feat: 초기 프로젝트 설정 및 룰.md 파일 추가

This commit is contained in:
2025-07-28 09:53:31 +09:00
commit 09a4d38512
8165 changed files with 1021855 additions and 0 deletions

55
api.hyungi.net/node_modules/eventemitter2/CHANGELOG.md generated vendored Normal file
View File

@@ -0,0 +1,55 @@
# Change Log
All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).
For changes before version 2.2.0, please see the commit history
## [5.0.1] - 2018-01-09
### Fixed
- Allow `removeAllListeners` to recieve `undefined` as an argument. @majames
## [4.1.2] - 2017-07-12
### Added
- Correct listeners and listenersAny typings @cartant
## [4.1.1] - 2017-03-29
### Added
- Use process.emitWarning if it is available (new Node.js) @SimenB
## [4.0.0] - 2017-03-22
### Fixed
- Fix for EventAndListener in typescript definition. @thisboyiscrazy
### Added
- New Node 6 APIs such as `prependListener` and `eventNames`. @sebakerckhof
## [3.0.2] - 2017-03-06
### Fixed
- Fixed `emitAsync` when using `once`. @Moeriki
## [3.0.1] - 2017-02-21
### Changed
- Changed Typescript definition to take array of strings for event name. @thisboyiscrazy
## [3.0.0] - 2017-01-23
### Changed
- Typescript definition now uses `EventEmitter2` instead of `EventEmitter2.eitter`. @gitawego
## [2.2.2] - 2017-01-17
### Fixed
- Typescript definition for `removeAllListeners` can take an array. @gitawego
## [2.2.1] - 2016-11-24
### Added
- Added missing parameters for emitAsync in typescript definition. @stanleytakamatsu
## [2.2.0] - 2016-11-14
### Added
- option to emit name of event that causes memory leak warning. @kwiateusz
### Fixed
- component.json and bower.json got updated with latest version. @kwiateusz
- missing globals in test suite got added in. @kwiateusz

21
api.hyungi.net/node_modules/eventemitter2/LICENSE.txt generated vendored Normal file
View File

@@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2016 Paolo Fragomeni <http://www.github.com/0x00a> and 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.

348
api.hyungi.net/node_modules/eventemitter2/README.md generated vendored Normal file
View File

