{"id":17472549,"url":"https://github.com/shinnn/modify-event","last_synced_at":"2025-04-09T22:54:23.397Z","repository":{"id":16211709,"uuid":"18958717","full_name":"shinnn/modify-event","owner":"shinnn","description":"Modify the value of the specific object's event","archived":false,"fork":false,"pushed_at":"2019-01-10T01:47:40.000Z","size":92,"stargazers_count":6,"open_issues_count":0,"forks_count":3,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-10-18T19:57:28.229Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","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/shinnn.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":"2014-04-20T05:56:47.000Z","updated_at":"2019-01-10T01:44:02.000Z","dependencies_parsed_at":"2022-08-24T19:30:20.147Z","dependency_job_id":null,"html_url":"https://github.com/shinnn/modify-event","commit_stats":null,"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shinnn%2Fmodify-event","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shinnn%2Fmodify-event/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shinnn%2Fmodify-event/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shinnn%2Fmodify-event/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/shinnn","download_url":"https://codeload.github.com/shinnn/modify-event/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247953107,"owners_count":21023947,"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-10-18T17:26:40.198Z","updated_at":"2025-04-09T22:54:23.373Z","avatar_url":"https://github.com/shinnn.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# modify-event\n\n[![npm version](https://img.shields.io/npm/v/modify-event.svg)](https://www.npmjs.com/package/modify-event)\n[![Build Status](https://travis-ci.com/shinnn/modify-event.svg?branch=master)](https://travis-ci.com/shinnn/modify-event)\n[![Coverage Status](https://img.shields.io/coveralls/shinnn/modify-event.svg)](https://coveralls.io/github/shinnn/modify-event)\n\nModify the value of the specific object's [event](https://nodejs.org/api/events.html)\n\n```javascript\nconst {EventEmitter} = require('events');\nconst modifyEvent = require('modify-event');\n\nconst emitter = new EventEmitter();\n\nmodifyEvent(emitter, 'foo', val =\u003e val * 2);\n\nemitter.on('foo', data =\u003e {\n  data; //=\u003e 2\n});\n\nemitter.emit('foo', 1);\n```\n\n## Installation\n\n[Use](https://docs.npmjs.com/cli/install) [npm](https://docs.npmjs.com/about-npm/).\n\n```\nnpm install modify-event\n```\n\n## API\n\n```javascript\nconst modifyEvent = require('modify-event');\n```\n\n### modifyEvent(*eventEmitter*, *eventName*, *modifier*)\n\n*eventEmitter*: [`EventEmitter`](https://nodejs.org/api/events.html#events_class_eventemitter)  \n*eventName*: `string` `symbol` (event name)  \n*modifier*: `Function`  \nReturn: `EventEmitter` (a reference to the first argument)\n\nIt changes the first argument of the event listeners for a given event, in response to the return value of the *modifier* function.\n\n```javascript\nconst {EventEmitter} = require('events');\nconst modifyEvent = require('modify-event');\n\nconst emitter = new EventEmitter();\nconst eventName = Symbol('custom event name');\n\nmodifyEvent(emitter, eventName, val =\u003e `${val}b`);\nmodifyEvent(emitter, eventName, val =\u003e `${val}c`);\n\nemitter\n.on(eventName, listener)\n.emit(eventName, 'a');\n\nfunction listener(data) {\n  data; //=\u003e 'abc'\n}\n```\n\n## License\n\nCopyright (c) 2015 - 2019 [Shinnosuke Watanabe](https://github.com/shinnn)\n\nLicensed under [the MIT License](./LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshinnn%2Fmodify-event","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshinnn%2Fmodify-event","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshinnn%2Fmodify-event/lists"}