re-emitter
Advanced tools
Comparing version 0.3.0 to 1.0.0
27
index.js
@@ -1,15 +0,22 @@ | ||
var slice = Array.prototype.slice | ||
, EventEmitter = require("events").EventEmitter | ||
, reemit = require("./reemit") | ||
module.exports = reemit | ||
module.exports.filter = filter | ||
ReEmitter.reemit = reemit | ||
var EventEmitter = require('events').EventEmitter | ||
module.exports = ReEmitter | ||
function reemit (source, target, events) { | ||
if (!Array.isArray(events)) events = [ events ] | ||
function ReEmitter(other, list) { | ||
var emitter = new EventEmitter() | ||
events.forEach(function (event) { | ||
source.on(event, function () { | ||
var args = [].slice.call(arguments) | ||
args.unshift(event) | ||
target.emit.apply(target, args) | ||
}) | ||
}) | ||
} | ||
reemit(other, emitter, list) | ||
return emitter | ||
function filter (source, events) { | ||
var emitter = new EventEmitter() | ||
reemit(source, emitter, events) | ||
return emitter | ||
} |
{ | ||
"name": "re-emitter", | ||
"version": "0.3.0", | ||
"description": "Re emit events from another emitter", | ||
"keywords": [], | ||
"version": "1.0.0", | ||
"author": "Raynos <raynos2@gmail.com>", | ||
"repository": "git://github.com/Raynos/re-emitter.git", | ||
"main": "index", | ||
"homepage": "https://github.com/Raynos/re-emitter", | ||
"bugs": { | ||
"url": "https://github.com/feross/re-emitter/issues", | ||
"email": "raynos2@gmail.com" | ||
}, | ||
"contributors": [ | ||
{ | ||
"name": "Jake Verbaten" | ||
}, | ||
{ | ||
"name": "Feross Aboukhadijeh" | ||
} | ||
], | ||
"bugs": { | ||
"url": "https://github.com/Raynos/re-emitter/issues", | ||
"email": "raynos2@gmail.com" | ||
"dependencies": {}, | ||
"devDependencies": { | ||
"tape": "^2.13.4" | ||
}, | ||
"dependencies": { | ||
"to-array": "~0.1.3" | ||
}, | ||
"devDependencies": {}, | ||
"homepage": "https://github.com/feross/re-emitter", | ||
"keywords": [ | ||
"reemit", | ||
"re emit", | ||
"re-emit", | ||
"reemitter", | ||
"filter events", | ||
"events", | ||
"emitter" | ||
], | ||
"licenses": [ | ||
{ | ||
"type": "MIT", | ||
"url": "http://github.com/Raynos/re-emitter/raw/master/LICENSE" | ||
"url": "http://github.com/feross/re-emitter/raw/master/LICENSE" | ||
} | ||
], | ||
"scripts": {} | ||
"main": "index.js", | ||
"repository": "git://github.com/feross/re-emitter.git", | ||
"scripts": { | ||
"test": "tape test/*.js" | ||
}, | ||
"testling": { | ||
"files": "test/*.js", | ||
"browsers": [ | ||
"ie/9..latest", | ||
"chrome/25..latest", | ||
"chrome/canary", | ||
"firefox/20..latest", | ||
"firefox/nightly", | ||
"safari/6..latest", | ||
"opera/15.0..latest", | ||
"opera/next", | ||
"ipad/6.0..latest", | ||
"iphone/6.0..latest", | ||
"android-browser/4.2..latest" | ||
] | ||
} | ||
} |
@@ -1,39 +0,49 @@ | ||
# re-emitter | ||
# re-emitter [![travis](https://img.shields.io/travis/feross/re-emitter.svg)](https://travis-ci.org/feross/re-emitter) [![npm](https://img.shields.io/npm/v/re-emitter.svg)](https://npmjs.org/package/re-emitter) [![downloads](https://img.shields.io/npm/dm/re-emitter.svg)](https://npmjs.org/package/re-emitter) | ||
Re emit events from another emitter | ||
#### Re emit events from another emitter | ||
## Example | ||
![reemit](https://raw.githubusercontent.com/feross/re-emitter/master/img.jpg) | ||
``` js | ||
var EventEmitter = require("events").EventEmitter | ||
, ReEmitter = require("re-emitter") | ||
[![browser support](https://ci.testling.com/feross/re-emitter.png)](https://ci.testling.com/feross/re-emitter) | ||
### install | ||
``` | ||
npm install re-emitter | ||
``` | ||
### usage | ||
```js | ||
var emitter = new EventEmitter() | ||
, other = ReEmitter(emitter, ["foo", "bar"]) | ||
var other = new EventEmitter() | ||
other.on("foo", function () { | ||
console.log("fired") | ||
reemit(emitter, other, ['foo', 'bar']) | ||
other.on('foo', function () { | ||
t.pass('foo fired') | ||
}) | ||
other.on("baz", function () { | ||
console.log("should not fire") | ||
emitter.emit('foo') | ||
other.on('baz', function () { | ||
t.fail('baz should not fire on other emitter') | ||
}) | ||
emitter.on("bar", function () { | ||
console.log("should not fire") | ||
emitter.emit('baz') | ||
emitter.on('bar', function () { | ||
t.fail('bar should not fire on original emitter') | ||
}) | ||
emitter.emit("foo") | ||
emitter.emit("baz") | ||
other.emit("bar") | ||
other.emit('bar') | ||
``` | ||
## Installation | ||
### contributors | ||
`npm install re-emitter` | ||
- Raynos | ||
- Feross | ||
## Contributors | ||
### license | ||
- Raynos | ||
## MIT Licenced | ||
MIT. Copyright (c) Raynos. |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
15825
0
69
0
50
1
7
1
- Removedto-array@~0.1.3
- Removedto-array@0.1.4(transitive)