Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

re-emitter

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

re-emitter - npm Package Compare versions

Comparing version 0.3.0 to 1.0.0

.travis.yml

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.
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc