{"id":15207250,"url":"https://github.com/gulpjs/evented-require","last_synced_at":"2025-10-03T01:30:39.573Z","repository":{"id":44695150,"uuid":"183788404","full_name":"gulpjs/evented-require","owner":"gulpjs","description":"Require modules and receive events.","archived":true,"fork":false,"pushed_at":"2022-01-16T06:30:52.000Z","size":8,"stargazers_count":3,"open_issues_count":0,"forks_count":3,"subscribers_count":6,"default_branch":"master","last_synced_at":"2024-10-30T00:55:58.039Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gulpjs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-04-27T15:13:44.000Z","updated_at":"2023-11-05T01:51:52.000Z","dependencies_parsed_at":"2022-09-12T13:40:59.135Z","dependency_job_id":null,"html_url":"https://github.com/gulpjs/evented-require","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gulpjs%2Fevented-require","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gulpjs%2Fevented-require/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gulpjs%2Fevented-require/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gulpjs%2Fevented-require/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gulpjs","download_url":"https://codeload.github.com/gulpjs/evented-require/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":235059234,"owners_count":18929279,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-09-28T06:40:49.248Z","updated_at":"2025-10-03T01:30:39.265Z","avatar_url":"https://github.com/gulpjs.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n  \u003ca href=\"http://gulpjs.com\"\u003e\n    \u003cimg height=\"257\" width=\"114\" src=\"https://raw.githubusercontent.com/gulpjs/artwork/master/gulp-2x.png\"\u003e\n  \u003c/a\u003e\n\u003c/p\u003e\n\n# evented-require\n\n[![NPM version][npm-image]][npm-url] [![Downloads][downloads-image]][npm-url] [![Azure Pipelines Build Status][azure-pipelines-image]][azure-pipelines-url] [![Travis Build Status][travis-image]][travis-url] [![AppVeyor Build Status][appveyor-image]][appveyor-url] [![Coveralls Status][coveralls-image]][coveralls-url] [![Gitter chat][gitter-image]][gitter-url]\n\nRequire modules and receive events.\n\n## Usage\n\n```js\nvar EventedRequire = require('evented-require');\n\nvar basedir = process.cwd(); // or __dirname, etc\n\nvar loader = new EventedRequire(basedir);\n\nvar foo = loader.require('./foo'); // requires relative to basedir\nvar expect = loader.require('expect'); // requires from node_modules\n\nloader.on('before', function(moduleName) {\n  // emitted with the moduleName before that module is required\n});\n\nloader.on('success', function(moduleName, result) {\n  // emitted with the moduleName and the result of the require when a module is successfully required\n});\n\nloader.on('failure', function(moduleName, error) {\n  // emitted with the moduleName and the error of the require when a module fails to load\n});\n\n// loads a series of module in order, filtering out duplicate entries\nloader.requireAll([\n  './foo.js',\n  './bar.js'\n]);\n```\n\n## API\n\n### `new EventedRequire(basedir)`\n\nConstructs a new EventEmitter instance. Requires made using this instance will be relative to the `basedir` given.\n\n#### `instance.require(moduleName)`\n\nInstance method for requiring modules relative to the `basedir` of the instance. Emits events for `before`, `success`, and/or `failure` depending on the outcome of the require. Returns the result of the require if successful.\n\n#### `instance.requireAll(moduleNames)`\n\nInstance method for requiring an array of modules in order. Removes duplicates in the array before requiring them. Emits the same events as `instance.require` for each module.  Doesn't return anything.\n\n#### event: `instance.on('before', function(moduleName) {})`\n\nEmits the `before` event before a module is required. Provides the module name to the callback.\n\n#### event: `instance.on('success', function(moduleName, module) {})`\n\nEmits the `success` event after a module is required successfully. Provides the module name and the result of the require to the callback.\n\n#### event: `instance.on('failure', function(moduleName, error) {})`\n\nEmits the `failure` event after a module fails to load. Provides the module name and the error to the callback.\n\n## License\n\nMIT\n\n[downloads-image]: http://img.shields.io/npm/dm/evented-require.svg\n[npm-url]: https://www.npmjs.com/package/evented-require\n[npm-image]: http://img.shields.io/npm/v/evented-require.svg\n\n[azure-pipelines-url]: https://dev.azure.com/gulpjs/gulp/_build/latest?definitionId=3\u0026branchName=master\n[azure-pipelines-image]: https://dev.azure.com/gulpjs/gulp/_apis/build/status/evented-require?branchName=master\n\n[travis-url]: https://travis-ci.org/gulpjs/evented-require\n[travis-image]: http://img.shields.io/travis/gulpjs/evented-require.svg?label=travis-ci\n\n[appveyor-url]: https://ci.appveyor.com/project/gulpjs/evented-require\n[appveyor-image]: https://img.shields.io/appveyor/ci/gulpjs/evented-require.svg?label=appveyor\n\n[coveralls-url]: https://coveralls.io/r/gulpjs/evented-require\n[coveralls-image]: http://img.shields.io/coveralls/gulpjs/evented-require/master.svg\n\n[gitter-url]: https://gitter.im/gulpjs/gulp\n[gitter-image]: https://badges.gitter.im/gulpjs/gulp.svg\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgulpjs%2Fevented-require","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgulpjs%2Fevented-require","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgulpjs%2Fevented-require/lists"}