<commit_before># modify-event

[![NPM version](https://img.shields.io/npm/v/modify-event.svg)](https://www.npmjs.com/package/modify-event)
[![Build Status](https://travis-ci.org/shinnn/modify-event.svg?branch=master)](https://travis-ci.org/shinnn/modify-event)
[![Build status](https://ci.appveyor.com/api/projects/status/4noc4o9y40atakp3?svg=true)](https://ci.appveyor.com/project/ShinnosukeWatanabe/modify-event)
[![Coverage Status](https://img.shields.io/coveralls/shinnn/modify-event.svg)](https://coveralls.io/r/shinnn/modify-event)
[![devDependency Status](https://david-dm.org/shinnn/modify-event/dev-status.svg)](https://david-dm.org/shinnn/modify-event#info=devDependencies)

Modify the value of the specific object's [event](https://nodejs.org/api/events.html)

```javascript
const EventEmitter = require('events').EventEmitter;
const modifyEvent = require('modify-event');

let emitter = new EventEmitter();

modifyEvent(emitter, 'foo', val => val * 2);

emitter.on('foo', data => {
  data; //=> 2
});

emitter.emit('foo', 1);
```

## Installation

[Use npm.](https://docs.npmjs.com/cli/install)

```
npm install modify-event
```

## API

```javascript
const modifyEvent = require('modify-event');
```

### modifyEvent(*eventEmitter*, *eventName*, *modifier*)

*eventEmitter*: `Object` (an instance of [`EventEmitter`](https://nodejs.org/api/events.html#events_class_events_eventemitter) or its inheritance e.g. [`Stream`](https://nodejs.org/api/stream.html#stream_stream))  
*eventName*: `String` (event name)  
*modifier*: `Function`  
Return: `Object` (Same as the first argument)

It changes the first argument of the event listeners for a given event, in response to the return value of the *modifier* function.

```javascript
const EventEmitter = require('events').EventEmitter;
const modifyEvent = require('modify-event');

let emitter = new EventEmitter();

modifyEvent(emitter, 'data', val => val + 'b');
modifyEvent(emitter, 'data', val => val + 'c');

emitter
.on('data', listener)
.emit('data', 'a');

function listener(data) {
  data; //=> 'abc'<commit_msg>write the docs with more ES2015 friendly way<commit_after># modify-event

[![NPM version](https://img.shields.io/npm/v/modify-event.svg)](https://www.npmjs.com/package/modify-event)
[![Build Status](https://travis-ci.org/shinnn/modify-event.svg?branch=master)](https://travis-ci.org/shinnn/modify-event)
[![Build status](https://ci.appveyor.com/api/projects/status/4noc4o9y40atakp3?svg=true)](https://ci.appveyor.com/project/ShinnosukeWatanabe/modify-event)
[![Coverage Status](https://img.shields.io/coveralls/shinnn/modify-event.svg)](https://coveralls.io/r/shinnn/modify-event)
[![devDependency Status](https://david-dm.org/shinnn/modify-event/dev-status.svg)](https://david-dm.org/shinnn/modify-event#info=devDependencies)

Modify the value of the specific object's [event](https://nodejs.org/api/events.html)

```javascript
const {EventEmitter} = require('events');
const modifyEvent = require('modify-event');

const emitter = new EventEmitter();

modifyEvent(emitter, 'foo', val => val * 2);

emitter.on('foo', data => {
  data; //=> 2
});

emitter.emit('foo', 1);
```

## Installation

[Use npm.](https://docs.npmjs.com/cli/install)

```
npm install modify-event
```

## API

```javascript
const modifyEvent = require('modify-event');
```

### modifyEvent(*eventEmitter*, *eventName*, *modifier*)

*eventEmitter*: `Object` (an instance of [`EventEmitter`](https://nodejs.org/api/events.html#events_class_events_eventemitter) or its inheritance e.g. [`Stream`](https://nodejs.org/api/stream.html#stream_stream))  
*eventName*: `String` (event name)  
*modifier*: `Function`  
Return: `Object` (Same as the first argument)

It changes the first argument of the event listeners for a given event, in response to the return value of the *modifier* function.

```javascript
const {EventEmitter} = require('events');
const modifyEvent = require('modify-event');

const emitter = new EventEmitter();

modifyEvent(emitter, 'data', val => val + 'b');
modifyEvent(emitter, 'data', val => val + 'c');

emitter
.on('data', listener)
.emit('data', 'a');

function listener(data) {
  data; //=> 'abc'
{'fraction_non_alphanumeric': 0.1882634730538922, 'fraction_numerical': 0.005269461077844311, 'mean_word_length': 5.649681528662421, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 15, 'https://': 28, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5054022', 'n_tokens_mistral': 1485, 'n_tokens_neox': 1422, 'n_words': 272}