{"id":15207249,"url":"https://github.com/gulpjs/emit-mapper","last_synced_at":"2025-10-03T01:30:38.506Z","repository":{"id":57224617,"uuid":"183929393","full_name":"gulpjs/emit-mapper","owner":"gulpjs","description":"Re-emit events while mapping them to new names.","archived":true,"fork":false,"pushed_at":"2019-04-28T17:23:28.000Z","size":8,"stargazers_count":1,"open_issues_count":0,"forks_count":3,"subscribers_count":6,"default_branch":"master","last_synced_at":"2024-10-30T00:55:57.907Z","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-28T15:59:42.000Z","updated_at":"2023-11-12T03:31:48.000Z","dependencies_parsed_at":"2022-09-04T07:41:33.825Z","dependency_job_id":null,"html_url":"https://github.com/gulpjs/emit-mapper","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%2Femit-mapper","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gulpjs%2Femit-mapper/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gulpjs%2Femit-mapper/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gulpjs%2Femit-mapper/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gulpjs","download_url":"https://codeload.github.com/gulpjs/emit-mapper/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:47.765Z","updated_at":"2025-10-03T01:30:38.177Z","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# emit-mapper\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\nRe-emit events while mapping them to new names.\n\n## Usage\n\n```js\nvar src = new EventEmitter();\nvar dest = new EventEmitter();\nvar events = {\n  before: 'preload:before',\n  success: 'preload:success',\n  failure: 'preload:failure',\n};\n\nvar cleanup = emitMapper(src, dest, events);\n\ndest.on('preload:before', console.log);\ndest.on('preload:success', console.log);\ndest.on('preload:failure', console.log);\n\nsrc.emit('before', 'some value');\nsrc.emit('success', 1, 2, 3);\nsrc.emit('failure', 'moduleName', new Error('some error'));\n\n// No more events will be re-emitted after cleanup\ncleanup();\n\nsrc.emit('before', 'not re-emitted');\n```\n\n## API\n\n### `emitMapper(source, destination, eventMapping)`\n\nTakes a `source` EventEmitter, a `destination` EventEmitter, and an `eventMapping` object that maps `source` events to `destination` events. Whenever an event from the `eventMapping` object is emitted on `source`, a new event will be emitted on `destination` with the mapped named but containing all the same arguments.\n\nReturns a cleanup method to remove all handlers registered for re-emitting.\n\n## Prior art\n\nThis module is heavily inspired by [re-emitter][re-emitter] but the ability to map event names to new names was needed. Also, this module supports back to node 0.10 while `re-emitter` only supports node LTS versions.\n\n## License\n\nMIT\n\n[re-emitter]: https://github.com/feross/re-emitter\n\n[downloads-image]: http://img.shields.io/npm/dm/emit-mapper.svg\n[npm-url]: https://www.npmjs.com/package/emit-mapper\n[npm-image]: http://img.shields.io/npm/v/emit-mapper.svg\n\n[azure-pipelines-url]: https://dev.azure.com/gulpjs/gulp/_build/latest?definitionId=4\u0026branchName=master\n[azure-pipelines-image]: https://dev.azure.com/gulpjs/gulp/_apis/build/status/emit-mapper?branchName=master\n\n[travis-url]: https://travis-ci.org/gulpjs/emit-mapper\n[travis-image]: http://img.shields.io/travis/gulpjs/emit-mapper.svg?label=travis-ci\n\n[appveyor-url]: https://ci.appveyor.com/project/gulpjs/emit-mapper\n[appveyor-image]: https://img.shields.io/appveyor/ci/gulpjs/emit-mapper.svg?label=appveyor\n\n[coveralls-url]: https://coveralls.io/r/gulpjs/emit-mapper\n[coveralls-image]: http://img.shields.io/coveralls/gulpjs/emit-mapper/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%2Femit-mapper","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgulpjs%2Femit-mapper","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgulpjs%2Femit-mapper/lists"}