first commit
This commit is contained in:
1
build/node_modules/events/.npmignore
generated
vendored
Normal file
1
build/node_modules/events/.npmignore
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
node_modules
|
||||
8
build/node_modules/events/.travis.yml
generated
vendored
Normal file
8
build/node_modules/events/.travis.yml
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
sudo: false
|
||||
language: node_js
|
||||
node_js:
|
||||
- '0.10'
|
||||
env:
|
||||
global:
|
||||
- secure: XcBiD8yReflut9q7leKsigDZ0mI3qTKH+QrNVY8DaqlomJOZw8aOrVuX9Jz12l86ZJ41nbxmKnRNkFzcVr9mbP9YaeTb3DpeOBWmvaoSfud9Wnc16VfXtc1FCcwDhSVcSiM3UtnrmFU5cH+Dw1LPh5PbfylYOS/nJxUvG0FFLqI=
|
||||
- secure: jNWtEbqhUdQ0xXDHvCYfUbKYeJCi6a7B4LsrcxYCyWWn4NIgncE5x2YbB+FSUUFVYfz0dsn5RKP1oHB99f0laUEo18HBNkrAS/rtyOdVzcpJjbQ6kgSILGjnJD/Ty1B57Rcz3iyev5Y7bLZ6Y1FbDnk/i9/l0faOGz8vTC3Vdkc=
|
||||
12
build/node_modules/events/.zuul.yml
generated
vendored
Normal file
12
build/node_modules/events/.zuul.yml
generated
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
ui: mocha-qunit
|
||||
browsers:
|
||||
- name: chrome
|
||||
version: latest
|
||||
- name: firefox
|
||||
version: latest
|
||||
- name: safari
|
||||
version: 5..latest
|
||||
- name: iphone
|
||||
version: latest
|
||||
- name: ie
|
||||
version: 8..latest
|
||||
42
build/node_modules/events/History.md
generated
vendored
Normal file
42
build/node_modules/events/History.md
generated
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
# 1.1.1 (2016-06-22)
|
||||
|
||||
- add more context to errors if they are not instanceof Error
|
||||
|
||||
# 1.1.0 (2015-09-29)
|
||||
|
||||
- add Emitter#listerCount (to match node v4 api)
|
||||
|
||||
# 1.0.2 (2014-08-28)
|
||||
|
||||
- remove un-reachable code
|
||||
- update devDeps
|
||||
|
||||
## 1.0.1 / 2014-05-11
|
||||
|
||||
- check for console.trace before using it
|
||||
|
||||
## 1.0.0 / 2013-12-10
|
||||
|
||||
- Update to latest events code from node.js 0.10
|
||||
- copy tests from node.js
|
||||
|
||||
## 0.4.0 / 2011-07-03 ##
|
||||
|
||||
- Switching to graphquire@0.8.0
|
||||
|
||||
## 0.3.0 / 2011-07-03 ##
|
||||
|
||||
- Switching to URL based module require.
|
||||
|
||||
## 0.2.0 / 2011-06-10 ##
|
||||
|
||||
- Simplified package structure.
|
||||
- Graphquire for dependency management.
|
||||
|
||||
## 0.1.1 / 2011-05-16 ##
|
||||
|
||||
- Unhandled errors are logged via console.error
|
||||
|
||||
## 0.1.0 / 2011-04-22 ##
|
||||
|
||||
- Initial release
|
||||
22
build/node_modules/events/LICENSE
generated
vendored
Normal file
22
build/node_modules/events/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
MIT
|
||||
|
||||
Copyright Joyent, Inc. and other Node contributors.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a
|
||||
copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to permit
|
||||
persons to whom the Software is furnished to do so, subject to the
|
||||
following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included
|
||||
in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
||||
NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||||
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
||||
USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
19
build/node_modules/events/Readme.md
generated
vendored
Normal file
19
build/node_modules/events/Readme.md
generated
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
# events [](https://travis-ci.org/Gozala/events)
|
||||
|
||||
Node's event emitter for all engines.
|
||||
|
||||
## Install ##
|
||||
|
||||
```
|
||||
npm install events
|
||||
```
|
||||
|
||||
## Require ##
|
||||
|
||||
```javascript
|
||||
var EventEmitter = require('events').EventEmitter
|
||||
```
|
||||
|
||||
## Usage ##
|
||||
|
||||
See the [node.js event emitter docs](http://nodejs.org/api/events.html)
|
||||
302
build/node_modules/events/events.js
generated
vendored
Normal file
302
build/node_modules/events/events.js
generated
vendored
Normal file
@@ -0,0 +1,302 @@
|
||||
// Copyright Joyent, Inc. and other Node contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to permit
|
||||
// persons to whom the Software is furnished to do so, subject to the
|
||||
// following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
||||
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||||
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
||||
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
function EventEmitter() {
|
||||
this._events = this._events || {};
|
||||
this._maxListeners = this._maxListeners || undefined;
|
||||
}
|
||||
module.exports = EventEmitter;
|
||||
|
||||
// Backwards-compat with node 0.10.x
|
||||
EventEmitter.EventEmitter = EventEmitter;
|
||||
|
||||
EventEmitter.prototype._events = undefined;
|
||||
EventEmitter.prototype._maxListeners = undefined;
|
||||
|
||||
// By default EventEmitters will print a warning if more than 10 listeners are
|
||||
// added to it. This is a useful default which helps finding memory leaks.
|
||||
EventEmitter.defaultMaxListeners = 10;
|
||||
|
||||
// Obviously not all Emitters should be limited to 10. This function allows
|
||||
// that to be increased. Set to zero for unlimited.
|
||||
EventEmitter.prototype.setMaxListeners = function(n) {
|
||||
if (!isNumber(n) || n < 0 || isNaN(n))
|
||||
throw TypeError('n must be a positive number');
|
||||
this._maxListeners = n;
|
||||
return this;
|
||||
};
|
||||
|
||||
EventEmitter.prototype.emit = function(type) {
|
||||
var er, handler, len, args, i, listeners;
|
||||
|
||||
if (!this._events)
|
||||
this._events = {};
|
||||
|
||||
// If there is no 'error' event listener then throw.
|
||||
if (type === 'error') {
|
||||
if (!this._events.error ||
|
||||
(isObject(this._events.error) && !this._events.error.length)) {
|
||||
er = arguments[1];
|
||||
if (er instanceof Error) {
|
||||
throw er; // Unhandled 'error' event
|
||||
} else {
|
||||
// At least give some kind of context to the user
|
||||
var err = new Error('Uncaught, unspecified "error" event. (' + er + ')');
|
||||
err.context = er;
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
handler = this._events[type];
|
||||
|
||||
if (isUndefined(handler))
|
||||
return false;
|
||||
|
||||
if (isFunction(handler)) {
|
||||
switch (arguments.length) {
|
||||
// fast cases
|
||||
case 1:
|
||||
handler.call(this);
|
||||
break;
|
||||
case 2:
|
||||
handler.call(this, arguments[1]);
|
||||
break;
|
||||
case 3:
|
||||
handler.call(this, arguments[1], arguments[2]);
|
||||
break;
|
||||
// slower
|
||||
default:
|
||||
args = Array.prototype.slice.call(arguments, 1);
|
||||
handler.apply(this, args);
|
||||
}
|
||||
} else if (isObject(handler)) {
|
||||
args = Array.prototype.slice.call(arguments, 1);
|
||||
listeners = handler.slice();
|
||||
len = listeners.length;
|
||||
for (i = 0; i < len; i++)
|
||||
listeners[i].apply(this, args);
|
||||
}
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
EventEmitter.prototype.addListener = function(type, listener) {
|
||||
var m;
|
||||
|
||||
if (!isFunction(listener))
|
||||
throw TypeError('listener must be a function');
|
||||
|
||||
if (!this._events)
|
||||
this._events = {};
|
||||
|
||||
// To avoid recursion in the case that type === "newListener"! Before
|
||||
// adding it to the listeners, first emit "newListener".
|
||||
if (this._events.newListener)
|
||||
this.emit('newListener', type,
|
||||
isFunction(listener.listener) ?
|
||||
listener.listener : listener);
|
||||
|
||||
if (!this._events[type])
|
||||
// Optimize the case of one listener. Don't need the extra array object.
|
||||
this._events[type] = listener;
|
||||
else if (isObject(this._events[type]))
|
||||
// If we've already got an array, just append.
|
||||
this._events[type].push(listener);
|
||||
else
|
||||
// Adding the second element, need to change to array.
|
||||
this._events[type] = [this._events[type], listener];
|
||||
|
||||
// Check for listener leak
|
||||
if (isObject(this._events[type]) && !this._events[type].warned) {
|
||||
if (!isUndefined(this._maxListeners)) {
|
||||
m = this._maxListeners;
|
||||
} else {
|
||||
m = EventEmitter.defaultMaxListeners;
|
||||
}
|
||||
|
||||
if (m && m > 0 && this._events[type].length > m) {
|
||||
this._events[type].warned = true;
|
||||
console.error('(node) warning: possible EventEmitter memory ' +
|
||||
'leak detected. %d listeners added. ' +
|
||||
'Use emitter.setMaxListeners() to increase limit.',
|
||||
this._events[type].length);
|
||||
if (typeof console.trace === 'function') {
|
||||
// not supported in IE 10
|
||||
console.trace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
EventEmitter.prototype.on = EventEmitter.prototype.addListener;
|
||||
|
||||
EventEmitter.prototype.once = function(type, listener) {
|
||||
if (!isFunction(listener))
|
||||
throw TypeError('listener must be a function');
|
||||
|
||||
var fired = false;
|
||||
|
||||
function g() {
|
||||
this.removeListener(type, g);
|
||||
|
||||
if (!fired) {
|
||||
fired = true;
|
||||
listener.apply(this, arguments);
|
||||
}
|
||||
}
|
||||
|
||||
g.listener = listener;
|
||||
this.on(type, g);
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
// emits a 'removeListener' event iff the listener was removed
|
||||
EventEmitter.prototype.removeListener = function(type, listener) {
|
||||
var list, position, length, i;
|
||||
|
||||
if (!isFunction(listener))
|
||||
throw TypeError('listener must be a function');
|
||||
|
||||
if (!this._events || !this._events[type])
|
||||
return this;
|
||||
|
||||
list = this._events[type];
|
||||
length = list.length;
|
||||
position = -1;
|
||||
|
||||
if (list === listener ||
|
||||
(isFunction(list.listener) && list.listener === listener)) {
|
||||
delete this._events[type];
|
||||
if (this._events.removeListener)
|
||||
this.emit('removeListener', type, listener);
|
||||
|
||||
} else if (isObject(list)) {
|
||||
for (i = length; i-- > 0;) {
|
||||
if (list[i] === listener ||
|
||||
(list[i].listener && list[i].listener === listener)) {
|
||||
position = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (position < 0)
|
||||
return this;
|
||||
|
||||
if (list.length === 1) {
|
||||
list.length = 0;
|
||||
delete this._events[type];
|
||||
} else {
|
||||
list.splice(position, 1);
|
||||
}
|
||||
|
||||
if (this._events.removeListener)
|
||||
this.emit('removeListener', type, listener);
|
||||
}
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
EventEmitter.prototype.removeAllListeners = function(type) {
|
||||
var key, listeners;
|
||||
|
||||
if (!this._events)
|
||||
return this;
|
||||
|
||||
// not listening for removeListener, no need to emit
|
||||
if (!this._events.removeListener) {
|
||||
if (arguments.length === 0)
|
||||
this._events = {};
|
||||
else if (this._events[type])
|
||||
delete this._events[type];
|
||||
return this;
|
||||
}
|
||||
|
||||
// emit removeListener for all listeners on all events
|
||||
if (arguments.length === 0) {
|
||||
for (key in this._events) {
|
||||
if (key === 'removeListener') continue;
|
||||
this.removeAllListeners(key);
|
||||
}
|
||||
this.removeAllListeners('removeListener');
|
||||
this._events = {};
|
||||
return this;
|
||||
}
|
||||
|
||||
listeners = this._events[type];
|
||||
|
||||
if (isFunction(listeners)) {
|
||||
this.removeListener(type, listeners);
|
||||
} else if (listeners) {
|
||||
// LIFO order
|
||||
while (listeners.length)
|
||||
this.removeListener(type, listeners[listeners.length - 1]);
|
||||
}
|
||||
delete this._events[type];
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
EventEmitter.prototype.listeners = function(type) {
|
||||
var ret;
|
||||
if (!this._events || !this._events[type])
|
||||
ret = [];
|
||||
else if (isFunction(this._events[type]))
|
||||
ret = [this._events[type]];
|
||||
else
|
||||
ret = this._events[type].slice();
|
||||
return ret;
|
||||
};
|
||||
|
||||
EventEmitter.prototype.listenerCount = function(type) {
|
||||
if (this._events) {
|
||||
var evlistener = this._events[type];
|
||||
|
||||
if (isFunction(evlistener))
|
||||
return 1;
|
||||
else if (evlistener)
|
||||
return evlistener.length;
|
||||
}
|
||||
return 0;
|
||||
};
|
||||
|
||||
EventEmitter.listenerCount = function(emitter, type) {
|
||||
return emitter.listenerCount(type);
|
||||
};
|
||||
|
||||
function isFunction(arg) {
|
||||
return typeof arg === 'function';
|
||||
}
|
||||
|
||||
function isNumber(arg) {
|
||||
return typeof arg === 'number';
|
||||
}
|
||||
|
||||
function isObject(arg) {
|
||||
return typeof arg === 'object' && arg !== null;
|
||||
}
|
||||
|
||||
function isUndefined(arg) {
|
||||
return arg === void 0;
|
||||
}
|
||||
63
build/node_modules/events/package.json
generated
vendored
Normal file
63
build/node_modules/events/package.json
generated
vendored
Normal file
@@ -0,0 +1,63 @@
|
||||
{
|
||||
"_from": "events@~1.1.0",
|
||||
"_id": "events@1.1.1",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha1-nr23Y1rQmccNzEwqH1AEKI6L2SQ=",
|
||||
"_location": "/events",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "range",
|
||||
"registry": true,
|
||||
"raw": "events@~1.1.0",
|
||||
"name": "events",
|
||||
"escapedName": "events",
|
||||
"rawSpec": "~1.1.0",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "~1.1.0"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/browserify"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/events/-/events-1.1.1.tgz",
|
||||
"_shasum": "9ebdb7635ad099c70dcc4c2a1f5004288e8bd924",
|
||||
"_spec": "events@~1.1.0",
|
||||
"_where": "/Users/asciidisco/Desktop/asciidisco.com/build/node_modules/browserify",
|
||||
"author": {
|
||||
"name": "Irakli Gozalishvili",
|
||||
"email": "rfobic@gmail.com",
|
||||
"url": "http://jeditoolkit.com"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "http://github.com/Gozala/events/issues/"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"deprecated": false,
|
||||
"description": "Node's event emitter for all engines.",
|
||||
"devDependencies": {
|
||||
"mocha": "~1.21.4",
|
||||
"zuul": "~1.10.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=0.4.x"
|
||||
},
|
||||
"homepage": "https://github.com/Gozala/events#readme",
|
||||
"id": "events",
|
||||
"keywords": [
|
||||
"events",
|
||||
"eventEmitter",
|
||||
"eventDispatcher",
|
||||
"listeners"
|
||||
],
|
||||
"license": "MIT",
|
||||
"main": "./events.js",
|
||||
"name": "events",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/Gozala/events.git",
|
||||
"web": "https://github.com/Gozala/events"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "mocha --ui qunit -- tests/index.js && zuul -- tests/index.js"
|
||||
},
|
||||
"version": "1.1.1"
|
||||
}
|
||||
63
build/node_modules/events/tests/add-listeners.js
generated
vendored
Normal file
63
build/node_modules/events/tests/add-listeners.js
generated
vendored
Normal file
@@ -0,0 +1,63 @@
|
||||
// Copyright Joyent, Inc. and other Node contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to permit
|
||||
// persons to whom the Software is furnished to do so, subject to the
|
||||
// following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
||||
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||||
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
||||
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
var assert = require('assert');
|
||||
var events = require('../');
|
||||
|
||||
var e = new events.EventEmitter();
|
||||
|
||||
var events_new_listener_emited = [];
|
||||
var listeners_new_listener_emited = [];
|
||||
var times_hello_emited = 0;
|
||||
|
||||
// sanity check
|
||||
assert.equal(e.addListener, e.on);
|
||||
|
||||
e.on('newListener', function(event, listener) {
|
||||
console.log('newListener: ' + event);
|
||||
events_new_listener_emited.push(event);
|
||||
listeners_new_listener_emited.push(listener);
|
||||
});
|
||||
|
||||
function hello(a, b) {
|
||||
console.log('hello');
|
||||
times_hello_emited += 1;
|
||||
assert.equal('a', a);
|
||||
assert.equal('b', b);
|
||||
}
|
||||
e.on('hello', hello);
|
||||
|
||||
var foo = function() {};
|
||||
e.once('foo', foo);
|
||||
|
||||
console.log('start');
|
||||
|
||||
e.emit('hello', 'a', 'b');
|
||||
|
||||
|
||||
// just make sure that this doesn't throw:
|
||||
var f = new events.EventEmitter();
|
||||
f.setMaxListeners(0);
|
||||
|
||||
assert.deepEqual(['hello', 'foo'], events_new_listener_emited);
|
||||
assert.deepEqual([hello, foo], listeners_new_listener_emited);
|
||||
assert.equal(1, times_hello_emited);
|
||||
|
||||
86
build/node_modules/events/tests/check-listener-leaks.js
generated
vendored
Normal file
86
build/node_modules/events/tests/check-listener-leaks.js
generated
vendored
Normal file
@@ -0,0 +1,86 @@
|
||||
// Copyright Joyent, Inc. and other Node contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to permit
|
||||
// persons to whom the Software is furnished to do so, subject to the
|
||||
// following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
||||
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||||
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
||||
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
var assert = require('assert');
|
||||
var events = require('../');
|
||||
|
||||
var e = new events.EventEmitter();
|
||||
|
||||
// default
|
||||
for (var i = 0; i < 10; i++) {
|
||||
e.on('default', function() {});
|
||||
}
|
||||
assert.ok(!e._events['default'].hasOwnProperty('warned'));
|
||||
e.on('default', function() {});
|
||||
assert.ok(e._events['default'].warned);
|
||||
|
||||
// specific
|
||||
e.setMaxListeners(5);
|
||||
for (var i = 0; i < 5; i++) {
|
||||
e.on('specific', function() {});
|
||||
}
|
||||
assert.ok(!e._events['specific'].hasOwnProperty('warned'));
|
||||
e.on('specific', function() {});
|
||||
assert.ok(e._events['specific'].warned);
|
||||
|
||||
// only one
|
||||
e.setMaxListeners(1);
|
||||
e.on('only one', function() {});
|
||||
assert.ok(!e._events['only one'].hasOwnProperty('warned'));
|
||||
e.on('only one', function() {});
|
||||
assert.ok(e._events['only one'].hasOwnProperty('warned'));
|
||||
|
||||
// unlimited
|
||||
e.setMaxListeners(0);
|
||||
for (var i = 0; i < 1000; i++) {
|
||||
e.on('unlimited', function() {});
|
||||
}
|
||||
assert.ok(!e._events['unlimited'].hasOwnProperty('warned'));
|
||||
|
||||
// process-wide
|
||||
events.EventEmitter.defaultMaxListeners = 42;
|
||||
e = new events.EventEmitter();
|
||||
|
||||
for (var i = 0; i < 42; ++i) {
|
||||
e.on('fortytwo', function() {});
|
||||
}
|
||||
assert.ok(!e._events['fortytwo'].hasOwnProperty('warned'));
|
||||
e.on('fortytwo', function() {});
|
||||
assert.ok(e._events['fortytwo'].hasOwnProperty('warned'));
|
||||
delete e._events['fortytwo'].warned;
|
||||
|
||||
events.EventEmitter.defaultMaxListeners = 44;
|
||||
e.on('fortytwo', function() {});
|
||||
assert.ok(!e._events['fortytwo'].hasOwnProperty('warned'));
|
||||
e.on('fortytwo', function() {});
|
||||
assert.ok(e._events['fortytwo'].hasOwnProperty('warned'));
|
||||
|
||||
// but _maxListeners still has precedence over defaultMaxListeners
|
||||
events.EventEmitter.defaultMaxListeners = 42;
|
||||
e = new events.EventEmitter();
|
||||
e.setMaxListeners(1);
|
||||
e.on('uno', function() {});
|
||||
assert.ok(!e._events['uno'].hasOwnProperty('warned'));
|
||||
e.on('uno', function() {});
|
||||
assert.ok(e._events['uno'].hasOwnProperty('warned'));
|
||||
|
||||
// chainable
|
||||
assert.strictEqual(e, e.setMaxListeners(1));
|
||||
42
build/node_modules/events/tests/common.js
generated
vendored
Normal file
42
build/node_modules/events/tests/common.js
generated
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
var assert = require('assert');
|
||||
|
||||
var mustCallChecks = [];
|
||||
|
||||
function runCallChecks() {
|
||||
var failed_count = 0;
|
||||
for (var i=0 ; i< mustCallChecks.length; ++i) {
|
||||
var context = mustCallChecks[i];
|
||||
if (context.actual === context.expected) {
|
||||
continue;
|
||||
}
|
||||
|
||||
failed_count++;
|
||||
console.log('Mismatched %s function calls. Expected %d, actual %d.',
|
||||
context.name,
|
||||
context.expected,
|
||||
context.actual);
|
||||
console.log(context.stack.split('\n').slice(2).join('\n'));
|
||||
}
|
||||
|
||||
assert(failed_count === 0);
|
||||
}
|
||||
|
||||
after(runCallChecks);
|
||||
|
||||
exports.mustCall = function(fn, expected) {
|
||||
if (typeof expected !== 'number') expected = 1;
|
||||
|
||||
var context = {
|
||||
expected: expected,
|
||||
actual: 0,
|
||||
stack: (new Error).stack,
|
||||
name: fn.name || '<anonymous>'
|
||||
};
|
||||
|
||||
mustCallChecks.push(context);
|
||||
|
||||
return function() {
|
||||
context.actual++;
|
||||
return fn.apply(this, arguments);
|
||||
};
|
||||
};
|
||||
25
build/node_modules/events/tests/index.js
generated
vendored
Normal file
25
build/node_modules/events/tests/index.js
generated
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
|
||||
require('./legacy-compat');
|
||||
|
||||
// we do this to easily wrap each file in a mocha test
|
||||
// and also have browserify be able to statically analyze this file
|
||||
var orig_require = require;
|
||||
var require = function(file) {
|
||||
test(file, function() {
|
||||
orig_require(file);
|
||||
});
|
||||
}
|
||||
|
||||
require('./add-listeners.js');
|
||||
require('./check-listener-leaks.js');
|
||||
require('./listener-count.js');
|
||||
require('./listeners-side-effects.js');
|
||||
require('./listeners.js');
|
||||
require('./max-listeners.js');
|
||||
require('./modify-in-emit.js');
|
||||
require('./num-args.js');
|
||||
require('./once.js');
|
||||
require('./set-max-listeners-side-effects.js');
|
||||
require('./subclass.js');
|
||||
require('./remove-all-listeners.js');
|
||||
require('./remove-listeners.js');
|
||||
18
build/node_modules/events/tests/legacy-compat.js
generated
vendored
Normal file
18
build/node_modules/events/tests/legacy-compat.js
generated
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
// sigh... life is hard
|
||||
if (!global.console) {
|
||||
console = {}
|
||||
}
|
||||
|
||||
var fns = ['log', 'error', 'trace'];
|
||||
for (var i=0 ; i<fns.length ; ++i) {
|
||||
var fn = fns[i];
|
||||
if (!console[fn]) {
|
||||
console[fn] = function() {};
|
||||
}
|
||||
}
|
||||
|
||||
if (!Array.isArray) {
|
||||
Array.isArray = function(arr) {
|
||||
return Object.prototype.toString.call(arr) === '[object Array]';
|
||||
}
|
||||
}
|
||||
36
build/node_modules/events/tests/listener-count.js
generated
vendored
Normal file
36
build/node_modules/events/tests/listener-count.js
generated
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
// Copyright Joyent, Inc. and other Node contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to permit
|
||||
// persons to whom the Software is furnished to do so, subject to the
|
||||
// following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
||||
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||||
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
||||
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
var assert = require('assert');
|
||||
var EventEmitter = require('../');
|
||||
|
||||
var emitter = new EventEmitter();
|
||||
emitter.on('foo', function() {});
|
||||
emitter.on('foo', function() {});
|
||||
emitter.on('baz', function() {});
|
||||
// Allow any type
|
||||
emitter.on(123, function() {});
|
||||
|
||||
assert.strictEqual(EventEmitter.listenerCount(emitter, 'foo'), 2);
|
||||
assert.strictEqual(emitter.listenerCount('foo'), 2);
|
||||
assert.strictEqual(emitter.listenerCount('bar'), 0);
|
||||
assert.strictEqual(emitter.listenerCount('baz'), 1);
|
||||
assert.strictEqual(emitter.listenerCount(123), 1);
|
||||
55
build/node_modules/events/tests/listeners-side-effects.js
generated
vendored
Normal file
55
build/node_modules/events/tests/listeners-side-effects.js
generated
vendored
Normal file
@@ -0,0 +1,55 @@
|
||||
|
||||
// Copyright Joyent, Inc. and other Node contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to permit
|
||||
// persons to whom the Software is furnished to do so, subject to the
|
||||
// following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
||||
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||||
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
||||
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
var assert = require('assert');
|
||||
var EventEmitter = require('../').EventEmitter;
|
||||
|
||||
var e = new EventEmitter;
|
||||
var fl; // foo listeners
|
||||
|
||||
fl = e.listeners('foo');
|
||||
assert(Array.isArray(fl));
|
||||
assert(fl.length === 0);
|
||||
assert.deepEqual(e._events, {});
|
||||
|
||||
e.on('foo', assert.fail);
|
||||
fl = e.listeners('foo');
|
||||
assert(e._events.foo === assert.fail);
|
||||
assert(Array.isArray(fl));
|
||||
assert(fl.length === 1);
|
||||
assert(fl[0] === assert.fail);
|
||||
|
||||
e.listeners('bar');
|
||||
assert(!e._events.hasOwnProperty('bar'));
|
||||
|
||||
e.on('foo', assert.ok);
|
||||
fl = e.listeners('foo');
|
||||
|
||||
assert(Array.isArray(e._events.foo));
|
||||
assert(e._events.foo.length === 2);
|
||||
assert(e._events.foo[0] === assert.fail);
|
||||
assert(e._events.foo[1] === assert.ok);
|
||||
|
||||
assert(Array.isArray(fl));
|
||||
assert(fl.length === 2);
|
||||
assert(fl[0] === assert.fail);
|
||||
assert(fl[1] === assert.ok);
|
||||
51
build/node_modules/events/tests/listeners.js
generated
vendored
Normal file
51
build/node_modules/events/tests/listeners.js
generated
vendored
Normal file
@@ -0,0 +1,51 @@
|
||||
|
||||
// Copyright Joyent, Inc. and other Node contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to permit
|
||||
// persons to whom the Software is furnished to do so, subject to the
|
||||
// following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
||||
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||||
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
||||
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
var assert = require('assert');
|
||||
var events = require('../');
|
||||
|
||||
function listener() {}
|
||||
function listener2() {}
|
||||
|
||||
var e1 = new events.EventEmitter();
|
||||
e1.on('foo', listener);
|
||||
var fooListeners = e1.listeners('foo');
|
||||
assert.deepEqual(e1.listeners('foo'), [listener]);
|
||||
e1.removeAllListeners('foo');
|
||||
assert.deepEqual(e1.listeners('foo'), []);
|
||||
assert.deepEqual(fooListeners, [listener]);
|
||||
|
||||
var e2 = new events.EventEmitter();
|
||||
e2.on('foo', listener);
|
||||
var e2ListenersCopy = e2.listeners('foo');
|
||||
assert.deepEqual(e2ListenersCopy, [listener]);
|
||||
assert.deepEqual(e2.listeners('foo'), [listener]);
|
||||
e2ListenersCopy.push(listener2);
|
||||
assert.deepEqual(e2.listeners('foo'), [listener]);
|
||||
assert.deepEqual(e2ListenersCopy, [listener, listener2]);
|
||||
|
||||
var e3 = new events.EventEmitter();
|
||||
e3.on('foo', listener);
|
||||
var e3ListenersCopy = e3.listeners('foo');
|
||||
e3.on('foo', listener2);
|
||||
assert.deepEqual(e3.listeners('foo'), [listener, listener2]);
|
||||
assert.deepEqual(e3ListenersCopy, [listener]);
|
||||
50
build/node_modules/events/tests/max-listeners.js
generated
vendored
Normal file
50
build/node_modules/events/tests/max-listeners.js
generated
vendored
Normal file
@@ -0,0 +1,50 @@
|
||||
// Copyright Joyent, Inc. and other Node contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to permit
|
||||
// persons to whom the Software is furnished to do so, subject to the
|
||||
// following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
||||
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||||
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
||||
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
var assert = require('assert');
|
||||
var events = require('../');
|
||||
|
||||
var gotEvent = false;
|
||||
|
||||
var e = new events.EventEmitter();
|
||||
|
||||
e.on('maxListeners', function() {
|
||||
gotEvent = true;
|
||||
});
|
||||
|
||||
// Should not corrupt the 'maxListeners' queue.
|
||||
e.setMaxListeners(42);
|
||||
|
||||
assert.throws(function() {
|
||||
e.setMaxListeners(NaN);
|
||||
});
|
||||
|
||||
assert.throws(function() {
|
||||
e.setMaxListeners(-1);
|
||||
});
|
||||
|
||||
assert.throws(function() {
|
||||
e.setMaxListeners("and even this");
|
||||
});
|
||||
|
||||
e.emit('maxListeners');
|
||||
|
||||
assert(gotEvent);
|
||||
76
build/node_modules/events/tests/modify-in-emit.js
generated
vendored
Normal file
76
build/node_modules/events/tests/modify-in-emit.js
generated
vendored
Normal file
@@ -0,0 +1,76 @@
|
||||
// Copyright Joyent, Inc. and other Node contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to permit
|
||||
// persons to whom the Software is furnished to do so, subject to the
|
||||
// following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
||||
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||||
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
||||
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
var assert = require('assert');
|
||||
var events = require('../');
|
||||
|
||||
var callbacks_called = [];
|
||||
|
||||
var e = new events.EventEmitter();
|
||||
|
||||
function callback1() {
|
||||
callbacks_called.push('callback1');
|
||||
e.on('foo', callback2);
|
||||
e.on('foo', callback3);
|
||||
e.removeListener('foo', callback1);
|
||||
}
|
||||
|
||||
function callback2() {
|
||||
callbacks_called.push('callback2');
|
||||
e.removeListener('foo', callback2);
|
||||
}
|
||||
|
||||
function callback3() {
|
||||
callbacks_called.push('callback3');
|
||||
e.removeListener('foo', callback3);
|
||||
}
|
||||
|
||||
e.on('foo', callback1);
|
||||
assert.equal(1, e.listeners('foo').length);
|
||||
|
||||
e.emit('foo');
|
||||
assert.equal(2, e.listeners('foo').length);
|
||||
assert.deepEqual(['callback1'], callbacks_called);
|
||||
|
||||
e.emit('foo');
|
||||
assert.equal(0, e.listeners('foo').length);
|
||||
assert.deepEqual(['callback1', 'callback2', 'callback3'], callbacks_called);
|
||||
|
||||
e.emit('foo');
|
||||
assert.equal(0, e.listeners('foo').length);
|
||||
assert.deepEqual(['callback1', 'callback2', 'callback3'], callbacks_called);
|
||||
|
||||
e.on('foo', callback1);
|
||||
e.on('foo', callback2);
|
||||
assert.equal(2, e.listeners('foo').length);
|
||||
e.removeAllListeners('foo');
|
||||
assert.equal(0, e.listeners('foo').length);
|
||||
|
||||
// Verify that removing callbacks while in emit allows emits to propagate to
|
||||
// all listeners
|
||||
callbacks_called = [];
|
||||
|
||||
e.on('foo', callback2);
|
||||
e.on('foo', callback3);
|
||||
assert.equal(2, e.listeners('foo').length);
|
||||
e.emit('foo');
|
||||
assert.deepEqual(['callback2', 'callback3'], callbacks_called);
|
||||
assert.equal(0, e.listeners('foo').length);
|
||||
44
build/node_modules/events/tests/num-args.js
generated
vendored
Normal file
44
build/node_modules/events/tests/num-args.js
generated
vendored
Normal file
@@ -0,0 +1,44 @@
|
||||
// Copyright Joyent, Inc. and other Node contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to permit
|
||||
// persons to whom the Software is furnished to do so, subject to the
|
||||
// following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
||||
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||||
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
||||
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
var assert = require('assert');
|
||||
var events = require('../');
|
||||
|
||||
var e = new events.EventEmitter(),
|
||||
num_args_emited = [];
|
||||
|
||||
e.on('numArgs', function() {
|
||||
var numArgs = arguments.length;
|
||||
console.log('numArgs: ' + numArgs);
|
||||
num_args_emited.push(numArgs);
|
||||
});
|
||||
|
||||
console.log('start');
|
||||
|
||||
e.emit('numArgs');
|
||||
e.emit('numArgs', null);
|
||||
e.emit('numArgs', null, null);
|
||||
e.emit('numArgs', null, null, null);
|
||||
e.emit('numArgs', null, null, null, null);
|
||||
e.emit('numArgs', null, null, null, null, null);
|
||||
|
||||
assert.deepEqual([0, 1, 2, 3, 4, 5], num_args_emited);
|
||||
|
||||
59
build/node_modules/events/tests/once.js
generated
vendored
Normal file
59
build/node_modules/events/tests/once.js
generated
vendored
Normal file
@@ -0,0 +1,59 @@
|
||||
// Copyright Joyent, Inc. and other Node contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to permit
|
||||
// persons to whom the Software is furnished to do so, subject to the
|
||||
// following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
||||
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||||
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
||||
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
var assert = require('assert');
|
||||
var events = require('../');
|
||||
|
||||
var e = new events.EventEmitter();
|
||||
var times_hello_emited = 0;
|
||||
|
||||
e.once('hello', function(a, b) {
|
||||
times_hello_emited++;
|
||||
});
|
||||
|
||||
e.emit('hello', 'a', 'b');
|
||||
e.emit('hello', 'a', 'b');
|
||||
e.emit('hello', 'a', 'b');
|
||||
e.emit('hello', 'a', 'b');
|
||||
|
||||
var remove = function() {
|
||||
assert.fail(1, 0, 'once->foo should not be emitted', '!');
|
||||
};
|
||||
|
||||
e.once('foo', remove);
|
||||
e.removeListener('foo', remove);
|
||||
e.emit('foo');
|
||||
|
||||
var times_recurse_emitted = 0;
|
||||
|
||||
e.once('e', function() {
|
||||
e.emit('e');
|
||||
times_recurse_emitted++;
|
||||
});
|
||||
|
||||
e.once('e', function() {
|
||||
times_recurse_emitted++;
|
||||
});
|
||||
|
||||
e.emit('e');
|
||||
|
||||
assert.equal(1, times_hello_emited);
|
||||
assert.equal(2, times_recurse_emitted);
|
||||
80
build/node_modules/events/tests/remove-all-listeners.js
generated
vendored
Normal file
80
build/node_modules/events/tests/remove-all-listeners.js
generated
vendored
Normal file
@@ -0,0 +1,80 @@
|
||||
// Copyright Joyent, Inc. and other Node contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to permit
|
||||
// persons to whom the Software is furnished to do so, subject to the
|
||||
// following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
||||
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||||
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
||||
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
var common = require('./common');
|
||||
var assert = require('assert');
|
||||
var events = require('../');
|
||||
|
||||
var after_checks = [];
|
||||
after(function() {
|
||||
for (var i=0 ; i<after_checks.length ; ++i) {
|
||||
after_checks[i]();
|
||||
}
|
||||
});
|
||||
|
||||
function expect(expected) {
|
||||
var actual = [];
|
||||
after_checks.push(function() {
|
||||
assert.deepEqual(actual.sort(), expected.sort());
|
||||
});
|
||||
|
||||
function listener(name) {
|
||||
actual.push(name)
|
||||
}
|
||||
return common.mustCall(listener, expected.length);
|
||||
}
|
||||
|
||||
function listener() {}
|
||||
|
||||
var e1 = new events.EventEmitter();
|
||||
e1.on('foo', listener);
|
||||
e1.on('bar', listener);
|
||||
e1.on('baz', listener);
|
||||
e1.on('baz', listener);
|
||||
var fooListeners = e1.listeners('foo');
|
||||
var barListeners = e1.listeners('bar');
|
||||
var bazListeners = e1.listeners('baz');
|
||||
e1.on('removeListener', expect(['bar', 'baz', 'baz']));
|
||||
e1.removeAllListeners('bar');
|
||||
e1.removeAllListeners('baz');
|
||||
assert.deepEqual(e1.listeners('foo'), [listener]);
|
||||
assert.deepEqual(e1.listeners('bar'), []);
|
||||
assert.deepEqual(e1.listeners('baz'), []);
|
||||
// after calling removeAllListeners,
|
||||
// the old listeners array should stay unchanged
|
||||
assert.deepEqual(fooListeners, [listener]);
|
||||
assert.deepEqual(barListeners, [listener]);
|
||||
assert.deepEqual(bazListeners, [listener, listener]);
|
||||
// after calling removeAllListeners,
|
||||
// new listeners arrays are different from the old
|
||||
assert.notEqual(e1.listeners('bar'), barListeners);
|
||||
assert.notEqual(e1.listeners('baz'), bazListeners);
|
||||
|
||||
var e2 = new events.EventEmitter();
|
||||
e2.on('foo', listener);
|
||||
e2.on('bar', listener);
|
||||
// expect LIFO order
|
||||
e2.on('removeListener', expect(['foo', 'bar', 'removeListener']));
|
||||
e2.on('removeListener', expect(['foo', 'bar']));
|
||||
e2.removeAllListeners();
|
||||
console.error(e2);
|
||||
assert.deepEqual([], e2.listeners('foo'));
|
||||
assert.deepEqual([], e2.listeners('bar'));
|
||||
84
build/node_modules/events/tests/remove-listeners.js
generated
vendored
Normal file
84
build/node_modules/events/tests/remove-listeners.js
generated
vendored
Normal file
@@ -0,0 +1,84 @@
|
||||
// Copyright Joyent, Inc. and other Node contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to permit
|
||||
// persons to whom the Software is furnished to do so, subject to the
|
||||
// following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
||||
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||||
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
||||
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
var common = require('./common');
|
||||
var assert = require('assert');
|
||||
var events = require('../');
|
||||
|
||||
var count = 0;
|
||||
|
||||
function listener1() {
|
||||
console.log('listener1');
|
||||
count++;
|
||||
}
|
||||
|
||||
function listener2() {
|
||||
console.log('listener2');
|
||||
count++;
|
||||
}
|
||||
|
||||
function listener3() {
|
||||
console.log('listener3');
|
||||
count++;
|
||||
}
|
||||
|
||||
function remove1() {
|
||||
assert(0);
|
||||
}
|
||||
|
||||
function remove2() {
|
||||
assert(0);
|
||||
}
|
||||
|
||||
var e1 = new events.EventEmitter();
|
||||
e1.on('hello', listener1);
|
||||
e1.on('removeListener', common.mustCall(function(name, cb) {
|
||||
assert.equal(name, 'hello');
|
||||
assert.equal(cb, listener1);
|
||||
}));
|
||||
e1.removeListener('hello', listener1);
|
||||
assert.deepEqual([], e1.listeners('hello'));
|
||||
|
||||
var e2 = new events.EventEmitter();
|
||||
e2.on('hello', listener1);
|
||||
e2.on('removeListener', assert.fail);
|
||||
e2.removeListener('hello', listener2);
|
||||
assert.deepEqual([listener1], e2.listeners('hello'));
|
||||
|
||||
var e3 = new events.EventEmitter();
|
||||
e3.on('hello', listener1);
|
||||
e3.on('hello', listener2);
|
||||
e3.on('removeListener', common.mustCall(function(name, cb) {
|
||||
assert.equal(name, 'hello');
|
||||
assert.equal(cb, listener1);
|
||||
}));
|
||||
e3.removeListener('hello', listener1);
|
||||
assert.deepEqual([listener2], e3.listeners('hello'));
|
||||
|
||||
var e4 = new events.EventEmitter();
|
||||
e4.on('removeListener', common.mustCall(function(name, cb) {
|
||||
if (cb !== remove1) return;
|
||||
this.removeListener('quux', remove2);
|
||||
this.emit('quux');
|
||||
}, 2));
|
||||
e4.on('quux', remove1);
|
||||
e4.on('quux', remove2);
|
||||
e4.removeListener('quux', remove1);
|
||||
29
build/node_modules/events/tests/set-max-listeners-side-effects.js
generated
vendored
Normal file
29
build/node_modules/events/tests/set-max-listeners-side-effects.js
generated
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
// Copyright Joyent, Inc. and other Node contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to permit
|
||||
// persons to whom the Software is furnished to do so, subject to the
|
||||
// following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
||||
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||||
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
||||
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
var assert = require('assert');
|
||||
var events = require('../');
|
||||
|
||||
var e = new events.EventEmitter;
|
||||
|
||||
assert.deepEqual(e._events, {});
|
||||
e.setMaxListeners(5);
|
||||
assert.deepEqual(e._events, {});
|
||||
51
build/node_modules/events/tests/subclass.js
generated
vendored
Normal file
51
build/node_modules/events/tests/subclass.js
generated
vendored
Normal file
@@ -0,0 +1,51 @@
|
||||
// Copyright Joyent, Inc. and other Node contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to permit
|
||||
// persons to whom the Software is furnished to do so, subject to the
|
||||
// following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
||||
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||||
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
||||
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
var assert = require('assert');
|
||||
var EventEmitter = require('../').EventEmitter;
|
||||
var util = require('util');
|
||||
|
||||
util.inherits(MyEE, EventEmitter);
|
||||
|
||||
function MyEE(cb) {
|
||||
this.once(1, cb);
|
||||
this.emit(1);
|
||||
this.removeAllListeners();
|
||||
EventEmitter.call(this);
|
||||
}
|
||||
|
||||
var called = false;
|
||||
var myee = new MyEE(function() {
|
||||
called = true;
|
||||
});
|
||||
|
||||
|
||||
util.inherits(ErrorEE, EventEmitter);
|
||||
function ErrorEE() {
|
||||
this.emit('error', new Error('blerg'));
|
||||
}
|
||||
|
||||
assert.throws(function() {
|
||||
new ErrorEE();
|
||||
}, /blerg/);
|
||||
|
||||
assert(called);
|
||||
assert.deepEqual(myee._events, {});
|
||||
Reference in New Issue
Block a user