Software: Apache/2.4.41 (Ubuntu). PHP/8.0.30 uname -a: Linux apirnd 5.4.0-204-generic #224-Ubuntu SMP Thu Dec 5 13:38:28 UTC 2024 x86_64 uid=33(www-data) gid=33(www-data) groups=33(www-data) Safe-mode: OFF (not secure) /usr/local/share/.cache/yarn/v6/npm-re-emitter-1.1.3-integrity/node_modules/re-emitter/test/ drwxr-xr-x | |
| Viewing file: Select action/file-type: var EventEmitter = require('events').EventEmitter
var reemit = require('../')
var test = require('tape')
test('Re-emit events from another emitter', function (t) {
t.plan(1)
var emitter = new EventEmitter()
var other = new EventEmitter()
reemit(emitter, other, ['foo', 'bar'])
other.on('foo', function () {
t.pass('foo fired')
})
emitter.emit('foo')
other.on('baz', function () {
t.fail('baz should not fire on other emitter')
})
emitter.emit('baz')
emitter.on('bar', function () {
t.fail('bar should not fire on original emitter')
})
other.emit('bar')
})
test('Cancel reemitting at some point in the future', function (t) {
t.plan(2)
var emitter = new EventEmitter()
var other = new EventEmitter()
var cancel = reemit(emitter, other, ['foo', 'bar'])
other.on('foo', function () {
t.pass('foo fired')
})
// these should fire
emitter.emit('foo')
emitter.emit('foo')
cancel()
// none of these should fire
emitter.emit('foo')
emitter.emit('foo')
emitter.emit('foo')
})
test('Re-emit events from another emitter with arguments', function (t) {
t.plan(4)
var emitter = new EventEmitter()
var other = new EventEmitter()
reemit(emitter, other, ['foo', 'bar'])
other.on('foo', function (arg1, arg2) {
t.pass('foo fired')
t.equal(arg1, 'arg1')
t.equal(arg2, 'arg2')
t.equal(arguments[2], undefined)
})
emitter.emit('foo', 'arg1', 'arg2')
})
test('Filter events from another emitter', function (t) {
t.plan(1)
var emitter = new EventEmitter()
var other = reemit.filter(emitter, ['foo', 'bar'])
other.on('foo', function () {
t.pass('foo fired')
})
emitter.emit('foo')
other.on('baz', function () {
t.fail('baz should not fire on other emitter')
})
emitter.emit('baz')
emitter.on('bar', function () {
t.fail('bar should not fire on original emitter')
})
other.emit('bar')
})
|
:: Command execute :: | |
--[ c99shell v. 2.5 [PHP 8 Update] [24.05.2025] | Generation time: 0.0066 ]-- |