event-emitter
Advanced tools
Comparing version 0.3.0 to 0.3.1
{ | ||
"name": "event-emitter", | ||
"version": "0.3.0", | ||
"version": "0.3.1", | ||
"description": "Environment agnostic event emitter", | ||
@@ -5,0 +5,0 @@ "author": "Mariusz Nowak <medyk@medikoo.com> (http://www.medikoo.com/)", |
29
pipe.js
'use strict'; | ||
var defineProperty = Object.defineProperty | ||
, aFrom = require('es5-ext/array/from') | ||
var aFrom = require('es5-ext/array/from') | ||
, remove = require('es5-ext/array/#/remove') | ||
, value = require('es5-ext/object/valid-object') | ||
, d = require('d') | ||
, value = require('es5-ext/object/valid-object') | ||
, emit = require('./').methods.emit | ||
, defineProperty = Object.defineProperty | ||
, hasOwnProperty = Object.prototype.hasOwnProperty | ||
, getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor; | ||
module.exports = function (e1, e2) { | ||
var pipes, pipe, desc; | ||
module.exports = function (e1, e2/*, name*/) { | ||
var pipes, pipe, desc, name; | ||
(value(e1) && value(e2)); | ||
if (typeof e1.emit !== 'function') { | ||
throw new TypeError(e1 + ' is not emitter'); | ||
} | ||
name = arguments[2]; | ||
if (name === undefined) name = 'emit'; | ||
@@ -28,6 +27,10 @@ pipe = { | ||
} | ||
defineProperty(e1, '__eePipes__', d(pipes = [e2])); | ||
desc = getOwnPropertyDescriptor(e1, 'emit'); | ||
delete desc.get; | ||
delete desc.set; | ||
defineProperty(e1, '__eePipes__', d('c', pipes = [e2])); | ||
desc = getOwnPropertyDescriptor(e1, name); | ||
if (!desc) { | ||
desc = d('c', undefined); | ||
} else { | ||
delete desc.get; | ||
delete desc.set; | ||
} | ||
desc.value = function () { | ||
@@ -38,4 +41,4 @@ var i, emitter, data = aFrom(pipes); | ||
}; | ||
defineProperty(e1, 'emit', desc); | ||
defineProperty(e1, name, desc); | ||
return pipe; | ||
}; |
@@ -58,6 +58,7 @@ # event-emitter | ||
#### pipe(source, target) _(event-emitter/pipe)_ | ||
#### pipe(source, target/*, emitMethodName*/) _(event-emitter/pipe)_ | ||
Pipes all events from _source_ emitter onto _target_ emitter (all events from _source_ emitter will be emitted also on _target_ emitter, but not other way). | ||
Returns _pipe_ object which exposes `pipe.close` function. Invoke it to close configured _pipe_. | ||
Returns _pipe_ object which exposes `pipe.close` function. Invoke it to close configured _pipe_. | ||
It works internally by redefinition of `emit` method, if in your interface this method is referenced differenetly, provide its name (or symbol) with third argument. | ||
@@ -64,0 +65,0 @@ #### unify(emitter1, emitter2) _(event-emitter/unify)_ |
@@ -9,2 +9,3 @@ 'use strict'; | ||
ee(x); | ||
x = Object.create(x); | ||
ee(y); | ||
@@ -11,0 +12,0 @@ ee(z); |
Sorry, the diff of this file is not supported yet
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
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
25739
667
97
0