mirror of
https://kevinblog.sytes.net/Code/Jibo-Revival-Group/RoboCommander.git
synced 2026-06-15 10:26:04 +00:00
Initial commit
This commit is contained in:
22
node_modules/ultron/LICENSE
generated
vendored
Normal file
22
node_modules/ultron/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2015 Unshift.io, Arnout Kazemier, the 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.
|
||||
|
||||
136
node_modules/ultron/index.js
generated
vendored
Normal file
136
node_modules/ultron/index.js
generated
vendored
Normal file
@@ -0,0 +1,136 @@
|
||||
'use strict';
|
||||
|
||||
var has = Object.prototype.hasOwnProperty;
|
||||
|
||||
/**
|
||||
* An auto incrementing id which we can use to create "unique" Ultron instances
|
||||
* so we can track the event emitters that are added through the Ultron
|
||||
* interface.
|
||||
*
|
||||
* @type {Number}
|
||||
* @private
|
||||
*/
|
||||
var id = 0;
|
||||
|
||||
/**
|
||||
* Ultron is high-intelligence robot. It gathers intelligence so it can start improving
|
||||
* upon his rudimentary design. It will learn from your EventEmitting patterns
|
||||
* and exterminate them.
|
||||
*
|
||||
* @constructor
|
||||
* @param {EventEmitter} ee EventEmitter instance we need to wrap.
|
||||
* @api public
|
||||
*/
|
||||
function Ultron(ee) {
|
||||
if (!(this instanceof Ultron)) return new Ultron(ee);
|
||||
|
||||
this.id = id++;
|
||||
this.ee = ee;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a new EventListener for the given event.
|
||||
*
|
||||
* @param {String} event Name of the event.
|
||||
* @param {Functon} fn Callback function.
|
||||
* @param {Mixed} context The context of the function.
|
||||
* @returns {Ultron}
|
||||
* @api public
|
||||
*/
|
||||
Ultron.prototype.on = function on(event, fn, context) {
|
||||
fn.__ultron = this.id;
|
||||
this.ee.on(event, fn, context);
|
||||
|
||||
return this;
|
||||
};
|
||||
/**
|
||||
* Add an EventListener that's only called once.
|
||||
*
|
||||
* @param {String} event Name of the event.
|
||||
* @param {Function} fn Callback function.
|
||||
* @param {Mixed} context The context of the function.
|
||||
* @returns {Ultron}
|
||||
* @api public
|
||||
*/
|
||||
Ultron.prototype.once = function once(event, fn, context) {
|
||||
fn.__ultron = this.id;
|
||||
this.ee.once(event, fn, context);
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
/**
|
||||
* Remove the listeners we assigned for the given event.
|
||||
*
|
||||
* @returns {Ultron}
|
||||
* @api public
|
||||
*/
|
||||
Ultron.prototype.remove = function remove() {
|
||||
var args = arguments
|
||||
, ee = this.ee
|
||||
, event;
|
||||
|
||||
//
|
||||
// When no event names are provided we assume that we need to clear all the
|
||||
// events that were assigned through us.
|
||||
//
|
||||
if (args.length === 1 && 'string' === typeof args[0]) {
|
||||
args = args[0].split(/[, ]+/);
|
||||
} else if (!args.length) {
|
||||
if (ee.eventNames) {
|
||||
args = ee.eventNames();
|
||||
} else if (ee._events) {
|
||||
args = [];
|
||||
|
||||
for (event in ee._events) {
|
||||
if (has.call(ee._events, event)) args.push(event);
|
||||
}
|
||||
|
||||
if (Object.getOwnPropertySymbols) {
|
||||
args = args.concat(Object.getOwnPropertySymbols(ee._events));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (var i = 0; i < args.length; i++) {
|
||||
var listeners = ee.listeners(args[i]);
|
||||
|
||||
for (var j = 0; j < listeners.length; j++) {
|
||||
event = listeners[j];
|
||||
|
||||
//
|
||||
// Once listeners have a `listener` property that stores the real listener
|
||||
// in the EventEmitter that ships with Node.js.
|
||||
//
|
||||
if (event.listener) {
|
||||
if (event.listener.__ultron !== this.id) continue;
|
||||
} else if (event.__ultron !== this.id) {
|
||||
continue;
|
||||
}
|
||||
|
||||
ee.removeListener(args[i], event);
|
||||
}
|
||||
}
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
/**
|
||||
* Destroy the Ultron instance, remove all listeners and release all references.
|
||||
*
|
||||
* @returns {Boolean}
|
||||
* @api public
|
||||
*/
|
||||
Ultron.prototype.destroy = function destroy() {
|
||||
if (!this.ee) return false;
|
||||
|
||||
this.remove();
|
||||
this.ee = null;
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
//
|
||||
// Expose the module.
|
||||
//
|
||||
module.exports = Ultron;
|
||||
20
node_modules/ultron/package.json
generated
vendored
Normal file
20
node_modules/ultron/package.json
generated
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"name": "ultron",
|
||||
"version": "1.1.1",
|
||||
"description": "Ultron is high-intelligence robot. It gathers intel so it can start improving upon his rudimentary design",
|
||||
"main": "index.js",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/unshiftio/ultron"
|
||||
},
|
||||
"author": "Arnout Kazemier",
|
||||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
"assume": "~1.5.0",
|
||||
"eventemitter3": "2.0.x",
|
||||
"istanbul": "0.4.x",
|
||||
"mocha": "~4.0.0",
|
||||
"pre-commit": "~1.2.0"
|
||||
},
|
||||
"homepage": "https://github.com/unshiftio/ultron"
|
||||
}
|
||||
Reference in New Issue
Block a user