@@ -0,0 +1,348 @@
[![Codeship](https://img.shields.io/codeship/3ad58940-4c7d-0131-15d5-5a8cd3f550f8.svg?maxAge=2592000)]()
[![NPM version](https://badge.fury.io/js/eventemitter2.svg)](http://badge.fury.io/js/eventemitter2)
[![Dependency Status](https://img.shields.io/david/asyncly/eventemitter2.svg)](https://david-dm.org/asyncly/eventemitter2)
[![npm](https://img.shields.io/npm/dm/eventemitter2.svg?maxAge=2592000)]()
# SYNOPSIS
EventEmitter2 is an implementation of the EventEmitter module found in Node.js. In addition to having a better benchmark performance than EventEmitter and being browser-compatible, it also extends the interface of EventEmitter with additional non-breaking features.
# DESCRIPTION
### FEATURES
- Namespaces/Wildcards.
- Times To Listen (TTL), extends the `once` concept with `many`.
- Browser environment compatibility.
- Demonstrates good performance in benchmarks
```
EventEmitterHeatUp x 3,728,965 ops/sec \302\2610.68% (60 runs sampled)
EventEmitter x 2,822,904 ops/sec \302\2610.74% (63 runs sampled)
EventEmitter2 x 7,251,227 ops/sec \302\2610.55% (58 runs sampled)
EventEmitter2 (wild) x 3,220,268 ops/sec \302\2610.44% (65 runs sampled)
Fastest is EventEmitter2
```
### Differences (Non-breaking, compatible with existing EventEmitter)
- The EventEmitter2 constructor takes an optional configuration object.
```javascript
var EventEmitter2 = require('eventemitter2').EventEmitter2;
var server = new EventEmitter2({
//
// set this to `true` to use wildcards. It defaults to `false`.
//
wildcard: true,
//
// the delimiter used to segment namespaces, defaults to `.`.
//
delimiter: '::',
//
// set this to `true` if you want to emit the newListener event. The default value is `true`.
//
newListener: false,
//
// the maximum amount of listeners that can be assigned to an event, default 10.
//
maxListeners: 20,
//
// show event name in memory leak message when more than maximum amount of listeners is assigned, default false
//
verboseMemoryLeak: false
});
```
- Getting the actual event that fired.
```javascript
server.on('foo.*', function(value1, value2) {
console.log(this.event, value1, value2);
});
```
- Fire an event N times and then remove it, an extension of the `once` concept.
```javascript
server.many('foo', 4, function() {
console.log('hello');
});
```
- Pass in a namespaced event as an array rather than a delimited string.
```javascript
server.many(['foo', 'bar', 'bazz'], 4, function() {
console.log('hello');
});
```
# Installing
```console
$ npm install --save eventemitter2
```
# API
When an `EventEmitter` instance experiences an error, the typical action is
to emit an `error` event. Error events are treated as a special case.
If there is no listener for it, then the default action is to print a stack
trace and exit the program.
All EventEmitters emit the event `newListener` when new listeners are
added. EventEmitters also emit the event `removeListener` when listeners are
removed, and `removeListenerAny` when listeners added through `onAny` are
removed.
**Namespaces** with **Wildcards**
To use namespaces/wildcards, pass the `wildcard` option into the EventEmitter
constructor. When namespaces/wildcards are enabled, events can either be
strings (`foo.bar`) separated by a delimiter or arrays (`['foo', 'bar']`). The
delimiter is also configurable as a constructor option.
An event name passed to any event emitter method can contain a wild card (the
`*` character). If the event name is a string, a wildcard may appear as `foo.*`.
If the event name is an array, the wildcard may appear as `['foo', '*']`.
If either of the above described events were passed to the `on` method,
subsequent emits such as the following would be observed...
```javascript
emitter.emit('foo.bazz');
emitter.emit(['foo', 'bar']);
```
**NOTE:** An event name may use more than one wildcard. For example,
`foo.*.bar.*` is a valid event name, and would match events such as
`foo.x.bar.y`, or `['foo', 'bazz', 'bar', 'test']`
# Multi-level Wildcards
A double wildcard (the string `**`) matches any number of levels (zero or more) of events. So if for example `'foo.**'` is passed to the `on` method, the following events would be observed:
````javascript
emitter.emit('foo');
emitter.emit('foo.bar');
emitter.emit('foo.bar.baz');
````
On the other hand, if the single-wildcard event name was passed to the on method, the callback would only observe the second of these events.
### emitter.addListener(event, listener)
### emitter.on(event, listener)
Adds a listener to the end of the listeners array for the specified event.
```javascript
server.on('data', function(value1, value2, value3, ...) {
console.log('The event was raised!');
});
```
```javascript
server.on('data', function(value) {
console.log('The event was raised!');
});
```
### emitter.prependListener(event, listener)
Adds a listener to the beginning of the listeners array for the specified event.
```javascript
server.prependListener('data', function(value1, value2, value3, ...) {
console.log('The event was raised!');
});
```
### emitter.onAny(listener)
Adds a listener that will be fired when any event is emitted. The event name is passed as the first argument to the callback.
```javascript
server.onAny(function(event, value) {
console.log('All events trigger this.');
});
```
### emitter.prependAny(listener)
Adds a listener that will be fired when any event is emitted. The event name is passed as the first argument to the callback. The listener is added to the beginning of the listeners array
```javascript
server.prependAny(function(event, value) {
console.log('All events trigger this.');
});
```
### emitter.offAny(listener)
Removes the listener that will be fired when any event is emitted.
```javascript
server.offAny(function(value) {
console.log('The event was raised!');
});
```
#### emitter.once(event, listener)
Adds a **one time** listener for the event. The listener is invoked
only the first time the event is fired, after which it is removed.
```javascript
server.once('get', function (value) {
console.log('Ah, we have our first value!');
});
```
#### emitter.prependOnceListener(event, listener)
Adds a **one time** listener for the event. The listener is invoked
only the first time the event is fired, after which it is removed.
The listener is added to the beginning of the listeners array
```javascript
server.prependOnceListener('get', function (value) {
console.log('Ah, we have our first value!');
});
```
### emitter.many(event, timesToListen, listener)
Adds a listener that will execute **n times** for the event before being
removed. The listener is invoked only the first **n times** the event is
fired, after which it is removed.
```javascript
server.many('get', 4, function (value) {
console.log('This event will be listened to exactly four times.');
});
```
### emitter.prependMany(event, timesToListen, listener)
Adds a listener that will execute **n times** for the event before being
removed. The listener is invoked only the first **n times** the event is
fired, after which it is removed.
The listener is added to the beginning of the listeners array.
```javascript
server.many('get', 4, function (value) {
console.log('This event will be listened to exactly four times.');
});
```
### emitter.removeListener(event, listener)
### emitter.off(event, listener)
Remove a listener from the listener array for the specified event.
**Caution**: Calling this method changes the array indices in the listener array behind the listener.
```javascript
var callback = function(value) {
console.log('someone connected!');
};
server.on('get', callback);
// ...
server.removeListener('get', callback);
```
### emitter.removeAllListeners([event])
Removes all listeners, or those of the specified event.
### emitter.setMaxListeners(n)
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.
Obviously not all Emitters should be limited to 10. This function allows
that to be increased. Set to zero for unlimited.
### emitter.listeners(event)
Returns an array of listeners for the specified event. This array can be
manipulated, e.g. to remove listeners.
```javascript
server.on('get', function(value) {
console.log('someone connected!');
});
console.log(server.listeners('get')); // [ [Function] ]
```
### emitter.listenersAny()
Returns an array of listeners that are listening for any event that is
specified. This array can be manipulated, e.g. to remove listeners.
```javascript
server.onAny(function(value) {
console.log('someone connected!');
});
console.log(server.listenersAny()[0]); // [ [Function] ]
```
### emitter.emit(event, [arg1], [arg2], [...])
Execute each of the listeners that may be listening for the specified event
name in order with the list of arguments.
### emitter.emitAsync(event, [arg1], [arg2], [...])
Return the results of the listeners via [Promise.all](https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Global_Objects/Promise/all).
Only this method doesn't work [IE](http://caniuse.com/#search=promise).
```javascript
emitter.on('get',function(i) {
return new Promise(function(resolve){
setTimeout(function(){
resolve(i+3);
},50);
});
});
emitter.on('get',function(i) {
return new Promise(function(resolve){
resolve(i+2)
});
});
emitter.on('get',function(i) {
return Promise.resolve(i+1);
});
emitter.on('get',function(i) {
return i+0;
});
emitter.on('get',function(i) {
// noop
});
emitter.emitAsync('get',0)
.then(function(results){
console.log(results); // [3,2,1,0,undefined]
});
```
### emitter.eventNames()
Returns an array listing the events for which the emitter has registered listeners. The values in the array will be strings.
```javascript
emitter.on('foo', () => {});
emitter.on('bar', () => {});
console.log(emitter.eventNames());
// Prints: [ 'foo', 'bar' ]
```

View File

@@ -0,0 +1,57 @@
export type eventNS = string[];
export interface ConstructorOptions {
/**
* @default false
* @description set this to `true` to use wildcards.
*/
wildcard?: boolean,
/**
* @default '.'
* @description the delimiter used to segment namespaces.
*/
delimiter?: string,
/**
* @default true
* @description set this to `true` if you want to emit the newListener events.
*/
newListener?: boolean,
/**
* @default 10
* @description the maximum amount of listeners that can be assigned to an event.
*/
maxListeners?: number
/**
* @default false
* @description show event name in memory leak message when more than maximum amount of listeners is assigned, default false
*/
verboseMemoryLeak?: boolean;
}
export interface Listener {
(...values: any[]): void;
}
export interface EventAndListener {
(event: string | string[], ...values: any[]): void;
}
export declare class EventEmitter2 {
constructor(options?: ConstructorOptions)
emit(event: string | string[], ...values: any[]): boolean;
emitAsync(event: string | string[], ...values: any[]): Promise<any[]>;
addListener(event: string, listener: Listener): this;
on(event: string | string[], listener: Listener): this;
prependListener(event: string | string[], listener: Listener): this;
once(event: string | string[], listener: Listener): this;
prependOnceListener(event: string | string[], listener: Listener): this;
many(event: string | string[], timesToListen: number, listener: Listener): this;
prependMany(event: string | string[], timesToListen: number, listener: Listener): this;
onAny(listener: EventAndListener): this;
prependAny(listener: EventAndListener): this;
offAny(listener: Listener): this;
removeListener(event: string | string[], listener: Listener): this;
off(event: string, listener: Listener): this;
removeAllListeners(event?: string | eventNS): this;
setMaxListeners(n: number): void;
eventNames(): string[];
listeners(event: string | string[]): Listener[] // TODO: not in documentation by Willian
listenersAny(): Listener[] // TODO: not in documentation by Willian
}

1
api.hyungi.net/node_modules/eventemitter2/index.js generated vendored Normal file
View File

@@ -0,0 +1 @@
module.exports = require('./lib/eventemitter2');

View File

@@ -0,0 +1,782 @@
/*!
* EventEmitter2
* https://github.com/hij1nx/EventEmitter2
*
* Copyright (c) 2013 hij1nx
* Licensed under the MIT license.
*/
;!function(undefined) {
var isArray = Array.isArray ? Array.isArray : function _isArray(obj) {
return Object.prototype.toString.call(obj) === "[object Array]";
};
var defaultMaxListeners = 10;
function init() {
this._events = {};
if (this._conf) {
configure.call(this, this._conf);
}
}
function configure(conf) {
if (conf) {
this._conf = conf;
conf.delimiter && (this.delimiter = conf.delimiter);
this._maxListeners = conf.maxListeners !== undefined ? conf.maxListeners : defaultMaxListeners;
conf.wildcard && (this.wildcard = conf.wildcard);
conf.newListener && (this._newListener = conf.newListener);
conf.removeListener && (this._removeListener = conf.removeListener);
conf.verboseMemoryLeak && (this.verboseMemoryLeak = conf.verboseMemoryLeak);
if (this.wildcard) {
this.listenerTree = {};
}
} else {
this._maxListeners = defaultMaxListeners;
}
}
function logPossibleMemoryLeak(count, eventName) {
var errorMsg = '(node) warning: possible EventEmitter memory ' +
'leak detected. ' + count + ' listeners added. ' +
'Use emitter.setMaxListeners() to increase limit.';
if(this.verboseMemoryLeak){
errorMsg += ' Event name: ' + eventName + '.';
}
if(typeof process !== 'undefined' && process.emitWarning){
var e = new Error(errorMsg);
e.name = 'MaxListenersExceededWarning';
e.emitter = this;
e.count = count;
process.emitWarning(e);
} else {
console.error(errorMsg);
if (console.trace){
console.trace();
}
}
}
function EventEmitter(conf) {
this._events = {};
this._newListener = false;
this._removeListener = false;
this.verboseMemoryLeak = false;
configure.call(this, conf);
}
EventEmitter.EventEmitter2 = EventEmitter; // backwards compatibility for exporting EventEmitter property
//
// Attention, function return type now is array, always !
// It has zero elements if no any matches found and one or more
// elements (leafs) if there are matches
//
function searchListenerTree(handlers, type, tree, i) {
if (!tree) {
return [];
}
var listeners=[], leaf, len, branch, xTree, xxTree, isolatedBranch, endReached,
typeLength = type.length, currentType = type[i], nextType = type[i+1];
if (i === typeLength && tree._listeners) {
//
// If at the end of the event(s) list and the tree has listeners
// invoke those listeners.
//
if (typeof tree._listeners === 'function') {
handlers && handlers.push(tree._listeners);
return [tree];
} else {
for (leaf = 0, len = tree._listeners.length; leaf < len; leaf++) {
handlers && handlers.push(tree._listeners[leaf]);
}
return [tree];
}
}
if ((currentType === '*' || currentType === '**') || tree[currentType]) {
//
// If the event emitted is '*' at this part
// or there is a concrete match at this patch
//
if (currentType === '*') {
for (branch in tree) {
if (branch !== '_listeners' && tree.hasOwnProperty(branch)) {
listeners = listeners.concat(searchListenerTree(handlers, type, tree[branch], i+1));
}
}
return listeners;
} else if(currentType === '**') {
endReached = (i+1 === typeLength || (i+2 === typeLength && nextType === '*'));
if(endReached && tree._listeners) {
// The next element has a _listeners, add it to the handlers.
listeners = listeners.concat(searchListenerTree(handlers, type, tree, typeLength));
}
for (branch in tree) {
if (branch !== '_listeners' && tree.hasOwnProperty(branch)) {
if(branch === '*' || branch === '**') {
if(tree[branch]._listeners && !endReached) {
listeners = listeners.concat(searchListenerTree(handlers, type, tree[branch], typeLength));
}
listeners = listeners.concat(searchListenerTree(handlers, type, tree[branch], i));
} else if(branch === nextType) {
listeners = listeners.concat(searchListenerTree(handlers, type, tree[branch], i+2));
} else {
// No match on this one, shift into the tree but not in the type array.
listeners = listeners.concat(searchListenerTree(handlers, type, tree[branch], i));
}
}
}
return listeners;
}
listeners = listeners.concat(searchListenerTree(handlers, type, tree[currentType], i+1));
}
xTree = tree['*'];
if (xTree) {
//
// If the listener tree will allow any match for this part,
// then recursively explore all branches of the tree
//
searchListenerTree(handlers, type, xTree, i+1);
}
xxTree = tree['**'];
if(xxTree) {
if(i < typeLength) {
if(xxTree._listeners) {
// If we have a listener on a '**', it will catch all, so add its handler.
searchListenerTree(handlers, type, xxTree, typeLength);
}
// Build arrays of matching next branches and others.
for(branch in xxTree) {
if(branch !== '_listeners' && xxTree.hasOwnProperty(branch)) {
if(branch === nextType) {
// We know the next element will match, so jump twice.
searchListenerTree(handlers, type, xxTree[branch], i+2);
} else if(branch === currentType) {
// Current node matches, move into the tree.
searchListenerTree(handlers, type, xxTree[branch], i+1);
} else {
isolatedBranch = {};
isolatedBranch[branch] = xxTree[branch];
searchListenerTree(handlers, type, { '**': isolatedBranch }, i+1);
}
}
}
} else if(xxTree._listeners) {
// We have reached the end and still on a '**'
searchListenerTree(handlers, type, xxTree, typeLength);
} else if(xxTree['*'] && xxTree['*']._listeners) {
searchListenerTree(handlers, type, xxTree['*'], typeLength);
}
}
return listeners;
}
function growListenerTree(type, listener) {
type = typeof type === 'string' ? type.split(this.delimiter) : type.slice();
//
// Looks for two consecutive '**', if so, don't add the event at all.
//
for(var i = 0, len = type.length; i+1 < len; i++) {
if(type[i] === '**' && type[i+1] === '**') {
return;
}
}
var tree = this.listenerTree;
var name = type.shift();
while (name !== undefined) {
if (!tree[name]) {
tree[name] = {};
}
tree = tree[name];
if (type.length === 0) {
if (!tree._listeners) {
tree._listeners = listener;
}
else {
if (typeof tree._listeners === 'function') {
tree._listeners = [tree._listeners];
}
tree._listeners.push(listener);
if (
!tree._listeners.warned &&
this._maxListeners > 0 &&
tree._listeners.length > this._maxListeners
) {
tree._listeners.warned = true;
logPossibleMemoryLeak.call(this, tree._listeners.length, name);
}
}
return true;
}
name = type.shift();
}
return true;
}
// 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.
//
// Obviously not all Emitters should be limited to 10. This function allows
// that to be increased. Set to zero for unlimited.
EventEmitter.prototype.delimiter = '.';
EventEmitter.prototype.setMaxListeners = function(n) {
if (n !== undefined) {
this._maxListeners = n;
if (!this._conf) this._conf = {};
this._conf.maxListeners = n;
}
};
EventEmitter.prototype.event = '';
EventEmitter.prototype.once = function(event, fn) {
return this._once(event, fn, false);
};
EventEmitter.prototype.prependOnceListener = function(event, fn) {
return this._once(event, fn, true);
};
EventEmitter.prototype._once = function(event, fn, prepend) {
this._many(event, 1, fn, prepend);
return this;
};
EventEmitter.prototype.many = function(event, ttl, fn) {
return this._many(event, ttl, fn, false);
}
EventEmitter.prototype.prependMany = function(event, ttl, fn) {
return this._many(event, ttl, fn, true);
}
EventEmitter.prototype._many = function(event, ttl, fn, prepend) {
var self = this;
if (typeof fn !== 'function') {
throw new Error('many only accepts instances of Function');
}
function listener() {
if (--ttl === 0) {
self.off(event, listener);
}
return fn.apply(this, arguments);
}
listener._origin = fn;
this._on(event, listener, prepend);
return self;
};
EventEmitter.prototype.emit = function() {
this._events || init.call(this);
var type = arguments[0];
if (type === 'newListener' && !this._newListener) {
if (!this._events.newListener) {
return false;
}
}
var al = arguments.length;
var args,l,i,j;
var handler;
if (this._all && this._all.length) {
handler = this._all.slice();
if (al > 3) {
args = new Array(al);
for (j = 0; j < al; j++) args[j] = arguments[j];
}
for (i = 0, l = handler.length; i < l; i++) {
this.event = type;
switch (al) {
case 1:
handler[i].call(this, type);
break;
case 2:
handler[i].call(this, type, arguments[1]);
break;
case 3:
handler[i].call(this, type, arguments[1], arguments[2]);
break;
default:
handler[i].apply(this, args);
}
}
}
if (this.wildcard) {
handler = [];
var ns = typeof type === 'string' ? type.split(this.delimiter) : type.slice();
searchListenerTree.call(this, handler, ns, this.listenerTree, 0);
} else {
handler = this._events[type];
if (typeof handler === 'function') {
this.event = type;
switch (al) {
case 1:
handler.call(this);
break;
case 2:
handler.call(this, arguments[1]);
break;
case 3:
handler.call(this, arguments[1], arguments[2]);
break;
default:
args = new Array(al - 1);
for (j = 1; j < al; j++) args[j - 1] = arguments[j];
handler.apply(this, args);
}
return true;
} else if (handler) {
// need to make copy of handlers because list can change in the middle
// of emit call
handler = handler.slice();
}
}
if (handler && handler.length) {
if (al > 3) {
args = new Array(al - 1);
for (j = 1; j < al; j++) args[j - 1] = arguments[j];
}
for (i = 0, l = handler.length; i < l; i++) {
this.event = type;
switch (al) {
case 1:
handler[i].call(this);
break;
case 2:
handler[i].call(this, arguments[1]);
break;
case 3:
handler[i].call(this, arguments[1], arguments[2]);
break;
default:
handler[i].apply(this, args);
}
}
return true;
} else if (!this._all && type === 'error') {
if (arguments[1] instanceof Error) {
throw arguments[1]; // Unhandled 'error' event
} else {
throw new Error("Uncaught, unspecified 'error' event.");
}
return false;
}
return !!this._all;
};
EventEmitter.prototype.emitAsync = function() {
this._events || init.call(this);
var type = arguments[0];
if (type === 'newListener' && !this._newListener) {
if (!this._events.newListener) { return Promise.resolve([false]); }
}
var promises= [];
var al = arguments.length;
var args,l,i,j;
var handler;
if (this._all) {
if (al > 3) {
args = new Array(al);
for (j = 1; j < al; j++) args[j] = arguments[j];
}
for (i = 0, l = this._all.length; i < l; i++) {
this.event = type;
switch (al) {
case 1:
promises.push(this._all[i].call(this, type));
break;
case 2:
promises.push(this._all[i].call(this, type, arguments[1]));
break;
case 3:
promises.push(this._all[i].call(this, type, arguments[1], arguments[2]));
break;
default:
promises.push(this._all[i].apply(this, args));
}
}
}
if (this.wildcard) {
handler = [];
var ns = typeof type === 'string' ? type.split(this.delimiter) : type.slice();
searchListenerTree.call(this, handler, ns, this.listenerTree, 0);
} else {
handler = this._events[type];
}
if (typeof handler === 'function') {
this.event = type;
switch (al) {
case 1:
promises.push(handler.call(this));
break;
case 2:
promises.push(handler.call(this, arguments[1]));
break;
case 3:
promises.push(handler.call(this, arguments[1], arguments[2]));
break;
default:
args = new Array(al - 1);
for (j = 1; j < al; j++) args[j - 1] = arguments[j];
promises.push(handler.apply(this, args));
}
} else if (handler && handler.length) {
handler = handler.slice();
if (al > 3) {
args = new Array(al - 1);
for (j = 1; j < al; j++) args[j - 1] = arguments[j];
}
for (i = 0, l = handler.length; i < l; i++) {
this.event = type;
switch (al) {
case 1:
promises.push(handler[i].call(this));
break;
case 2:
promises.push(handler[i].call(this, arguments[1]));
break;
case 3:
promises.push(handler[i].call(this, arguments[1], arguments[2]));
break;
default:
promises.push(handler[i].apply(this, args));
}
}
} else if (!this._all && type === 'error') {
if (arguments[1] instanceof Error) {
return Promise.reject(arguments[1]); // Unhandled 'error' event
} else {
return Promise.reject("Uncaught, unspecified 'error' event.");
}
}
return Promise.all(promises);
};
EventEmitter.prototype.on = function(type, listener) {
return this._on(type, listener, false);
};
EventEmitter.prototype.prependListener = function(type, listener) {
return this._on(type, listener, true);
};
EventEmitter.prototype.onAny = function(fn) {
return this._onAny(fn, false);
};
EventEmitter.prototype.prependAny = function(fn) {
return this._onAny(fn, true);
};
EventEmitter.prototype.addListener = EventEmitter.prototype.on;
EventEmitter.prototype._onAny = function(fn, prepend){
if (typeof fn !== 'function') {
throw new Error('onAny only accepts instances of Function');
}
if (!this._all) {
this._all = [];
}
// Add the function to the event listener collection.
if(prepend){
this._all.unshift(fn);
}else{
this._all.push(fn);
}
return this;
}
EventEmitter.prototype._on = function(type, listener, prepend) {
if (typeof type === 'function') {
this._onAny(type, listener);
return this;
}
if (typeof listener !== 'function') {
throw new Error('on only accepts instances of Function');
}
this._events || init.call(this);
// To avoid recursion in the case that type == "newListeners"! Before
// adding it to the listeners, first emit "newListeners".
if (this._newListener)
this.emit('newListener', type, listener);
if (this.wildcard) {
growListenerTree.call(this, type, listener);
return this;
}
if (!this._events[type]) {
// Optimize the case of one listener. Don't need the extra array object.
this._events[type] = listener;
}
else {
if (typeof this._events[type] === 'function') {
// Change to array.
this._events[type] = [this._events[type]];
}
// If we've already got an array, just add
if(prepend){
this._events[type].unshift(listener);
}else{
this._events[type].push(listener);
}
// Check for listener leak
if (
!this._events[type].warned &&
this._maxListeners > 0 &&
this._events[type].length > this._maxListeners
) {
this._events[type].warned = true;
logPossibleMemoryLeak.call(this, this._events[type].length, type);
}
}
return this;
}
EventEmitter.prototype.off = function(type, listener) {
if (typeof listener !== 'function') {
throw new Error('removeListener only takes instances of Function');
}
var handlers,leafs=[];
if(this.wildcard) {
var ns = typeof type === 'string' ? type.split(this.delimiter) : type.slice();
leafs = searchListenerTree.call(this, null, ns, this.listenerTree, 0);
}
else {
// does not use listeners(), so no side effect of creating _events[type]
if (!this._events[type]) return this;
handlers = this._events[type];
leafs.push({_listeners:handlers});
}
for (var iLeaf=0; iLeaf<leafs.length; iLeaf++) {
var leaf = leafs[iLeaf];
handlers = leaf._listeners;
if (isArray(handlers)) {
var position = -1;
for (var i = 0, length = handlers.length; i < length; i++) {
if (handlers[i] === listener ||
(handlers[i].listener && handlers[i].listener === listener) ||
(handlers[i]._origin && handlers[i]._origin === listener)) {
position = i;
break;
}
}
if (position < 0) {
continue;
}
if(this.wildcard) {
leaf._listeners.splice(position, 1);
}
else {
this._events[type].splice(position, 1);
}
if (handlers.length === 0) {
if(this.wildcard) {
delete leaf._listeners;
}
else {
delete this._events[type];
}
}
if (this._removeListener)
this.emit("removeListener", type, listener);
return this;
}
else if (handlers === listener ||
(handlers.listener && handlers.listener === listener) ||
(handlers._origin && handlers._origin === listener)) {
if(this.wildcard) {
delete leaf._listeners;
}
else {
delete this._events[type];
}
if (this._removeListener)
this.emit("removeListener", type, listener);
}
}
function recursivelyGarbageCollect(root) {
if (root === undefined) {
return;
}
var keys = Object.keys(root);
for (var i in keys) {
var key = keys[i];
var obj = root[key];
if ((obj instanceof Function) || (typeof obj !== "object") || (obj === null))
continue;
if (Object.keys(obj).length > 0) {
recursivelyGarbageCollect(root[key]);
}
if (Object.keys(obj).length === 0) {
delete root[key];
}
}
}
recursivelyGarbageCollect(this.listenerTree);
return this;
};
EventEmitter.prototype.offAny = function(fn) {
var i = 0, l = 0, fns;
if (fn && this._all && this._all.length > 0) {
fns = this._all;
for(i = 0, l = fns.length; i < l; i++) {
if(fn === fns[i]) {
fns.splice(i, 1);
if (this._removeListener)
this.emit("removeListenerAny", fn);
return this;
}
}
} else {
fns = this._all;
if (this._removeListener) {
for(i = 0, l = fns.length; i < l; i++)
this.emit("removeListenerAny", fns[i]);
}
this._all = [];
}
return this;
};
EventEmitter.prototype.removeListener = EventEmitter.prototype.off;
EventEmitter.prototype.removeAllListeners = function(type) {
if (type === undefined) {
!this._events || init.call(this);
return this;
}
if (this.wildcard) {
var ns = typeof type === 'string' ? type.split(this.delimiter) : type.slice();
var leafs = searchListenerTree.call(this, null, ns, this.listenerTree, 0);
for (var iLeaf=0; iLeaf<leafs.length; iLeaf++) {
var leaf = leafs[iLeaf];
leaf._listeners = null;
}
}
else if (this._events) {
this._events[type] = null;
}
return this;
};
EventEmitter.prototype.listeners = function(type) {
if (this.wildcard) {
var handlers = [];
var ns = typeof type === 'string' ? type.split(this.delimiter) : type.slice();
searchListenerTree.call(this, handlers, ns, this.listenerTree, 0);
return handlers;
}
this._events || init.call(this);
if (!this._events[type]) this._events[type] = [];
if (!isArray(this._events[type])) {
this._events[type] = [this._events[type]];
}
return this._events[type];
};
EventEmitter.prototype.eventNames = function(){
return Object.keys(this._events);
}
EventEmitter.prototype.listenerCount = function(type) {
return this.listeners(type).length;
};
EventEmitter.prototype.listenersAny = function() {
if(this._all) {
return this._all;
}
else {
return [];
}
};
if (typeof define === 'function' && define.amd) {
// AMD. Register as an anonymous module.
define(function() {
return EventEmitter;
});
} else if (typeof exports === 'object') {
// CommonJS
module.exports = EventEmitter;
}
else {
// Browser global.
window.EventEmitter2 = EventEmitter;
}
}();

69
api.hyungi.net/node_modules/eventemitter2/package.json generated vendored Normal file
View File

@@ -0,0 +1,69 @@
{
"name": "eventemitter2",
"version": "5.0.1",
"description": "A Node.js event emitter implementation with namespaces, wildcards, TTL and browser support.",
"keywords": [
"event",
"events",
"emitter",
"eventemitter"
],
"author": "hij1nx <paolo@async.ly> http://twitter.com/hij1nx",
"contributors": [
"Eric Elliott",
"Charlie Robbins <charlie@nodejitsu.com> http://twitter.com/indexzero",
"Jameson Lee <jameson@nodejitsu.com> http://twitter.com/Jamesonjlee",
"Jeroen van Duffelen <jvduf@nodejitsu.com> http://www.twitter.com/jvduf",
"Fedor Indutny <fedor.indutny@gmail.com> http://www.twitter.com/indutny"
],
"license": "MIT",
"repository": "git://github.com/hij1nx/EventEmitter2.git",
"devDependencies": {
"benchmark": ">= 0.2.2",
"nodeunit": "*",
"nyc": "^11.4.1"
},
"main": "./lib/eventemitter2.js",
"scripts": {
"test": "nodeunit test/simple/ test/wildcardEvents/",
"coverage": "nyc --check-coverage npm run test",
"benchmark": "node --reporter test/perf/benchmark.js"
},
"files": [
"lib/eventemitter2.js",
"index.js",
"eventemitter2.d.ts"
],
"typings": "./eventemitter2.d.ts",
"typescript": {
"definition": "./eventemitter2.d.ts"
},
"nyc": {
"lines": 83,
"functions": 84,
"branches": 79,
"statements": 83,
"watermarks": {
"lines": [
80,
95
],
"functions": [
80,
95
],
"branches": [
80,
95
],
"statements": [
80,
95
]
},
"reporter": [
"lcov",
"text-summary"
]
}
}