mirror of
https://github.com/jsdoc/jsdoc.git
synced 2025-12-08 19:46:11 +00:00
Remove node_modules
This commit is contained in:
parent
ac7ce7c408
commit
f26322ae4a
19
node_modules/async/LICENSE
generated
vendored
19
node_modules/async/LICENSE
generated
vendored
@ -1,19 +0,0 @@
|
||||
Copyright (c) 2010-2014 Caolan McMahon
|
||||
|
||||
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.
|
||||
1216
node_modules/async/lib/async.js
generated
vendored
1216
node_modules/async/lib/async.js
generated
vendored
File diff suppressed because it is too large
Load Diff
105
node_modules/async/package.json
generated
vendored
105
node_modules/async/package.json
generated
vendored
@ -1,105 +0,0 @@
|
||||
{
|
||||
"name": "async",
|
||||
"description": "Higher-order functions and common patterns for asynchronous code",
|
||||
"main": "lib/async.js",
|
||||
"author": {
|
||||
"name": "Caolan McMahon"
|
||||
},
|
||||
"version": "1.4.0",
|
||||
"keywords": [
|
||||
"async",
|
||||
"callback",
|
||||
"utility",
|
||||
"module"
|
||||
],
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/caolan/async.git"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/caolan/async/issues"
|
||||
},
|
||||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
"benchmark": "github:bestiejs/benchmark.js",
|
||||
"bluebird": "^2.9.32",
|
||||
"coveralls": "^2.11.2",
|
||||
"es6-promise": "^2.3.0",
|
||||
"jscs": "^1.13.1",
|
||||
"jshint": "~2.8.0",
|
||||
"lodash": "^3.9.0",
|
||||
"mkdirp": "~0.5.1",
|
||||
"native-promise-only": "^0.8.0-a",
|
||||
"nodeunit": ">0.0.0",
|
||||
"nyc": "^2.1.0",
|
||||
"rsvp": "^3.0.18",
|
||||
"uglify-js": "~2.4.0",
|
||||
"xyz": "^0.5.0",
|
||||
"yargs": "~3.9.1"
|
||||
},
|
||||
"jam": {
|
||||
"main": "lib/async.js",
|
||||
"include": [
|
||||
"lib/async.js",
|
||||
"README.md",
|
||||
"LICENSE"
|
||||
],
|
||||
"categories": [
|
||||
"Utilities"
|
||||
]
|
||||
},
|
||||
"scripts": {
|
||||
"test": "npm run-script lint && nodeunit test/test-async.js",
|
||||
"lint": "jshint lib/*.js test/*.js perf/*.js && jscs lib/*.js test/*.js perf/*.js",
|
||||
"coverage": "nyc npm test && nyc report",
|
||||
"coveralls": "nyc npm test && nyc report --reporter=text-lcov | coveralls"
|
||||
},
|
||||
"spm": {
|
||||
"main": "lib/async.js"
|
||||
},
|
||||
"volo": {
|
||||
"main": "lib/async.js",
|
||||
"ignore": [
|
||||
"**/.*",
|
||||
"node_modules",
|
||||
"bower_components",
|
||||
"test",
|
||||
"tests"
|
||||
]
|
||||
},
|
||||
"gitHead": "5bfcd31c72e003f96df025e75753463da61f49f9",
|
||||
"homepage": "https://github.com/caolan/async#readme",
|
||||
"_id": "async@1.4.0",
|
||||
"_shasum": "35f86f83c59e0421d099cd9a91d8278fb578c00d",
|
||||
"_from": "async@1.4.0",
|
||||
"_npmVersion": "2.13.0",
|
||||
"_nodeVersion": "2.4.0",
|
||||
"_npmUser": {
|
||||
"name": "megawac",
|
||||
"email": "megawac@gmail.com"
|
||||
},
|
||||
"dist": {
|
||||
"shasum": "35f86f83c59e0421d099cd9a91d8278fb578c00d",
|
||||
"tarball": "http://registry.npmjs.org/async/-/async-1.4.0.tgz"
|
||||
},
|
||||
"maintainers": [
|
||||
{
|
||||
"name": "caolan",
|
||||
"email": "caolan.mcmahon@gmail.com"
|
||||
},
|
||||
{
|
||||
"name": "beaugunderson",
|
||||
"email": "beau@beaugunderson.com"
|
||||
},
|
||||
{
|
||||
"name": "aearly",
|
||||
"email": "alexander.early@gmail.com"
|
||||
},
|
||||
{
|
||||
"name": "megawac",
|
||||
"email": "megawac@gmail.com"
|
||||
}
|
||||
],
|
||||
"directories": {},
|
||||
"_resolved": "https://registry.npmjs.org/async/-/async-1.4.0.tgz"
|
||||
}
|
||||
21
node_modules/bluebird/LICENSE
generated
vendored
21
node_modules/bluebird/LICENSE
generated
vendored
@ -1,21 +0,0 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2014 Petka Antonov
|
||||
|
||||
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.
|
||||
21
node_modules/bluebird/js/main/any.js
generated
vendored
21
node_modules/bluebird/js/main/any.js
generated
vendored
@ -1,21 +0,0 @@
|
||||
"use strict";
|
||||
module.exports = function(Promise) {
|
||||
var SomePromiseArray = Promise._SomePromiseArray;
|
||||
function any(promises) {
|
||||
var ret = new SomePromiseArray(promises);
|
||||
var promise = ret.promise();
|
||||
ret.setHowMany(1);
|
||||
ret.setUnwrap();
|
||||
ret.init();
|
||||
return promise;
|
||||
}
|
||||
|
||||
Promise.any = function (promises) {
|
||||
return any(promises);
|
||||
};
|
||||
|
||||
Promise.prototype.any = function () {
|
||||
return any(this);
|
||||
};
|
||||
|
||||
};
|
||||
55
node_modules/bluebird/js/main/assert.js
generated
vendored
55
node_modules/bluebird/js/main/assert.js
generated
vendored
@ -1,55 +0,0 @@
|
||||
"use strict";
|
||||
module.exports = (function(){
|
||||
var AssertionError = (function() {
|
||||
function AssertionError(a) {
|
||||
this.constructor$(a);
|
||||
this.message = a;
|
||||
this.name = "AssertionError";
|
||||
}
|
||||
AssertionError.prototype = new Error();
|
||||
AssertionError.prototype.constructor = AssertionError;
|
||||
AssertionError.prototype.constructor$ = Error;
|
||||
return AssertionError;
|
||||
})();
|
||||
|
||||
function getParams(args) {
|
||||
var params = [];
|
||||
for (var i = 0; i < args.length; ++i) params.push("arg" + i);
|
||||
return params;
|
||||
}
|
||||
|
||||
function nativeAssert(callName, args, expect) {
|
||||
try {
|
||||
var params = getParams(args);
|
||||
var constructorArgs = params;
|
||||
constructorArgs.push("return " +
|
||||
callName + "("+ params.join(",") + ");");
|
||||
var fn = Function.apply(null, constructorArgs);
|
||||
return fn.apply(null, args);
|
||||
} catch (e) {
|
||||
if (!(e instanceof SyntaxError)) {
|
||||
throw e;
|
||||
} else {
|
||||
return expect;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return function assert(boolExpr, message) {
|
||||
if (boolExpr === true) return;
|
||||
|
||||
if (typeof boolExpr === "string" &&
|
||||
boolExpr.charAt(0) === "%") {
|
||||
var nativeCallName = boolExpr;
|
||||
var $_len = arguments.length;var args = new Array($_len - 2); for(var $_i = 2; $_i < $_len; ++$_i) {args[$_i - 2] = arguments[$_i];}
|
||||
if (nativeAssert(nativeCallName, args, message) === message) return;
|
||||
message = (nativeCallName + " !== " + message);
|
||||
}
|
||||
|
||||
var ret = new AssertionError(message);
|
||||
if (Error.captureStackTrace) {
|
||||
Error.captureStackTrace(ret, assert);
|
||||
}
|
||||
throw ret;
|
||||
};
|
||||
})();
|
||||
150
node_modules/bluebird/js/main/async.js
generated
vendored
150
node_modules/bluebird/js/main/async.js
generated
vendored
@ -1,150 +0,0 @@
|
||||
"use strict";
|
||||
var firstLineError;
|
||||
try {throw new Error(); } catch (e) {firstLineError = e;}
|
||||
var schedule = require("./schedule.js");
|
||||
var Queue = require("./queue.js");
|
||||
var util = require("./util.js");
|
||||
|
||||
function Async() {
|
||||
this._isTickUsed = false;
|
||||
this._lateQueue = new Queue(16);
|
||||
this._normalQueue = new Queue(16);
|
||||
this._trampolineEnabled = true;
|
||||
var self = this;
|
||||
this.drainQueues = function () {
|
||||
self._drainQueues();
|
||||
};
|
||||
this._schedule =
|
||||
schedule.isStatic ? schedule(this.drainQueues) : schedule;
|
||||
}
|
||||
|
||||
Async.prototype.disableTrampolineIfNecessary = function() {
|
||||
if (util.hasDevTools) {
|
||||
this._trampolineEnabled = false;
|
||||
}
|
||||
};
|
||||
|
||||
Async.prototype.enableTrampoline = function() {
|
||||
if (!this._trampolineEnabled) {
|
||||
this._trampolineEnabled = true;
|
||||
this._schedule = function(fn) {
|
||||
setTimeout(fn, 0);
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
Async.prototype.haveItemsQueued = function () {
|
||||
return this._normalQueue.length() > 0;
|
||||
};
|
||||
|
||||
Async.prototype.throwLater = function(fn, arg) {
|
||||
if (arguments.length === 1) {
|
||||
arg = fn;
|
||||
fn = function () { throw arg; };
|
||||
}
|
||||
if (typeof setTimeout !== "undefined") {
|
||||
setTimeout(function() {
|
||||
fn(arg);
|
||||
}, 0);
|
||||
} else try {
|
||||
this._schedule(function() {
|
||||
fn(arg);
|
||||
});
|
||||
} catch (e) {
|
||||
throw new Error("No async scheduler available\u000a\u000a See http://goo.gl/m3OTXk\u000a");
|
||||
}
|
||||
};
|
||||
|
||||
function AsyncInvokeLater(fn, receiver, arg) {
|
||||
this._lateQueue.push(fn, receiver, arg);
|
||||
this._queueTick();
|
||||
}
|
||||
|
||||
function AsyncInvoke(fn, receiver, arg) {
|
||||
this._normalQueue.push(fn, receiver, arg);
|
||||
this._queueTick();
|
||||
}
|
||||
|
||||
function AsyncSettlePromises(promise) {
|
||||
this._normalQueue._pushOne(promise);
|
||||
this._queueTick();
|
||||
}
|
||||
|
||||
if (!util.hasDevTools) {
|
||||
Async.prototype.invokeLater = AsyncInvokeLater;
|
||||
Async.prototype.invoke = AsyncInvoke;
|
||||
Async.prototype.settlePromises = AsyncSettlePromises;
|
||||
} else {
|
||||
if (schedule.isStatic) {
|
||||
schedule = function(fn) { setTimeout(fn, 0); };
|
||||
}
|
||||
Async.prototype.invokeLater = function (fn, receiver, arg) {
|
||||
if (this._trampolineEnabled) {
|
||||
AsyncInvokeLater.call(this, fn, receiver, arg);
|
||||
} else {
|
||||
this._schedule(function() {
|
||||
setTimeout(function() {
|
||||
fn.call(receiver, arg);
|
||||
}, 100);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
Async.prototype.invoke = function (fn, receiver, arg) {
|
||||
if (this._trampolineEnabled) {
|
||||
AsyncInvoke.call(this, fn, receiver, arg);
|
||||
} else {
|
||||
this._schedule(function() {
|
||||
fn.call(receiver, arg);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
Async.prototype.settlePromises = function(promise) {
|
||||
if (this._trampolineEnabled) {
|
||||
AsyncSettlePromises.call(this, promise);
|
||||
} else {
|
||||
this._schedule(function() {
|
||||
promise._settlePromises();
|
||||
});
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
Async.prototype.invokeFirst = function (fn, receiver, arg) {
|
||||
this._normalQueue.unshift(fn, receiver, arg);
|
||||
this._queueTick();
|
||||
};
|
||||
|
||||
Async.prototype._drainQueue = function(queue) {
|
||||
while (queue.length() > 0) {
|
||||
var fn = queue.shift();
|
||||
if (typeof fn !== "function") {
|
||||
fn._settlePromises();
|
||||
continue;
|
||||
}
|
||||
var receiver = queue.shift();
|
||||
var arg = queue.shift();
|
||||
fn.call(receiver, arg);
|
||||
}
|
||||
};
|
||||
|
||||
Async.prototype._drainQueues = function () {
|
||||
this._drainQueue(this._normalQueue);
|
||||
this._reset();
|
||||
this._drainQueue(this._lateQueue);
|
||||
};
|
||||
|
||||
Async.prototype._queueTick = function () {
|
||||
if (!this._isTickUsed) {
|
||||
this._isTickUsed = true;
|
||||
this._schedule(this.drainQueues);
|
||||
}
|
||||
};
|
||||
|
||||
Async.prototype._reset = function () {
|
||||
this._isTickUsed = false;
|
||||
};
|
||||
|
||||
module.exports = new Async();
|
||||
module.exports.firstLineError = firstLineError;
|
||||
72
node_modules/bluebird/js/main/bind.js
generated
vendored
72
node_modules/bluebird/js/main/bind.js
generated
vendored
@ -1,72 +0,0 @@
|
||||
"use strict";
|
||||
module.exports = function(Promise, INTERNAL, tryConvertToPromise) {
|
||||
var rejectThis = function(_, e) {
|
||||
this._reject(e);
|
||||
};
|
||||
|
||||
var targetRejected = function(e, context) {
|
||||
context.promiseRejectionQueued = true;
|
||||
context.bindingPromise._then(rejectThis, rejectThis, null, this, e);
|
||||
};
|
||||
|
||||
var bindingResolved = function(thisArg, context) {
|
||||
if (this._isPending()) {
|
||||
this._resolveCallback(context.target);
|
||||
}
|
||||
};
|
||||
|
||||
var bindingRejected = function(e, context) {
|
||||
if (!context.promiseRejectionQueued) this._reject(e);
|
||||
};
|
||||
|
||||
Promise.prototype.bind = function (thisArg) {
|
||||
var maybePromise = tryConvertToPromise(thisArg);
|
||||
var ret = new Promise(INTERNAL);
|
||||
ret._propagateFrom(this, 1);
|
||||
var target = this._target();
|
||||
|
||||
ret._setBoundTo(maybePromise);
|
||||
if (maybePromise instanceof Promise) {
|
||||
var context = {
|
||||
promiseRejectionQueued: false,
|
||||
promise: ret,
|
||||
target: target,
|
||||
bindingPromise: maybePromise
|
||||
};
|
||||
target._then(INTERNAL, targetRejected, ret._progress, ret, context);
|
||||
maybePromise._then(
|
||||
bindingResolved, bindingRejected, ret._progress, ret, context);
|
||||
} else {
|
||||
ret._resolveCallback(target);
|
||||
}
|
||||
return ret;
|
||||
};
|
||||
|
||||
Promise.prototype._setBoundTo = function (obj) {
|
||||
if (obj !== undefined) {
|
||||
this._bitField = this._bitField | 131072;
|
||||
this._boundTo = obj;
|
||||
} else {
|
||||
this._bitField = this._bitField & (~131072);
|
||||
}
|
||||
};
|
||||
|
||||
Promise.prototype._isBound = function () {
|
||||
return (this._bitField & 131072) === 131072;
|
||||
};
|
||||
|
||||
Promise.bind = function (thisArg, value) {
|
||||
var maybePromise = tryConvertToPromise(thisArg);
|
||||
var ret = new Promise(INTERNAL);
|
||||
|
||||
ret._setBoundTo(maybePromise);
|
||||
if (maybePromise instanceof Promise) {
|
||||
maybePromise._then(function() {
|
||||
ret._resolveCallback(value);
|
||||
}, ret._reject, ret._progress, ret, null);
|
||||
} else {
|
||||
ret._resolveCallback(value);
|
||||
}
|
||||
return ret;
|
||||
};
|
||||
};
|
||||
11
node_modules/bluebird/js/main/bluebird.js
generated
vendored
11
node_modules/bluebird/js/main/bluebird.js
generated
vendored
@ -1,11 +0,0 @@
|
||||
"use strict";
|
||||
var old;
|
||||
if (typeof Promise !== "undefined") old = Promise;
|
||||
function noConflict() {
|
||||
try { if (Promise === bluebird) Promise = old; }
|
||||
catch (e) {}
|
||||
return bluebird;
|
||||
}
|
||||
var bluebird = require("./promise.js")();
|
||||
bluebird.noConflict = noConflict;
|
||||
module.exports = bluebird;
|
||||
123
node_modules/bluebird/js/main/call_get.js
generated
vendored
123
node_modules/bluebird/js/main/call_get.js
generated
vendored
@ -1,123 +0,0 @@
|
||||
"use strict";
|
||||
var cr = Object.create;
|
||||
if (cr) {
|
||||
var callerCache = cr(null);
|
||||
var getterCache = cr(null);
|
||||
callerCache[" size"] = getterCache[" size"] = 0;
|
||||
}
|
||||
|
||||
module.exports = function(Promise) {
|
||||
var util = require("./util.js");
|
||||
var canEvaluate = util.canEvaluate;
|
||||
var isIdentifier = util.isIdentifier;
|
||||
|
||||
var getMethodCaller;
|
||||
var getGetter;
|
||||
if (!false) {
|
||||
var makeMethodCaller = function (methodName) {
|
||||
return new Function("ensureMethod", " \n\
|
||||
return function(obj) { \n\
|
||||
'use strict' \n\
|
||||
var len = this.length; \n\
|
||||
ensureMethod(obj, 'methodName'); \n\
|
||||
switch(len) { \n\
|
||||
case 1: return obj.methodName(this[0]); \n\
|
||||
case 2: return obj.methodName(this[0], this[1]); \n\
|
||||
case 3: return obj.methodName(this[0], this[1], this[2]); \n\
|
||||
case 0: return obj.methodName(); \n\
|
||||
default: \n\
|
||||
return obj.methodName.apply(obj, this); \n\
|
||||
} \n\
|
||||
}; \n\
|
||||
".replace(/methodName/g, methodName))(ensureMethod);
|
||||
};
|
||||
|
||||
var makeGetter = function (propertyName) {
|
||||
return new Function("obj", " \n\
|
||||
'use strict'; \n\
|
||||
return obj.propertyName; \n\
|
||||
".replace("propertyName", propertyName));
|
||||
};
|
||||
|
||||
var getCompiled = function(name, compiler, cache) {
|
||||
var ret = cache[name];
|
||||
if (typeof ret !== "function") {
|
||||
if (!isIdentifier(name)) {
|
||||
return null;
|
||||
}
|
||||
ret = compiler(name);
|
||||
cache[name] = ret;
|
||||
cache[" size"]++;
|
||||
if (cache[" size"] > 512) {
|
||||
var keys = Object.keys(cache);
|
||||
for (var i = 0; i < 256; ++i) delete cache[keys[i]];
|
||||
cache[" size"] = keys.length - 256;
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
};
|
||||
|
||||
getMethodCaller = function(name) {
|
||||
return getCompiled(name, makeMethodCaller, callerCache);
|
||||
};
|
||||
|
||||
getGetter = function(name) {
|
||||
return getCompiled(name, makeGetter, getterCache);
|
||||
};
|
||||
}
|
||||
|
||||
function ensureMethod(obj, methodName) {
|
||||
var fn;
|
||||
if (obj != null) fn = obj[methodName];
|
||||
if (typeof fn !== "function") {
|
||||
var message = "Object " + util.classString(obj) + " has no method '" +
|
||||
util.toString(methodName) + "'";
|
||||
throw new Promise.TypeError(message);
|
||||
}
|
||||
return fn;
|
||||
}
|
||||
|
||||
function caller(obj) {
|
||||
var methodName = this.pop();
|
||||
var fn = ensureMethod(obj, methodName);
|
||||
return fn.apply(obj, this);
|
||||
}
|
||||
Promise.prototype.call = function (methodName) {
|
||||
var $_len = arguments.length;var args = new Array($_len - 1); for(var $_i = 1; $_i < $_len; ++$_i) {args[$_i - 1] = arguments[$_i];}
|
||||
if (!false) {
|
||||
if (canEvaluate) {
|
||||
var maybeCaller = getMethodCaller(methodName);
|
||||
if (maybeCaller !== null) {
|
||||
return this._then(
|
||||
maybeCaller, undefined, undefined, args, undefined);
|
||||
}
|
||||
}
|
||||
}
|
||||
args.push(methodName);
|
||||
return this._then(caller, undefined, undefined, args, undefined);
|
||||
};
|
||||
|
||||
function namedGetter(obj) {
|
||||
return obj[this];
|
||||
}
|
||||
function indexedGetter(obj) {
|
||||
var index = +this;
|
||||
if (index < 0) index = Math.max(0, index + obj.length);
|
||||
return obj[index];
|
||||
}
|
||||
Promise.prototype.get = function (propertyName) {
|
||||
var isIndex = (typeof propertyName === "number");
|
||||
var getter;
|
||||
if (!isIndex) {
|
||||
if (canEvaluate) {
|
||||
var maybeGetter = getGetter(propertyName);
|
||||
getter = maybeGetter !== null ? maybeGetter : namedGetter;
|
||||
} else {
|
||||
getter = namedGetter;
|
||||
}
|
||||
} else {
|
||||
getter = indexedGetter;
|
||||
}
|
||||
return this._then(getter, undefined, undefined, propertyName, undefined);
|
||||
};
|
||||
};
|
||||
48
node_modules/bluebird/js/main/cancel.js
generated
vendored
48
node_modules/bluebird/js/main/cancel.js
generated
vendored
@ -1,48 +0,0 @@
|
||||
"use strict";
|
||||
module.exports = function(Promise) {
|
||||
var errors = require("./errors.js");
|
||||
var async = require("./async.js");
|
||||
var CancellationError = errors.CancellationError;
|
||||
|
||||
Promise.prototype._cancel = function (reason) {
|
||||
if (!this.isCancellable()) return this;
|
||||
var parent;
|
||||
var promiseToReject = this;
|
||||
while ((parent = promiseToReject._cancellationParent) !== undefined &&
|
||||
parent.isCancellable()) {
|
||||
promiseToReject = parent;
|
||||
}
|
||||
this._unsetCancellable();
|
||||
promiseToReject._target()._rejectCallback(reason, false, true);
|
||||
};
|
||||
|
||||
Promise.prototype.cancel = function (reason) {
|
||||
if (!this.isCancellable()) return this;
|
||||
if (reason === undefined) reason = new CancellationError();
|
||||
async.invokeLater(this._cancel, this, reason);
|
||||
return this;
|
||||
};
|
||||
|
||||
Promise.prototype.cancellable = function () {
|
||||
if (this._cancellable()) return this;
|
||||
async.enableTrampoline();
|
||||
this._setCancellable();
|
||||
this._cancellationParent = undefined;
|
||||
return this;
|
||||
};
|
||||
|
||||
Promise.prototype.uncancellable = function () {
|
||||
var ret = this.then();
|
||||
ret._unsetCancellable();
|
||||
return ret;
|
||||
};
|
||||
|
||||
Promise.prototype.fork = function (didFulfill, didReject, didProgress) {
|
||||
var ret = this._then(didFulfill, didReject, didProgress,
|
||||
undefined, undefined);
|
||||
|
||||
ret._setCancellable();
|
||||
ret._cancellationParent = undefined;
|
||||
return ret;
|
||||
};
|
||||
};
|
||||
493
node_modules/bluebird/js/main/captured_trace.js
generated
vendored
493
node_modules/bluebird/js/main/captured_trace.js
generated
vendored
@ -1,493 +0,0 @@
|
||||
"use strict";
|
||||
module.exports = function() {
|
||||
var async = require("./async.js");
|
||||
var util = require("./util.js");
|
||||
var bluebirdFramePattern =
|
||||
/[\\\/]bluebird[\\\/]js[\\\/](main|debug|zalgo|instrumented)/;
|
||||
var stackFramePattern = null;
|
||||
var formatStack = null;
|
||||
var indentStackFrames = false;
|
||||
var warn;
|
||||
|
||||
function CapturedTrace(parent) {
|
||||
this._parent = parent;
|
||||
var length = this._length = 1 + (parent === undefined ? 0 : parent._length);
|
||||
captureStackTrace(this, CapturedTrace);
|
||||
if (length > 32) this.uncycle();
|
||||
}
|
||||
util.inherits(CapturedTrace, Error);
|
||||
|
||||
CapturedTrace.prototype.uncycle = function() {
|
||||
var length = this._length;
|
||||
if (length < 2) return;
|
||||
var nodes = [];
|
||||
var stackToIndex = {};
|
||||
|
||||
for (var i = 0, node = this; node !== undefined; ++i) {
|
||||
nodes.push(node);
|
||||
node = node._parent;
|
||||
}
|
||||
length = this._length = i;
|
||||
for (var i = length - 1; i >= 0; --i) {
|
||||
var stack = nodes[i].stack;
|
||||
if (stackToIndex[stack] === undefined) {
|
||||
stackToIndex[stack] = i;
|
||||
}
|
||||
}
|
||||
for (var i = 0; i < length; ++i) {
|
||||
var currentStack = nodes[i].stack;
|
||||
var index = stackToIndex[currentStack];
|
||||
if (index !== undefined && index !== i) {
|
||||
if (index > 0) {
|
||||
nodes[index - 1]._parent = undefined;
|
||||
nodes[index - 1]._length = 1;
|
||||
}
|
||||
nodes[i]._parent = undefined;
|
||||
nodes[i]._length = 1;
|
||||
var cycleEdgeNode = i > 0 ? nodes[i - 1] : this;
|
||||
|
||||
if (index < length - 1) {
|
||||
cycleEdgeNode._parent = nodes[index + 1];
|
||||
cycleEdgeNode._parent.uncycle();
|
||||
cycleEdgeNode._length =
|
||||
cycleEdgeNode._parent._length + 1;
|
||||
} else {
|
||||
cycleEdgeNode._parent = undefined;
|
||||
cycleEdgeNode._length = 1;
|
||||
}
|
||||
var currentChildLength = cycleEdgeNode._length + 1;
|
||||
for (var j = i - 2; j >= 0; --j) {
|
||||
nodes[j]._length = currentChildLength;
|
||||
currentChildLength++;
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
CapturedTrace.prototype.parent = function() {
|
||||
return this._parent;
|
||||
};
|
||||
|
||||
CapturedTrace.prototype.hasParent = function() {
|
||||
return this._parent !== undefined;
|
||||
};
|
||||
|
||||
CapturedTrace.prototype.attachExtraTrace = function(error) {
|
||||
if (error.__stackCleaned__) return;
|
||||
this.uncycle();
|
||||
var parsed = CapturedTrace.parseStackAndMessage(error);
|
||||
var message = parsed.message;
|
||||
var stacks = [parsed.stack];
|
||||
|
||||
var trace = this;
|
||||
while (trace !== undefined) {
|
||||
stacks.push(cleanStack(trace.stack.split("\n")));
|
||||
trace = trace._parent;
|
||||
}
|
||||
removeCommonRoots(stacks);
|
||||
removeDuplicateOrEmptyJumps(stacks);
|
||||
util.notEnumerableProp(error, "stack", reconstructStack(message, stacks));
|
||||
util.notEnumerableProp(error, "__stackCleaned__", true);
|
||||
};
|
||||
|
||||
function reconstructStack(message, stacks) {
|
||||
for (var i = 0; i < stacks.length - 1; ++i) {
|
||||
stacks[i].push("From previous event:");
|
||||
stacks[i] = stacks[i].join("\n");
|
||||
}
|
||||
if (i < stacks.length) {
|
||||
stacks[i] = stacks[i].join("\n");
|
||||
}
|
||||
return message + "\n" + stacks.join("\n");
|
||||
}
|
||||
|
||||
function removeDuplicateOrEmptyJumps(stacks) {
|
||||
for (var i = 0; i < stacks.length; ++i) {
|
||||
if (stacks[i].length === 0 ||
|
||||
((i + 1 < stacks.length) && stacks[i][0] === stacks[i+1][0])) {
|
||||
stacks.splice(i, 1);
|
||||
i--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function removeCommonRoots(stacks) {
|
||||
var current = stacks[0];
|
||||
for (var i = 1; i < stacks.length; ++i) {
|
||||
var prev = stacks[i];
|
||||
var currentLastIndex = current.length - 1;
|
||||
var currentLastLine = current[currentLastIndex];
|
||||
var commonRootMeetPoint = -1;
|
||||
|
||||
for (var j = prev.length - 1; j >= 0; --j) {
|
||||
if (prev[j] === currentLastLine) {
|
||||
commonRootMeetPoint = j;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
for (var j = commonRootMeetPoint; j >= 0; --j) {
|
||||
var line = prev[j];
|
||||
if (current[currentLastIndex] === line) {
|
||||
current.pop();
|
||||
currentLastIndex--;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
current = prev;
|
||||
}
|
||||
}
|
||||
|
||||
function cleanStack(stack) {
|
||||
var ret = [];
|
||||
for (var i = 0; i < stack.length; ++i) {
|
||||
var line = stack[i];
|
||||
var isTraceLine = stackFramePattern.test(line) ||
|
||||
" (No stack trace)" === line;
|
||||
var isInternalFrame = isTraceLine && shouldIgnore(line);
|
||||
if (isTraceLine && !isInternalFrame) {
|
||||
if (indentStackFrames && line.charAt(0) !== " ") {
|
||||
line = " " + line;
|
||||
}
|
||||
ret.push(line);
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
function stackFramesAsArray(error) {
|
||||
var stack = error.stack.replace(/\s+$/g, "").split("\n");
|
||||
for (var i = 0; i < stack.length; ++i) {
|
||||
var line = stack[i];
|
||||
if (" (No stack trace)" === line || stackFramePattern.test(line)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (i > 0) {
|
||||
stack = stack.slice(i);
|
||||
}
|
||||
return stack;
|
||||
}
|
||||
|
||||
CapturedTrace.parseStackAndMessage = function(error) {
|
||||
var stack = error.stack;
|
||||
var message = error.toString();
|
||||
stack = typeof stack === "string" && stack.length > 0
|
||||
? stackFramesAsArray(error) : [" (No stack trace)"];
|
||||
return {
|
||||
message: message,
|
||||
stack: cleanStack(stack)
|
||||
};
|
||||
};
|
||||
|
||||
CapturedTrace.formatAndLogError = function(error, title) {
|
||||
if (typeof console !== "undefined") {
|
||||
var message;
|
||||
if (typeof error === "object" || typeof error === "function") {
|
||||
var stack = error.stack;
|
||||
message = title + formatStack(stack, error);
|
||||
} else {
|
||||
message = title + String(error);
|
||||
}
|
||||
if (typeof warn === "function") {
|
||||
warn(message);
|
||||
} else if (typeof console.log === "function" ||
|
||||
typeof console.log === "object") {
|
||||
console.log(message);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
CapturedTrace.unhandledRejection = function (reason) {
|
||||
CapturedTrace.formatAndLogError(reason, "^--- With additional stack trace: ");
|
||||
};
|
||||
|
||||
CapturedTrace.isSupported = function () {
|
||||
return typeof captureStackTrace === "function";
|
||||
};
|
||||
|
||||
CapturedTrace.fireRejectionEvent =
|
||||
function(name, localHandler, reason, promise) {
|
||||
var localEventFired = false;
|
||||
try {
|
||||
if (typeof localHandler === "function") {
|
||||
localEventFired = true;
|
||||
if (name === "rejectionHandled") {
|
||||
localHandler(promise);
|
||||
} else {
|
||||
localHandler(reason, promise);
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
async.throwLater(e);
|
||||
}
|
||||
|
||||
var globalEventFired = false;
|
||||
try {
|
||||
globalEventFired = fireGlobalEvent(name, reason, promise);
|
||||
} catch (e) {
|
||||
globalEventFired = true;
|
||||
async.throwLater(e);
|
||||
}
|
||||
|
||||
var domEventFired = false;
|
||||
if (fireDomEvent) {
|
||||
try {
|
||||
domEventFired = fireDomEvent(name.toLowerCase(), {
|
||||
reason: reason,
|
||||
promise: promise
|
||||
});
|
||||
} catch (e) {
|
||||
domEventFired = true;
|
||||
async.throwLater(e);
|
||||
}
|
||||
}
|
||||
|
||||
if (!globalEventFired && !localEventFired && !domEventFired &&
|
||||
name === "unhandledRejection") {
|
||||
CapturedTrace.formatAndLogError(reason, "Unhandled rejection ");
|
||||
}
|
||||
};
|
||||
|
||||
function formatNonError(obj) {
|
||||
var str;
|
||||
if (typeof obj === "function") {
|
||||
str = "[function " +
|
||||
(obj.name || "anonymous") +
|
||||
"]";
|
||||
} else {
|
||||
str = obj.toString();
|
||||
var ruselessToString = /\[object [a-zA-Z0-9$_]+\]/;
|
||||
if (ruselessToString.test(str)) {
|
||||
try {
|
||||
var newStr = JSON.stringify(obj);
|
||||
str = newStr;
|
||||
}
|
||||
catch(e) {
|
||||
|
||||
}
|
||||
}
|
||||
if (str.length === 0) {
|
||||
str = "(empty array)";
|
||||
}
|
||||
}
|
||||
return ("(<" + snip(str) + ">, no stack trace)");
|
||||
}
|
||||
|
||||
function snip(str) {
|
||||
var maxChars = 41;
|
||||
if (str.length < maxChars) {
|
||||
return str;
|
||||
}
|
||||
return str.substr(0, maxChars - 3) + "...";
|
||||
}
|
||||
|
||||
var shouldIgnore = function() { return false; };
|
||||
var parseLineInfoRegex = /[\/<\(]([^:\/]+):(\d+):(?:\d+)\)?\s*$/;
|
||||
function parseLineInfo(line) {
|
||||
var matches = line.match(parseLineInfoRegex);
|
||||
if (matches) {
|
||||
return {
|
||||
fileName: matches[1],
|
||||
line: parseInt(matches[2], 10)
|
||||
};
|
||||
}
|
||||
}
|
||||
CapturedTrace.setBounds = function(firstLineError, lastLineError) {
|
||||
if (!CapturedTrace.isSupported()) return;
|
||||
var firstStackLines = firstLineError.stack.split("\n");
|
||||
var lastStackLines = lastLineError.stack.split("\n");
|
||||
var firstIndex = -1;
|
||||
var lastIndex = -1;
|
||||
var firstFileName;
|
||||
var lastFileName;
|
||||
for (var i = 0; i < firstStackLines.length; ++i) {
|
||||
var result = parseLineInfo(firstStackLines[i]);
|
||||
if (result) {
|
||||
firstFileName = result.fileName;
|
||||
firstIndex = result.line;
|
||||
break;
|
||||
}
|
||||
}
|
||||
for (var i = 0; i < lastStackLines.length; ++i) {
|
||||
var result = parseLineInfo(lastStackLines[i]);
|
||||
if (result) {
|
||||
lastFileName = result.fileName;
|
||||
lastIndex = result.line;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (firstIndex < 0 || lastIndex < 0 || !firstFileName || !lastFileName ||
|
||||
firstFileName !== lastFileName || firstIndex >= lastIndex) {
|
||||
return;
|
||||
}
|
||||
|
||||
shouldIgnore = function(line) {
|
||||
if (bluebirdFramePattern.test(line)) return true;
|
||||
var info = parseLineInfo(line);
|
||||
if (info) {
|
||||
if (info.fileName === firstFileName &&
|
||||
(firstIndex <= info.line && info.line <= lastIndex)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
};
|
||||
};
|
||||
|
||||
var captureStackTrace = (function stackDetection() {
|
||||
var v8stackFramePattern = /^\s*at\s*/;
|
||||
var v8stackFormatter = function(stack, error) {
|
||||
if (typeof stack === "string") return stack;
|
||||
|
||||
if (error.name !== undefined &&
|
||||
error.message !== undefined) {
|
||||
return error.toString();
|
||||
}
|
||||
return formatNonError(error);
|
||||
};
|
||||
|
||||
if (typeof Error.stackTraceLimit === "number" &&
|
||||
typeof Error.captureStackTrace === "function") {
|
||||
Error.stackTraceLimit = Error.stackTraceLimit + 6;
|
||||
stackFramePattern = v8stackFramePattern;
|
||||
formatStack = v8stackFormatter;
|
||||
var captureStackTrace = Error.captureStackTrace;
|
||||
|
||||
shouldIgnore = function(line) {
|
||||
return bluebirdFramePattern.test(line);
|
||||
};
|
||||
return function(receiver, ignoreUntil) {
|
||||
Error.stackTraceLimit = Error.stackTraceLimit + 6;
|
||||
captureStackTrace(receiver, ignoreUntil);
|
||||
Error.stackTraceLimit = Error.stackTraceLimit - 6;
|
||||
};
|
||||
}
|
||||
var err = new Error();
|
||||
|
||||
if (typeof err.stack === "string" &&
|
||||
err.stack.split("\n")[0].indexOf("stackDetection@") >= 0) {
|
||||
stackFramePattern = /@/;
|
||||
formatStack = v8stackFormatter;
|
||||
indentStackFrames = true;
|
||||
return function captureStackTrace(o) {
|
||||
o.stack = new Error().stack;
|
||||
};
|
||||
}
|
||||
|
||||
var hasStackAfterThrow;
|
||||
try { throw new Error(); }
|
||||
catch(e) {
|
||||
hasStackAfterThrow = ("stack" in e);
|
||||
}
|
||||
if (!("stack" in err) && hasStackAfterThrow &&
|
||||
typeof Error.stackTraceLimit === "number") {
|
||||
stackFramePattern = v8stackFramePattern;
|
||||
formatStack = v8stackFormatter;
|
||||
return function captureStackTrace(o) {
|
||||
Error.stackTraceLimit = Error.stackTraceLimit + 6;
|
||||
try { throw new Error(); }
|
||||
catch(e) { o.stack = e.stack; }
|
||||
Error.stackTraceLimit = Error.stackTraceLimit - 6;
|
||||
};
|
||||
}
|
||||
|
||||
formatStack = function(stack, error) {
|
||||
if (typeof stack === "string") return stack;
|
||||
|
||||
if ((typeof error === "object" ||
|
||||
typeof error === "function") &&
|
||||
error.name !== undefined &&
|
||||
error.message !== undefined) {
|
||||
return error.toString();
|
||||
}
|
||||
return formatNonError(error);
|
||||
};
|
||||
|
||||
return null;
|
||||
|
||||
})([]);
|
||||
|
||||
var fireDomEvent;
|
||||
var fireGlobalEvent = (function() {
|
||||
if (util.isNode) {
|
||||
return function(name, reason, promise) {
|
||||
if (name === "rejectionHandled") {
|
||||
return process.emit(name, promise);
|
||||
} else {
|
||||
return process.emit(name, reason, promise);
|
||||
}
|
||||
};
|
||||
} else {
|
||||
var customEventWorks = false;
|
||||
var anyEventWorks = true;
|
||||
try {
|
||||
var ev = new self.CustomEvent("test");
|
||||
customEventWorks = ev instanceof CustomEvent;
|
||||
} catch (e) {}
|
||||
if (!customEventWorks) {
|
||||
try {
|
||||
var event = document.createEvent("CustomEvent");
|
||||
event.initCustomEvent("testingtheevent", false, true, {});
|
||||
self.dispatchEvent(event);
|
||||
} catch (e) {
|
||||
anyEventWorks = false;
|
||||
}
|
||||
}
|
||||
if (anyEventWorks) {
|
||||
fireDomEvent = function(type, detail) {
|
||||
var event;
|
||||
if (customEventWorks) {
|
||||
event = new self.CustomEvent(type, {
|
||||
detail: detail,
|
||||
bubbles: false,
|
||||
cancelable: true
|
||||
});
|
||||
} else if (self.dispatchEvent) {
|
||||
event = document.createEvent("CustomEvent");
|
||||
event.initCustomEvent(type, false, true, detail);
|
||||
}
|
||||
|
||||
return event ? !self.dispatchEvent(event) : false;
|
||||
};
|
||||
}
|
||||
|
||||
var toWindowMethodNameMap = {};
|
||||
toWindowMethodNameMap["unhandledRejection"] = ("on" +
|
||||
"unhandledRejection").toLowerCase();
|
||||
toWindowMethodNameMap["rejectionHandled"] = ("on" +
|
||||
"rejectionHandled").toLowerCase();
|
||||
|
||||
return function(name, reason, promise) {
|
||||
var methodName = toWindowMethodNameMap[name];
|
||||
var method = self[methodName];
|
||||
if (!method) return false;
|
||||
if (name === "rejectionHandled") {
|
||||
method.call(self, promise);
|
||||
} else {
|
||||
method.call(self, reason, promise);
|
||||
}
|
||||
return true;
|
||||
};
|
||||
}
|
||||
})();
|
||||
|
||||
if (typeof console !== "undefined" && typeof console.warn !== "undefined") {
|
||||
warn = function (message) {
|
||||
console.warn(message);
|
||||
};
|
||||
if (util.isNode && process.stderr.isTTY) {
|
||||
warn = function(message) {
|
||||
process.stderr.write("\u001b[31m" + message + "\u001b[39m\n");
|
||||
};
|
||||
} else if (!util.isNode && typeof (new Error().stack) === "string") {
|
||||
warn = function(message) {
|
||||
console.warn("%c" + message, "color: red");
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
return CapturedTrace;
|
||||
};
|
||||
66
node_modules/bluebird/js/main/catch_filter.js
generated
vendored
66
node_modules/bluebird/js/main/catch_filter.js
generated
vendored
@ -1,66 +0,0 @@
|
||||
"use strict";
|
||||
module.exports = function(NEXT_FILTER) {
|
||||
var util = require("./util.js");
|
||||
var errors = require("./errors.js");
|
||||
var tryCatch = util.tryCatch;
|
||||
var errorObj = util.errorObj;
|
||||
var keys = require("./es5.js").keys;
|
||||
var TypeError = errors.TypeError;
|
||||
|
||||
function CatchFilter(instances, callback, promise) {
|
||||
this._instances = instances;
|
||||
this._callback = callback;
|
||||
this._promise = promise;
|
||||
}
|
||||
|
||||
function safePredicate(predicate, e) {
|
||||
var safeObject = {};
|
||||
var retfilter = tryCatch(predicate).call(safeObject, e);
|
||||
|
||||
if (retfilter === errorObj) return retfilter;
|
||||
|
||||
var safeKeys = keys(safeObject);
|
||||
if (safeKeys.length) {
|
||||
errorObj.e = new TypeError("Catch filter must inherit from Error or be a simple predicate function\u000a\u000a See http://goo.gl/o84o68\u000a");
|
||||
return errorObj;
|
||||
}
|
||||
return retfilter;
|
||||
}
|
||||
|
||||
CatchFilter.prototype.doFilter = function (e) {
|
||||
var cb = this._callback;
|
||||
var promise = this._promise;
|
||||
var boundTo = promise._boundValue();
|
||||
for (var i = 0, len = this._instances.length; i < len; ++i) {
|
||||
var item = this._instances[i];
|
||||
var itemIsErrorType = item === Error ||
|
||||
(item != null && item.prototype instanceof Error);
|
||||
|
||||
if (itemIsErrorType && e instanceof item) {
|
||||
var ret = tryCatch(cb).call(boundTo, e);
|
||||
if (ret === errorObj) {
|
||||
NEXT_FILTER.e = ret.e;
|
||||
return NEXT_FILTER;
|
||||
}
|
||||
return ret;
|
||||
} else if (typeof item === "function" && !itemIsErrorType) {
|
||||
var shouldHandle = safePredicate(item, e);
|
||||
if (shouldHandle === errorObj) {
|
||||
e = errorObj.e;
|
||||
break;
|
||||
} else if (shouldHandle) {
|
||||
var ret = tryCatch(cb).call(boundTo, e);
|
||||
if (ret === errorObj) {
|
||||
NEXT_FILTER.e = ret.e;
|
||||
return NEXT_FILTER;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
}
|
||||
NEXT_FILTER.e = e;
|
||||
return NEXT_FILTER;
|
||||
};
|
||||
|
||||
return CatchFilter;
|
||||
};
|
||||
38
node_modules/bluebird/js/main/context.js
generated
vendored
38
node_modules/bluebird/js/main/context.js
generated
vendored
@ -1,38 +0,0 @@
|
||||
"use strict";
|
||||
module.exports = function(Promise, CapturedTrace, isDebugging) {
|
||||
var contextStack = [];
|
||||
function Context() {
|
||||
this._trace = new CapturedTrace(peekContext());
|
||||
}
|
||||
Context.prototype._pushContext = function () {
|
||||
if (!isDebugging()) return;
|
||||
if (this._trace !== undefined) {
|
||||
contextStack.push(this._trace);
|
||||
}
|
||||
};
|
||||
|
||||
Context.prototype._popContext = function () {
|
||||
if (!isDebugging()) return;
|
||||
if (this._trace !== undefined) {
|
||||
contextStack.pop();
|
||||
}
|
||||
};
|
||||
|
||||
function createContext() {
|
||||
if (isDebugging()) return new Context();
|
||||
}
|
||||
|
||||
function peekContext() {
|
||||
var lastIndex = contextStack.length - 1;
|
||||
if (lastIndex >= 0) {
|
||||
return contextStack[lastIndex];
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
Promise.prototype._peekContext = peekContext;
|
||||
Promise.prototype._pushContext = Context.prototype._pushContext;
|
||||
Promise.prototype._popContext = Context.prototype._popContext;
|
||||
|
||||
return createContext;
|
||||
};
|
||||
160
node_modules/bluebird/js/main/debuggability.js
generated
vendored
160
node_modules/bluebird/js/main/debuggability.js
generated
vendored
@ -1,160 +0,0 @@
|
||||
"use strict";
|
||||
module.exports = function(Promise, CapturedTrace) {
|
||||
var getDomain = Promise._getDomain;
|
||||
var async = require("./async.js");
|
||||
var Warning = require("./errors.js").Warning;
|
||||
var util = require("./util.js");
|
||||
var canAttachTrace = util.canAttachTrace;
|
||||
var unhandledRejectionHandled;
|
||||
var possiblyUnhandledRejection;
|
||||
var debugging = false || (util.isNode &&
|
||||
(!!process.env["BLUEBIRD_DEBUG"] ||
|
||||
process.env["NODE_ENV"] === "development"));
|
||||
|
||||
if (debugging) {
|
||||
async.disableTrampolineIfNecessary();
|
||||
}
|
||||
|
||||
Promise.prototype._ignoreRejections = function() {
|
||||
this._unsetRejectionIsUnhandled();
|
||||
this._bitField = this._bitField | 16777216;
|
||||
};
|
||||
|
||||
Promise.prototype._ensurePossibleRejectionHandled = function () {
|
||||
if ((this._bitField & 16777216) !== 0) return;
|
||||
this._setRejectionIsUnhandled();
|
||||
async.invokeLater(this._notifyUnhandledRejection, this, undefined);
|
||||
};
|
||||
|
||||
Promise.prototype._notifyUnhandledRejectionIsHandled = function () {
|
||||
CapturedTrace.fireRejectionEvent("rejectionHandled",
|
||||
unhandledRejectionHandled, undefined, this);
|
||||
};
|
||||
|
||||
Promise.prototype._notifyUnhandledRejection = function () {
|
||||
if (this._isRejectionUnhandled()) {
|
||||
var reason = this._getCarriedStackTrace() || this._settledValue;
|
||||
this._setUnhandledRejectionIsNotified();
|
||||
CapturedTrace.fireRejectionEvent("unhandledRejection",
|
||||
possiblyUnhandledRejection, reason, this);
|
||||
}
|
||||
};
|
||||
|
||||
Promise.prototype._setUnhandledRejectionIsNotified = function () {
|
||||
this._bitField = this._bitField | 524288;
|
||||
};
|
||||
|
||||
Promise.prototype._unsetUnhandledRejectionIsNotified = function () {
|
||||
this._bitField = this._bitField & (~524288);
|
||||
};
|
||||
|
||||
Promise.prototype._isUnhandledRejectionNotified = function () {
|
||||
return (this._bitField & 524288) > 0;
|
||||
};
|
||||
|
||||
Promise.prototype._setRejectionIsUnhandled = function () {
|
||||
this._bitField = this._bitField | 2097152;
|
||||
};
|
||||
|
||||
Promise.prototype._unsetRejectionIsUnhandled = function () {
|
||||
this._bitField = this._bitField & (~2097152);
|
||||
if (this._isUnhandledRejectionNotified()) {
|
||||
this._unsetUnhandledRejectionIsNotified();
|
||||
this._notifyUnhandledRejectionIsHandled();
|
||||
}
|
||||
};
|
||||
|
||||
Promise.prototype._isRejectionUnhandled = function () {
|
||||
return (this._bitField & 2097152) > 0;
|
||||
};
|
||||
|
||||
Promise.prototype._setCarriedStackTrace = function (capturedTrace) {
|
||||
this._bitField = this._bitField | 1048576;
|
||||
this._fulfillmentHandler0 = capturedTrace;
|
||||
};
|
||||
|
||||
Promise.prototype._isCarryingStackTrace = function () {
|
||||
return (this._bitField & 1048576) > 0;
|
||||
};
|
||||
|
||||
Promise.prototype._getCarriedStackTrace = function () {
|
||||
return this._isCarryingStackTrace()
|
||||
? this._fulfillmentHandler0
|
||||
: undefined;
|
||||
};
|
||||
|
||||
Promise.prototype._captureStackTrace = function () {
|
||||
if (debugging) {
|
||||
this._trace = new CapturedTrace(this._peekContext());
|
||||
}
|
||||
return this;
|
||||
};
|
||||
|
||||
Promise.prototype._attachExtraTrace = function (error, ignoreSelf) {
|
||||
if (debugging && canAttachTrace(error)) {
|
||||
var trace = this._trace;
|
||||
if (trace !== undefined) {
|
||||
if (ignoreSelf) trace = trace._parent;
|
||||
}
|
||||
if (trace !== undefined) {
|
||||
trace.attachExtraTrace(error);
|
||||
} else if (!error.__stackCleaned__) {
|
||||
var parsed = CapturedTrace.parseStackAndMessage(error);
|
||||
util.notEnumerableProp(error, "stack",
|
||||
parsed.message + "\n" + parsed.stack.join("\n"));
|
||||
util.notEnumerableProp(error, "__stackCleaned__", true);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Promise.prototype._warn = function(message) {
|
||||
var warning = new Warning(message);
|
||||
var ctx = this._peekContext();
|
||||
if (ctx) {
|
||||
ctx.attachExtraTrace(warning);
|
||||
} else {
|
||||
var parsed = CapturedTrace.parseStackAndMessage(warning);
|
||||
warning.stack = parsed.message + "\n" + parsed.stack.join("\n");
|
||||
}
|
||||
CapturedTrace.formatAndLogError(warning, "");
|
||||
};
|
||||
|
||||
Promise.onPossiblyUnhandledRejection = function (fn) {
|
||||
var domain = getDomain();
|
||||
possiblyUnhandledRejection =
|
||||
typeof fn === "function" ? (domain === null ? fn : domain.bind(fn))
|
||||
: undefined;
|
||||
};
|
||||
|
||||
Promise.onUnhandledRejectionHandled = function (fn) {
|
||||
var domain = getDomain();
|
||||
unhandledRejectionHandled =
|
||||
typeof fn === "function" ? (domain === null ? fn : domain.bind(fn))
|
||||
: undefined;
|
||||
};
|
||||
|
||||
Promise.longStackTraces = function () {
|
||||
if (async.haveItemsQueued() &&
|
||||
debugging === false
|
||||
) {
|
||||
throw new Error("cannot enable long stack traces after promises have been created\u000a\u000a See http://goo.gl/DT1qyG\u000a");
|
||||
}
|
||||
debugging = CapturedTrace.isSupported();
|
||||
if (debugging) {
|
||||
async.disableTrampolineIfNecessary();
|
||||
}
|
||||
};
|
||||
|
||||
Promise.hasLongStackTraces = function () {
|
||||
return debugging && CapturedTrace.isSupported();
|
||||
};
|
||||
|
||||
if (!CapturedTrace.isSupported()) {
|
||||
Promise.longStackTraces = function(){};
|
||||
debugging = false;
|
||||
}
|
||||
|
||||
return function() {
|
||||
return debugging;
|
||||
};
|
||||
};
|
||||
61
node_modules/bluebird/js/main/direct_resolve.js
generated
vendored
61
node_modules/bluebird/js/main/direct_resolve.js
generated
vendored
@ -1,61 +0,0 @@
|
||||
"use strict";
|
||||
var util = require("./util.js");
|
||||
var isPrimitive = util.isPrimitive;
|
||||
|
||||
module.exports = function(Promise) {
|
||||
var returner = function () {
|
||||
return this;
|
||||
};
|
||||
var thrower = function () {
|
||||
throw this;
|
||||
};
|
||||
var returnUndefined = function() {};
|
||||
var throwUndefined = function() {
|
||||
throw undefined;
|
||||
};
|
||||
|
||||
var wrapper = function (value, action) {
|
||||
if (action === 1) {
|
||||
return function () {
|
||||
throw value;
|
||||
};
|
||||
} else if (action === 2) {
|
||||
return function () {
|
||||
return value;
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Promise.prototype["return"] =
|
||||
Promise.prototype.thenReturn = function (value) {
|
||||
if (value === undefined) return this.then(returnUndefined);
|
||||
|
||||
if (isPrimitive(value)) {
|
||||
return this._then(
|
||||
wrapper(value, 2),
|
||||
undefined,
|
||||
undefined,
|
||||
undefined,
|
||||
undefined
|
||||
);
|
||||
}
|
||||
return this._then(returner, undefined, undefined, value, undefined);
|
||||
};
|
||||
|
||||
Promise.prototype["throw"] =
|
||||
Promise.prototype.thenThrow = function (reason) {
|
||||
if (reason === undefined) return this.then(throwUndefined);
|
||||
|
||||
if (isPrimitive(reason)) {
|
||||
return this._then(
|
||||
wrapper(reason, 1),
|
||||
undefined,
|
||||
undefined,
|
||||
undefined,
|
||||
undefined
|
||||
);
|
||||
}
|
||||
return this._then(thrower, undefined, undefined, reason, undefined);
|
||||
};
|
||||
};
|
||||
12
node_modules/bluebird/js/main/each.js
generated
vendored
12
node_modules/bluebird/js/main/each.js
generated
vendored
@ -1,12 +0,0 @@
|
||||
"use strict";
|
||||
module.exports = function(Promise, INTERNAL) {
|
||||
var PromiseReduce = Promise.reduce;
|
||||
|
||||
Promise.prototype.each = function (fn) {
|
||||
return PromiseReduce(this, fn, null, INTERNAL);
|
||||
};
|
||||
|
||||
Promise.each = function (promises, fn) {
|
||||
return PromiseReduce(promises, fn, null, INTERNAL);
|
||||
};
|
||||
};
|
||||
111
node_modules/bluebird/js/main/errors.js
generated
vendored
111
node_modules/bluebird/js/main/errors.js
generated
vendored
@ -1,111 +0,0 @@
|
||||
"use strict";
|
||||
var es5 = require("./es5.js");
|
||||
var Objectfreeze = es5.freeze;
|
||||
var util = require("./util.js");
|
||||
var inherits = util.inherits;
|
||||
var notEnumerableProp = util.notEnumerableProp;
|
||||
|
||||
function subError(nameProperty, defaultMessage) {
|
||||
function SubError(message) {
|
||||
if (!(this instanceof SubError)) return new SubError(message);
|
||||
notEnumerableProp(this, "message",
|
||||
typeof message === "string" ? message : defaultMessage);
|
||||
notEnumerableProp(this, "name", nameProperty);
|
||||
if (Error.captureStackTrace) {
|
||||
Error.captureStackTrace(this, this.constructor);
|
||||
} else {
|
||||
Error.call(this);
|
||||
}
|
||||
}
|
||||
inherits(SubError, Error);
|
||||
return SubError;
|
||||
}
|
||||
|
||||
var _TypeError, _RangeError;
|
||||
var Warning = subError("Warning", "warning");
|
||||
var CancellationError = subError("CancellationError", "cancellation error");
|
||||
var TimeoutError = subError("TimeoutError", "timeout error");
|
||||
var AggregateError = subError("AggregateError", "aggregate error");
|
||||
try {
|
||||
_TypeError = TypeError;
|
||||
_RangeError = RangeError;
|
||||
} catch(e) {
|
||||
_TypeError = subError("TypeError", "type error");
|
||||
_RangeError = subError("RangeError", "range error");
|
||||
}
|
||||
|
||||
var methods = ("join pop push shift unshift slice filter forEach some " +
|
||||
"every map indexOf lastIndexOf reduce reduceRight sort reverse").split(" ");
|
||||
|
||||
for (var i = 0; i < methods.length; ++i) {
|
||||
if (typeof Array.prototype[methods[i]] === "function") {
|
||||
AggregateError.prototype[methods[i]] = Array.prototype[methods[i]];
|
||||
}
|
||||
}
|
||||
|
||||
es5.defineProperty(AggregateError.prototype, "length", {
|
||||
value: 0,
|
||||
configurable: false,
|
||||
writable: true,
|
||||
enumerable: true
|
||||
});
|
||||
AggregateError.prototype["isOperational"] = true;
|
||||
var level = 0;
|
||||
AggregateError.prototype.toString = function() {
|
||||
var indent = Array(level * 4 + 1).join(" ");
|
||||
var ret = "\n" + indent + "AggregateError of:" + "\n";
|
||||
level++;
|
||||
indent = Array(level * 4 + 1).join(" ");
|
||||
for (var i = 0; i < this.length; ++i) {
|
||||
var str = this[i] === this ? "[Circular AggregateError]" : this[i] + "";
|
||||
var lines = str.split("\n");
|
||||
for (var j = 0; j < lines.length; ++j) {
|
||||
lines[j] = indent + lines[j];
|
||||
}
|
||||
str = lines.join("\n");
|
||||
ret += str + "\n";
|
||||
}
|
||||
level--;
|
||||
return ret;
|
||||
};
|
||||
|
||||
function OperationalError(message) {
|
||||
if (!(this instanceof OperationalError))
|
||||
return new OperationalError(message);
|
||||
notEnumerableProp(this, "name", "OperationalError");
|
||||
notEnumerableProp(this, "message", message);
|
||||
this.cause = message;
|
||||
this["isOperational"] = true;
|
||||
|
||||
if (message instanceof Error) {
|
||||
notEnumerableProp(this, "message", message.message);
|
||||
notEnumerableProp(this, "stack", message.stack);
|
||||
} else if (Error.captureStackTrace) {
|
||||
Error.captureStackTrace(this, this.constructor);
|
||||
}
|
||||
|
||||
}
|
||||
inherits(OperationalError, Error);
|
||||
|
||||
var errorTypes = Error["__BluebirdErrorTypes__"];
|
||||
if (!errorTypes) {
|
||||
errorTypes = Objectfreeze({
|
||||
CancellationError: CancellationError,
|
||||
TimeoutError: TimeoutError,
|
||||
OperationalError: OperationalError,
|
||||
RejectionError: OperationalError,
|
||||
AggregateError: AggregateError
|
||||
});
|
||||
notEnumerableProp(Error, "__BluebirdErrorTypes__", errorTypes);
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
Error: Error,
|
||||
TypeError: _TypeError,
|
||||
RangeError: _RangeError,
|
||||
CancellationError: errorTypes.CancellationError,
|
||||
OperationalError: errorTypes.OperationalError,
|
||||
TimeoutError: errorTypes.TimeoutError,
|
||||
AggregateError: errorTypes.AggregateError,
|
||||
Warning: Warning
|
||||
};
|
||||
80
node_modules/bluebird/js/main/es5.js
generated
vendored
80
node_modules/bluebird/js/main/es5.js
generated
vendored
@ -1,80 +0,0 @@
|
||||
var isES5 = (function(){
|
||||
"use strict";
|
||||
return this === undefined;
|
||||
})();
|
||||
|
||||
if (isES5) {
|
||||
module.exports = {
|
||||
freeze: Object.freeze,
|
||||
defineProperty: Object.defineProperty,
|
||||
getDescriptor: Object.getOwnPropertyDescriptor,
|
||||
keys: Object.keys,
|
||||
names: Object.getOwnPropertyNames,
|
||||
getPrototypeOf: Object.getPrototypeOf,
|
||||
isArray: Array.isArray,
|
||||
isES5: isES5,
|
||||
propertyIsWritable: function(obj, prop) {
|
||||
var descriptor = Object.getOwnPropertyDescriptor(obj, prop);
|
||||
return !!(!descriptor || descriptor.writable || descriptor.set);
|
||||
}
|
||||
};
|
||||
} else {
|
||||
var has = {}.hasOwnProperty;
|
||||
var str = {}.toString;
|
||||
var proto = {}.constructor.prototype;
|
||||
|
||||
var ObjectKeys = function (o) {
|
||||
var ret = [];
|
||||
for (var key in o) {
|
||||
if (has.call(o, key)) {
|
||||
ret.push(key);
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
};
|
||||
|
||||
var ObjectGetDescriptor = function(o, key) {
|
||||
return {value: o[key]};
|
||||
};
|
||||
|
||||
var ObjectDefineProperty = function (o, key, desc) {
|
||||
o[key] = desc.value;
|
||||
return o;
|
||||
};
|
||||
|
||||
var ObjectFreeze = function (obj) {
|
||||
return obj;
|
||||
};
|
||||
|
||||
var ObjectGetPrototypeOf = function (obj) {
|
||||
try {
|
||||
return Object(obj).constructor.prototype;
|
||||
}
|
||||
catch (e) {
|
||||
return proto;
|
||||
}
|
||||
};
|
||||
|
||||
var ArrayIsArray = function (obj) {
|
||||
try {
|
||||
return str.call(obj) === "[object Array]";
|
||||
}
|
||||
catch(e) {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
isArray: ArrayIsArray,
|
||||
keys: ObjectKeys,
|
||||
names: ObjectKeys,
|
||||
defineProperty: ObjectDefineProperty,
|
||||
getDescriptor: ObjectGetDescriptor,
|
||||
freeze: ObjectFreeze,
|
||||
getPrototypeOf: ObjectGetPrototypeOf,
|
||||
isES5: isES5,
|
||||
propertyIsWritable: function() {
|
||||
return true;
|
||||
}
|
||||
};
|
||||
}
|
||||
12
node_modules/bluebird/js/main/filter.js
generated
vendored
12
node_modules/bluebird/js/main/filter.js
generated
vendored
@ -1,12 +0,0 @@
|
||||
"use strict";
|
||||
module.exports = function(Promise, INTERNAL) {
|
||||
var PromiseMap = Promise.map;
|
||||
|
||||
Promise.prototype.filter = function (fn, options) {
|
||||
return PromiseMap(this, fn, options, INTERNAL);
|
||||
};
|
||||
|
||||
Promise.filter = function (promises, fn, options) {
|
||||
return PromiseMap(promises, fn, options, INTERNAL);
|
||||
};
|
||||
};
|
||||
98
node_modules/bluebird/js/main/finally.js
generated
vendored
98
node_modules/bluebird/js/main/finally.js
generated
vendored
@ -1,98 +0,0 @@
|
||||
"use strict";
|
||||
module.exports = function(Promise, NEXT_FILTER, tryConvertToPromise) {
|
||||
var util = require("./util.js");
|
||||
var isPrimitive = util.isPrimitive;
|
||||
var thrower = util.thrower;
|
||||
|
||||
function returnThis() {
|
||||
return this;
|
||||
}
|
||||
function throwThis() {
|
||||
throw this;
|
||||
}
|
||||
function return$(r) {
|
||||
return function() {
|
||||
return r;
|
||||
};
|
||||
}
|
||||
function throw$(r) {
|
||||
return function() {
|
||||
throw r;
|
||||
};
|
||||
}
|
||||
function promisedFinally(ret, reasonOrValue, isFulfilled) {
|
||||
var then;
|
||||
if (isPrimitive(reasonOrValue)) {
|
||||
then = isFulfilled ? return$(reasonOrValue) : throw$(reasonOrValue);
|
||||
} else {
|
||||
then = isFulfilled ? returnThis : throwThis;
|
||||
}
|
||||
return ret._then(then, thrower, undefined, reasonOrValue, undefined);
|
||||
}
|
||||
|
||||
function finallyHandler(reasonOrValue) {
|
||||
var promise = this.promise;
|
||||
var handler = this.handler;
|
||||
|
||||
var ret = promise._isBound()
|
||||
? handler.call(promise._boundValue())
|
||||
: handler();
|
||||
|
||||
if (ret !== undefined) {
|
||||
var maybePromise = tryConvertToPromise(ret, promise);
|
||||
if (maybePromise instanceof Promise) {
|
||||
maybePromise = maybePromise._target();
|
||||
return promisedFinally(maybePromise, reasonOrValue,
|
||||
promise.isFulfilled());
|
||||
}
|
||||
}
|
||||
|
||||
if (promise.isRejected()) {
|
||||
NEXT_FILTER.e = reasonOrValue;
|
||||
return NEXT_FILTER;
|
||||
} else {
|
||||
return reasonOrValue;
|
||||
}
|
||||
}
|
||||
|
||||
function tapHandler(value) {
|
||||
var promise = this.promise;
|
||||
var handler = this.handler;
|
||||
|
||||
var ret = promise._isBound()
|
||||
? handler.call(promise._boundValue(), value)
|
||||
: handler(value);
|
||||
|
||||
if (ret !== undefined) {
|
||||
var maybePromise = tryConvertToPromise(ret, promise);
|
||||
if (maybePromise instanceof Promise) {
|
||||
maybePromise = maybePromise._target();
|
||||
return promisedFinally(maybePromise, value, true);
|
||||
}
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
Promise.prototype._passThroughHandler = function (handler, isFinally) {
|
||||
if (typeof handler !== "function") return this.then();
|
||||
|
||||
var promiseAndHandler = {
|
||||
promise: this,
|
||||
handler: handler
|
||||
};
|
||||
|
||||
return this._then(
|
||||
isFinally ? finallyHandler : tapHandler,
|
||||
isFinally ? finallyHandler : undefined, undefined,
|
||||
promiseAndHandler, undefined);
|
||||
};
|
||||
|
||||
Promise.prototype.lastly =
|
||||
Promise.prototype["finally"] = function (handler) {
|
||||
return this._passThroughHandler(handler, true);
|
||||
};
|
||||
|
||||
Promise.prototype.tap = function (handler) {
|
||||
return this._passThroughHandler(handler, false);
|
||||
};
|
||||
};
|
||||
136
node_modules/bluebird/js/main/generators.js
generated
vendored
136
node_modules/bluebird/js/main/generators.js
generated
vendored
@ -1,136 +0,0 @@
|
||||
"use strict";
|
||||
module.exports = function(Promise,
|
||||
apiRejection,
|
||||
INTERNAL,
|
||||
tryConvertToPromise) {
|
||||
var errors = require("./errors.js");
|
||||
var TypeError = errors.TypeError;
|
||||
var util = require("./util.js");
|
||||
var errorObj = util.errorObj;
|
||||
var tryCatch = util.tryCatch;
|
||||
var yieldHandlers = [];
|
||||
|
||||
function promiseFromYieldHandler(value, yieldHandlers, traceParent) {
|
||||
for (var i = 0; i < yieldHandlers.length; ++i) {
|
||||
traceParent._pushContext();
|
||||
var result = tryCatch(yieldHandlers[i])(value);
|
||||
traceParent._popContext();
|
||||
if (result === errorObj) {
|
||||
traceParent._pushContext();
|
||||
var ret = Promise.reject(errorObj.e);
|
||||
traceParent._popContext();
|
||||
return ret;
|
||||
}
|
||||
var maybePromise = tryConvertToPromise(result, traceParent);
|
||||
if (maybePromise instanceof Promise) return maybePromise;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
function PromiseSpawn(generatorFunction, receiver, yieldHandler, stack) {
|
||||
var promise = this._promise = new Promise(INTERNAL);
|
||||
promise._captureStackTrace();
|
||||
this._stack = stack;
|
||||
this._generatorFunction = generatorFunction;
|
||||
this._receiver = receiver;
|
||||
this._generator = undefined;
|
||||
this._yieldHandlers = typeof yieldHandler === "function"
|
||||
? [yieldHandler].concat(yieldHandlers)
|
||||
: yieldHandlers;
|
||||
}
|
||||
|
||||
PromiseSpawn.prototype.promise = function () {
|
||||
return this._promise;
|
||||
};
|
||||
|
||||
PromiseSpawn.prototype._run = function () {
|
||||
this._generator = this._generatorFunction.call(this._receiver);
|
||||
this._receiver =
|
||||
this._generatorFunction = undefined;
|
||||
this._next(undefined);
|
||||
};
|
||||
|
||||
PromiseSpawn.prototype._continue = function (result) {
|
||||
if (result === errorObj) {
|
||||
return this._promise._rejectCallback(result.e, false, true);
|
||||
}
|
||||
|
||||
var value = result.value;
|
||||
if (result.done === true) {
|
||||
this._promise._resolveCallback(value);
|
||||
} else {
|
||||
var maybePromise = tryConvertToPromise(value, this._promise);
|
||||
if (!(maybePromise instanceof Promise)) {
|
||||
maybePromise =
|
||||
promiseFromYieldHandler(maybePromise,
|
||||
this._yieldHandlers,
|
||||
this._promise);
|
||||
if (maybePromise === null) {
|
||||
this._throw(
|
||||
new TypeError(
|
||||
"A value %s was yielded that could not be treated as a promise\u000a\u000a See http://goo.gl/4Y4pDk\u000a\u000a".replace("%s", value) +
|
||||
"From coroutine:\u000a" +
|
||||
this._stack.split("\n").slice(1, -7).join("\n")
|
||||
)
|
||||
);
|
||||
return;
|
||||
}
|
||||
}
|
||||
maybePromise._then(
|
||||
this._next,
|
||||
this._throw,
|
||||
undefined,
|
||||
this,
|
||||
null
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
PromiseSpawn.prototype._throw = function (reason) {
|
||||
this._promise._attachExtraTrace(reason);
|
||||
this._promise._pushContext();
|
||||
var result = tryCatch(this._generator["throw"])
|
||||
.call(this._generator, reason);
|
||||
this._promise._popContext();
|
||||
this._continue(result);
|
||||
};
|
||||
|
||||
PromiseSpawn.prototype._next = function (value) {
|
||||
this._promise._pushContext();
|
||||
var result = tryCatch(this._generator.next).call(this._generator, value);
|
||||
this._promise._popContext();
|
||||
this._continue(result);
|
||||
};
|
||||
|
||||
Promise.coroutine = function (generatorFunction, options) {
|
||||
if (typeof generatorFunction !== "function") {
|
||||
throw new TypeError("generatorFunction must be a function\u000a\u000a See http://goo.gl/6Vqhm0\u000a");
|
||||
}
|
||||
var yieldHandler = Object(options).yieldHandler;
|
||||
var PromiseSpawn$ = PromiseSpawn;
|
||||
var stack = new Error().stack;
|
||||
return function () {
|
||||
var generator = generatorFunction.apply(this, arguments);
|
||||
var spawn = new PromiseSpawn$(undefined, undefined, yieldHandler,
|
||||
stack);
|
||||
spawn._generator = generator;
|
||||
spawn._next(undefined);
|
||||
return spawn.promise();
|
||||
};
|
||||
};
|
||||
|
||||
Promise.coroutine.addYieldHandler = function(fn) {
|
||||
if (typeof fn !== "function") throw new TypeError("fn must be a function\u000a\u000a See http://goo.gl/916lJJ\u000a");
|
||||
yieldHandlers.push(fn);
|
||||
};
|
||||
|
||||
Promise.spawn = function (generatorFunction) {
|
||||
if (typeof generatorFunction !== "function") {
|
||||
return apiRejection("generatorFunction must be a function\u000a\u000a See http://goo.gl/6Vqhm0\u000a");
|
||||
}
|
||||
var spawn = new PromiseSpawn(generatorFunction, this);
|
||||
var ret = spawn.promise();
|
||||
spawn._run(Promise.spawn);
|
||||
return ret;
|
||||
};
|
||||
};
|
||||
107
node_modules/bluebird/js/main/join.js
generated
vendored
107
node_modules/bluebird/js/main/join.js
generated
vendored
@ -1,107 +0,0 @@
|
||||
"use strict";
|
||||
module.exports =
|
||||
function(Promise, PromiseArray, tryConvertToPromise, INTERNAL) {
|
||||
var util = require("./util.js");
|
||||
var canEvaluate = util.canEvaluate;
|
||||
var tryCatch = util.tryCatch;
|
||||
var errorObj = util.errorObj;
|
||||
var reject;
|
||||
|
||||
if (!false) {
|
||||
if (canEvaluate) {
|
||||
var thenCallback = function(i) {
|
||||
return new Function("value", "holder", " \n\
|
||||
'use strict'; \n\
|
||||
holder.pIndex = value; \n\
|
||||
holder.checkFulfillment(this); \n\
|
||||
".replace(/Index/g, i));
|
||||
};
|
||||
|
||||
var caller = function(count) {
|
||||
var values = [];
|
||||
for (var i = 1; i <= count; ++i) values.push("holder.p" + i);
|
||||
return new Function("holder", " \n\
|
||||
'use strict'; \n\
|
||||
var callback = holder.fn; \n\
|
||||
return callback(values); \n\
|
||||
".replace(/values/g, values.join(", ")));
|
||||
};
|
||||
var thenCallbacks = [];
|
||||
var callers = [undefined];
|
||||
for (var i = 1; i <= 5; ++i) {
|
||||
thenCallbacks.push(thenCallback(i));
|
||||
callers.push(caller(i));
|
||||
}
|
||||
|
||||
var Holder = function(total, fn) {
|
||||
this.p1 = this.p2 = this.p3 = this.p4 = this.p5 = null;
|
||||
this.fn = fn;
|
||||
this.total = total;
|
||||
this.now = 0;
|
||||
};
|
||||
|
||||
Holder.prototype.callers = callers;
|
||||
Holder.prototype.checkFulfillment = function(promise) {
|
||||
var now = this.now;
|
||||
now++;
|
||||
var total = this.total;
|
||||
if (now >= total) {
|
||||
var handler = this.callers[total];
|
||||
promise._pushContext();
|
||||
var ret = tryCatch(handler)(this);
|
||||
promise._popContext();
|
||||
if (ret === errorObj) {
|
||||
promise._rejectCallback(ret.e, false, true);
|
||||
} else {
|
||||
promise._resolveCallback(ret);
|
||||
}
|
||||
} else {
|
||||
this.now = now;
|
||||
}
|
||||
};
|
||||
|
||||
var reject = function (reason) {
|
||||
this._reject(reason);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Promise.join = function () {
|
||||
var last = arguments.length - 1;
|
||||
var fn;
|
||||
if (last > 0 && typeof arguments[last] === "function") {
|
||||
fn = arguments[last];
|
||||
if (!false) {
|
||||
if (last < 6 && canEvaluate) {
|
||||
var ret = new Promise(INTERNAL);
|
||||
ret._captureStackTrace();
|
||||
var holder = new Holder(last, fn);
|
||||
var callbacks = thenCallbacks;
|
||||
for (var i = 0; i < last; ++i) {
|
||||
var maybePromise = tryConvertToPromise(arguments[i], ret);
|
||||
if (maybePromise instanceof Promise) {
|
||||
maybePromise = maybePromise._target();
|
||||
if (maybePromise._isPending()) {
|
||||
maybePromise._then(callbacks[i], reject,
|
||||
undefined, ret, holder);
|
||||
} else if (maybePromise._isFulfilled()) {
|
||||
callbacks[i].call(ret,
|
||||
maybePromise._value(), holder);
|
||||
} else {
|
||||
ret._reject(maybePromise._reason());
|
||||
}
|
||||
} else {
|
||||
callbacks[i].call(ret, maybePromise, holder);
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
}
|
||||
var $_len = arguments.length;var args = new Array($_len); for(var $_i = 0; $_i < $_len; ++$_i) {args[$_i] = arguments[$_i];}
|
||||
if (fn) args.pop();
|
||||
var ret = new PromiseArray(args).promise();
|
||||
return fn !== undefined ? ret.spread(fn) : ret;
|
||||
};
|
||||
|
||||
};
|
||||
133
node_modules/bluebird/js/main/map.js
generated
vendored
133
node_modules/bluebird/js/main/map.js
generated
vendored
@ -1,133 +0,0 @@
|
||||
"use strict";
|
||||
module.exports = function(Promise,
|
||||
PromiseArray,
|
||||
apiRejection,
|
||||
tryConvertToPromise,
|
||||
INTERNAL) {
|
||||
var getDomain = Promise._getDomain;
|
||||
var async = require("./async.js");
|
||||
var util = require("./util.js");
|
||||
var tryCatch = util.tryCatch;
|
||||
var errorObj = util.errorObj;
|
||||
var PENDING = {};
|
||||
var EMPTY_ARRAY = [];
|
||||
|
||||
function MappingPromiseArray(promises, fn, limit, _filter) {
|
||||
this.constructor$(promises);
|
||||
this._promise._captureStackTrace();
|
||||
var domain = getDomain();
|
||||
this._callback = domain === null ? fn : domain.bind(fn);
|
||||
this._preservedValues = _filter === INTERNAL
|
||||
? new Array(this.length())
|
||||
: null;
|
||||
this._limit = limit;
|
||||
this._inFlight = 0;
|
||||
this._queue = limit >= 1 ? [] : EMPTY_ARRAY;
|
||||
async.invoke(init, this, undefined);
|
||||
}
|
||||
util.inherits(MappingPromiseArray, PromiseArray);
|
||||
function init() {this._init$(undefined, -2);}
|
||||
|
||||
MappingPromiseArray.prototype._init = function () {};
|
||||
|
||||
MappingPromiseArray.prototype._promiseFulfilled = function (value, index) {
|
||||
var values = this._values;
|
||||
var length = this.length();
|
||||
var preservedValues = this._preservedValues;
|
||||
var limit = this._limit;
|
||||
if (values[index] === PENDING) {
|
||||
values[index] = value;
|
||||
if (limit >= 1) {
|
||||
this._inFlight--;
|
||||
this._drainQueue();
|
||||
if (this._isResolved()) return;
|
||||
}
|
||||
} else {
|
||||
if (limit >= 1 && this._inFlight >= limit) {
|
||||
values[index] = value;
|
||||
this._queue.push(index);
|
||||
return;
|
||||
}
|
||||
if (preservedValues !== null) preservedValues[index] = value;
|
||||
|
||||
var callback = this._callback;
|
||||
var receiver = this._promise._boundValue();
|
||||
this._promise._pushContext();
|
||||
var ret = tryCatch(callback).call(receiver, value, index, length);
|
||||
this._promise._popContext();
|
||||
if (ret === errorObj) return this._reject(ret.e);
|
||||
|
||||
var maybePromise = tryConvertToPromise(ret, this._promise);
|
||||
if (maybePromise instanceof Promise) {
|
||||
maybePromise = maybePromise._target();
|
||||
if (maybePromise._isPending()) {
|
||||
if (limit >= 1) this._inFlight++;
|
||||
values[index] = PENDING;
|
||||
return maybePromise._proxyPromiseArray(this, index);
|
||||
} else if (maybePromise._isFulfilled()) {
|
||||
ret = maybePromise._value();
|
||||
} else {
|
||||
return this._reject(maybePromise._reason());
|
||||
}
|
||||
}
|
||||
values[index] = ret;
|
||||
}
|
||||
var totalResolved = ++this._totalResolved;
|
||||
if (totalResolved >= length) {
|
||||
if (preservedValues !== null) {
|
||||
this._filter(values, preservedValues);
|
||||
} else {
|
||||
this._resolve(values);
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
MappingPromiseArray.prototype._drainQueue = function () {
|
||||
var queue = this._queue;
|
||||
var limit = this._limit;
|
||||
var values = this._values;
|
||||
while (queue.length > 0 && this._inFlight < limit) {
|
||||
if (this._isResolved()) return;
|
||||
var index = queue.pop();
|
||||
this._promiseFulfilled(values[index], index);
|
||||
}
|
||||
};
|
||||
|
||||
MappingPromiseArray.prototype._filter = function (booleans, values) {
|
||||
var len = values.length;
|
||||
var ret = new Array(len);
|
||||
var j = 0;
|
||||
for (var i = 0; i < len; ++i) {
|
||||
if (booleans[i]) ret[j++] = values[i];
|
||||
}
|
||||
ret.length = j;
|
||||
this._resolve(ret);
|
||||
};
|
||||
|
||||
MappingPromiseArray.prototype.preservedValues = function () {
|
||||
return this._preservedValues;
|
||||
};
|
||||
|
||||
function map(promises, fn, options, _filter) {
|
||||
var limit = typeof options === "object" && options !== null
|
||||
? options.concurrency
|
||||
: 0;
|
||||
limit = typeof limit === "number" &&
|
||||
isFinite(limit) && limit >= 1 ? limit : 0;
|
||||
return new MappingPromiseArray(promises, fn, limit, _filter);
|
||||
}
|
||||
|
||||
Promise.prototype.map = function (fn, options) {
|
||||
if (typeof fn !== "function") return apiRejection("fn must be a function\u000a\u000a See http://goo.gl/916lJJ\u000a");
|
||||
|
||||
return map(this, fn, options, null).promise();
|
||||
};
|
||||
|
||||
Promise.map = function (promises, fn, options, _filter) {
|
||||
if (typeof fn !== "function") return apiRejection("fn must be a function\u000a\u000a See http://goo.gl/916lJJ\u000a");
|
||||
return map(promises, fn, options, _filter).promise();
|
||||
};
|
||||
|
||||
|
||||
};
|
||||
44
node_modules/bluebird/js/main/method.js
generated
vendored
44
node_modules/bluebird/js/main/method.js
generated
vendored
@ -1,44 +0,0 @@
|
||||
"use strict";
|
||||
module.exports =
|
||||
function(Promise, INTERNAL, tryConvertToPromise, apiRejection) {
|
||||
var util = require("./util.js");
|
||||
var tryCatch = util.tryCatch;
|
||||
|
||||
Promise.method = function (fn) {
|
||||
if (typeof fn !== "function") {
|
||||
throw new Promise.TypeError("fn must be a function\u000a\u000a See http://goo.gl/916lJJ\u000a");
|
||||
}
|
||||
return function () {
|
||||
var ret = new Promise(INTERNAL);
|
||||
ret._captureStackTrace();
|
||||
ret._pushContext();
|
||||
var value = tryCatch(fn).apply(this, arguments);
|
||||
ret._popContext();
|
||||
ret._resolveFromSyncValue(value);
|
||||
return ret;
|
||||
};
|
||||
};
|
||||
|
||||
Promise.attempt = Promise["try"] = function (fn, args, ctx) {
|
||||
if (typeof fn !== "function") {
|
||||
return apiRejection("fn must be a function\u000a\u000a See http://goo.gl/916lJJ\u000a");
|
||||
}
|
||||
var ret = new Promise(INTERNAL);
|
||||
ret._captureStackTrace();
|
||||
ret._pushContext();
|
||||
var value = util.isArray(args)
|
||||
? tryCatch(fn).apply(ctx, args)
|
||||
: tryCatch(fn).call(ctx, args);
|
||||
ret._popContext();
|
||||
ret._resolveFromSyncValue(value);
|
||||
return ret;
|
||||
};
|
||||
|
||||
Promise.prototype._resolveFromSyncValue = function (value) {
|
||||
if (value === util.errorObj) {
|
||||
this._rejectCallback(value.e, false, true);
|
||||
} else {
|
||||
this._resolveCallback(value, true);
|
||||
}
|
||||
};
|
||||
};
|
||||
59
node_modules/bluebird/js/main/nodeify.js
generated
vendored
59
node_modules/bluebird/js/main/nodeify.js
generated
vendored
@ -1,59 +0,0 @@
|
||||
"use strict";
|
||||
module.exports = function(Promise) {
|
||||
var util = require("./util.js");
|
||||
var async = require("./async.js");
|
||||
var tryCatch = util.tryCatch;
|
||||
var errorObj = util.errorObj;
|
||||
|
||||
function spreadAdapter(val, nodeback) {
|
||||
var promise = this;
|
||||
if (!util.isArray(val)) return successAdapter.call(promise, val, nodeback);
|
||||
var ret =
|
||||
tryCatch(nodeback).apply(promise._boundValue(), [null].concat(val));
|
||||
if (ret === errorObj) {
|
||||
async.throwLater(ret.e);
|
||||
}
|
||||
}
|
||||
|
||||
function successAdapter(val, nodeback) {
|
||||
var promise = this;
|
||||
var receiver = promise._boundValue();
|
||||
var ret = val === undefined
|
||||
? tryCatch(nodeback).call(receiver, null)
|
||||
: tryCatch(nodeback).call(receiver, null, val);
|
||||
if (ret === errorObj) {
|
||||
async.throwLater(ret.e);
|
||||
}
|
||||
}
|
||||
function errorAdapter(reason, nodeback) {
|
||||
var promise = this;
|
||||
if (!reason) {
|
||||
var target = promise._target();
|
||||
var newReason = target._getCarriedStackTrace();
|
||||
newReason.cause = reason;
|
||||
reason = newReason;
|
||||
}
|
||||
var ret = tryCatch(nodeback).call(promise._boundValue(), reason);
|
||||
if (ret === errorObj) {
|
||||
async.throwLater(ret.e);
|
||||
}
|
||||
}
|
||||
|
||||
Promise.prototype.asCallback =
|
||||
Promise.prototype.nodeify = function (nodeback, options) {
|
||||
if (typeof nodeback == "function") {
|
||||
var adapter = successAdapter;
|
||||
if (options !== undefined && Object(options).spread) {
|
||||
adapter = spreadAdapter;
|
||||
}
|
||||
this._then(
|
||||
adapter,
|
||||
errorAdapter,
|
||||
undefined,
|
||||
this,
|
||||
nodeback
|
||||
);
|
||||
}
|
||||
return this;
|
||||
};
|
||||
};
|
||||
76
node_modules/bluebird/js/main/progress.js
generated
vendored
76
node_modules/bluebird/js/main/progress.js
generated
vendored
@ -1,76 +0,0 @@
|
||||
"use strict";
|
||||
module.exports = function(Promise, PromiseArray) {
|
||||
var util = require("./util.js");
|
||||
var async = require("./async.js");
|
||||
var tryCatch = util.tryCatch;
|
||||
var errorObj = util.errorObj;
|
||||
|
||||
Promise.prototype.progressed = function (handler) {
|
||||
return this._then(undefined, undefined, handler, undefined, undefined);
|
||||
};
|
||||
|
||||
Promise.prototype._progress = function (progressValue) {
|
||||
if (this._isFollowingOrFulfilledOrRejected()) return;
|
||||
this._target()._progressUnchecked(progressValue);
|
||||
|
||||
};
|
||||
|
||||
Promise.prototype._progressHandlerAt = function (index) {
|
||||
return index === 0
|
||||
? this._progressHandler0
|
||||
: this[(index << 2) + index - 5 + 2];
|
||||
};
|
||||
|
||||
Promise.prototype._doProgressWith = function (progression) {
|
||||
var progressValue = progression.value;
|
||||
var handler = progression.handler;
|
||||
var promise = progression.promise;
|
||||
var receiver = progression.receiver;
|
||||
|
||||
var ret = tryCatch(handler).call(receiver, progressValue);
|
||||
if (ret === errorObj) {
|
||||
if (ret.e != null &&
|
||||
ret.e.name !== "StopProgressPropagation") {
|
||||
var trace = util.canAttachTrace(ret.e)
|
||||
? ret.e : new Error(util.toString(ret.e));
|
||||
promise._attachExtraTrace(trace);
|
||||
promise._progress(ret.e);
|
||||
}
|
||||
} else if (ret instanceof Promise) {
|
||||
ret._then(promise._progress, null, null, promise, undefined);
|
||||
} else {
|
||||
promise._progress(ret);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Promise.prototype._progressUnchecked = function (progressValue) {
|
||||
var len = this._length();
|
||||
var progress = this._progress;
|
||||
for (var i = 0; i < len; i++) {
|
||||
var handler = this._progressHandlerAt(i);
|
||||
var promise = this._promiseAt(i);
|
||||
if (!(promise instanceof Promise)) {
|
||||
var receiver = this._receiverAt(i);
|
||||
if (typeof handler === "function") {
|
||||
handler.call(receiver, progressValue, promise);
|
||||
} else if (receiver instanceof PromiseArray &&
|
||||
!receiver._isResolved()) {
|
||||
receiver._promiseProgressed(progressValue, promise);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
if (typeof handler === "function") {
|
||||
async.invoke(this._doProgressWith, this, {
|
||||
handler: handler,
|
||||
promise: promise,
|
||||
receiver: this._receiverAt(i),
|
||||
value: progressValue
|
||||
});
|
||||
} else {
|
||||
async.invoke(progress, promise, progressValue);
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
750
node_modules/bluebird/js/main/promise.js
generated
vendored
750
node_modules/bluebird/js/main/promise.js
generated
vendored
@ -1,750 +0,0 @@
|
||||
"use strict";
|
||||
module.exports = function() {
|
||||
var makeSelfResolutionError = function () {
|
||||
return new TypeError("circular promise resolution chain\u000a\u000a See http://goo.gl/LhFpo0\u000a");
|
||||
};
|
||||
var reflect = function() {
|
||||
return new Promise.PromiseInspection(this._target());
|
||||
};
|
||||
var apiRejection = function(msg) {
|
||||
return Promise.reject(new TypeError(msg));
|
||||
};
|
||||
|
||||
var util = require("./util.js");
|
||||
|
||||
var getDomain;
|
||||
if (util.isNode) {
|
||||
getDomain = function() {
|
||||
var ret = process.domain;
|
||||
if (ret === undefined) ret = null;
|
||||
return ret;
|
||||
};
|
||||
} else {
|
||||
getDomain = function() {
|
||||
return null;
|
||||
};
|
||||
}
|
||||
util.notEnumerableProp(Promise, "_getDomain", getDomain);
|
||||
|
||||
var async = require("./async.js");
|
||||
var errors = require("./errors.js");
|
||||
var TypeError = Promise.TypeError = errors.TypeError;
|
||||
Promise.RangeError = errors.RangeError;
|
||||
Promise.CancellationError = errors.CancellationError;
|
||||
Promise.TimeoutError = errors.TimeoutError;
|
||||
Promise.OperationalError = errors.OperationalError;
|
||||
Promise.RejectionError = errors.OperationalError;
|
||||
Promise.AggregateError = errors.AggregateError;
|
||||
var INTERNAL = function(){};
|
||||
var APPLY = {};
|
||||
var NEXT_FILTER = {e: null};
|
||||
var tryConvertToPromise = require("./thenables.js")(Promise, INTERNAL);
|
||||
var PromiseArray =
|
||||
require("./promise_array.js")(Promise, INTERNAL,
|
||||
tryConvertToPromise, apiRejection);
|
||||
var CapturedTrace = require("./captured_trace.js")();
|
||||
var isDebugging = require("./debuggability.js")(Promise, CapturedTrace);
|
||||
/*jshint unused:false*/
|
||||
var createContext =
|
||||
require("./context.js")(Promise, CapturedTrace, isDebugging);
|
||||
var CatchFilter = require("./catch_filter.js")(NEXT_FILTER);
|
||||
var PromiseResolver = require("./promise_resolver.js");
|
||||
var nodebackForPromise = PromiseResolver._nodebackForPromise;
|
||||
var errorObj = util.errorObj;
|
||||
var tryCatch = util.tryCatch;
|
||||
function Promise(resolver) {
|
||||
if (typeof resolver !== "function") {
|
||||
throw new TypeError("the promise constructor requires a resolver function\u000a\u000a See http://goo.gl/EC22Yn\u000a");
|
||||
}
|
||||
if (this.constructor !== Promise) {
|
||||
throw new TypeError("the promise constructor cannot be invoked directly\u000a\u000a See http://goo.gl/KsIlge\u000a");
|
||||
}
|
||||
this._bitField = 0;
|
||||
this._fulfillmentHandler0 = undefined;
|
||||
this._rejectionHandler0 = undefined;
|
||||
this._progressHandler0 = undefined;
|
||||
this._promise0 = undefined;
|
||||
this._receiver0 = undefined;
|
||||
this._settledValue = undefined;
|
||||
if (resolver !== INTERNAL) this._resolveFromResolver(resolver);
|
||||
}
|
||||
|
||||
Promise.prototype.toString = function () {
|
||||
return "[object Promise]";
|
||||
};
|
||||
|
||||
Promise.prototype.caught = Promise.prototype["catch"] = function (fn) {
|
||||
var len = arguments.length;
|
||||
if (len > 1) {
|
||||
var catchInstances = new Array(len - 1),
|
||||
j = 0, i;
|
||||
for (i = 0; i < len - 1; ++i) {
|
||||
var item = arguments[i];
|
||||
if (typeof item === "function") {
|
||||
catchInstances[j++] = item;
|
||||
} else {
|
||||
return Promise.reject(
|
||||
new TypeError("Catch filter must inherit from Error or be a simple predicate function\u000a\u000a See http://goo.gl/o84o68\u000a"));
|
||||
}
|
||||
}
|
||||
catchInstances.length = j;
|
||||
fn = arguments[i];
|
||||
var catchFilter = new CatchFilter(catchInstances, fn, this);
|
||||
return this._then(undefined, catchFilter.doFilter, undefined,
|
||||
catchFilter, undefined);
|
||||
}
|
||||
return this._then(undefined, fn, undefined, undefined, undefined);
|
||||
};
|
||||
|
||||
Promise.prototype.reflect = function () {
|
||||
return this._then(reflect, reflect, undefined, this, undefined);
|
||||
};
|
||||
|
||||
Promise.prototype.then = function (didFulfill, didReject, didProgress) {
|
||||
if (isDebugging() && arguments.length > 0 &&
|
||||
typeof didFulfill !== "function" &&
|
||||
typeof didReject !== "function") {
|
||||
var msg = ".then() only accepts functions but was passed: " +
|
||||
util.classString(didFulfill);
|
||||
if (arguments.length > 1) {
|
||||
msg += ", " + util.classString(didReject);
|
||||
}
|
||||
this._warn(msg);
|
||||
}
|
||||
return this._then(didFulfill, didReject, didProgress,
|
||||
undefined, undefined);
|
||||
};
|
||||
|
||||
Promise.prototype.done = function (didFulfill, didReject, didProgress) {
|
||||
var promise = this._then(didFulfill, didReject, didProgress,
|
||||
undefined, undefined);
|
||||
promise._setIsFinal();
|
||||
};
|
||||
|
||||
Promise.prototype.spread = function (didFulfill, didReject) {
|
||||
return this.all()._then(didFulfill, didReject, undefined, APPLY, undefined);
|
||||
};
|
||||
|
||||
Promise.prototype.isCancellable = function () {
|
||||
return !this.isResolved() &&
|
||||
this._cancellable();
|
||||
};
|
||||
|
||||
Promise.prototype.toJSON = function () {
|
||||
var ret = {
|
||||
isFulfilled: false,
|
||||
isRejected: false,
|
||||
fulfillmentValue: undefined,
|
||||
rejectionReason: undefined
|
||||
};
|
||||
if (this.isFulfilled()) {
|
||||
ret.fulfillmentValue = this.value();
|
||||
ret.isFulfilled = true;
|
||||
} else if (this.isRejected()) {
|
||||
ret.rejectionReason = this.reason();
|
||||
ret.isRejected = true;
|
||||
}
|
||||
return ret;
|
||||
};
|
||||
|
||||
Promise.prototype.all = function () {
|
||||
return new PromiseArray(this).promise();
|
||||
};
|
||||
|
||||
Promise.prototype.error = function (fn) {
|
||||
return this.caught(util.originatesFromRejection, fn);
|
||||
};
|
||||
|
||||
Promise.is = function (val) {
|
||||
return val instanceof Promise;
|
||||
};
|
||||
|
||||
Promise.fromNode = function(fn) {
|
||||
var ret = new Promise(INTERNAL);
|
||||
var result = tryCatch(fn)(nodebackForPromise(ret));
|
||||
if (result === errorObj) {
|
||||
ret._rejectCallback(result.e, true, true);
|
||||
}
|
||||
return ret;
|
||||
};
|
||||
|
||||
Promise.all = function (promises) {
|
||||
return new PromiseArray(promises).promise();
|
||||
};
|
||||
|
||||
Promise.defer = Promise.pending = function () {
|
||||
var promise = new Promise(INTERNAL);
|
||||
return new PromiseResolver(promise);
|
||||
};
|
||||
|
||||
Promise.cast = function (obj) {
|
||||
var ret = tryConvertToPromise(obj);
|
||||
if (!(ret instanceof Promise)) {
|
||||
var val = ret;
|
||||
ret = new Promise(INTERNAL);
|
||||
ret._fulfillUnchecked(val);
|
||||
}
|
||||
return ret;
|
||||
};
|
||||
|
||||
Promise.resolve = Promise.fulfilled = Promise.cast;
|
||||
|
||||
Promise.reject = Promise.rejected = function (reason) {
|
||||
var ret = new Promise(INTERNAL);
|
||||
ret._captureStackTrace();
|
||||
ret._rejectCallback(reason, true);
|
||||
return ret;
|
||||
};
|
||||
|
||||
Promise.setScheduler = function(fn) {
|
||||
if (typeof fn !== "function") throw new TypeError("fn must be a function\u000a\u000a See http://goo.gl/916lJJ\u000a");
|
||||
var prev = async._schedule;
|
||||
async._schedule = fn;
|
||||
return prev;
|
||||
};
|
||||
|
||||
Promise.prototype._then = function (
|
||||
didFulfill,
|
||||
didReject,
|
||||
didProgress,
|
||||
receiver,
|
||||
internalData
|
||||
) {
|
||||
var haveInternalData = internalData !== undefined;
|
||||
var ret = haveInternalData ? internalData : new Promise(INTERNAL);
|
||||
|
||||
if (!haveInternalData) {
|
||||
ret._propagateFrom(this, 4 | 1);
|
||||
ret._captureStackTrace();
|
||||
}
|
||||
|
||||
var target = this._target();
|
||||
if (target !== this) {
|
||||
if (receiver === undefined) receiver = this._boundTo;
|
||||
if (!haveInternalData) ret._setIsMigrated();
|
||||
}
|
||||
|
||||
var callbackIndex = target._addCallbacks(didFulfill,
|
||||
didReject,
|
||||
didProgress,
|
||||
ret,
|
||||
receiver,
|
||||
getDomain());
|
||||
|
||||
if (target._isResolved() && !target._isSettlePromisesQueued()) {
|
||||
async.invoke(
|
||||
target._settlePromiseAtPostResolution, target, callbackIndex);
|
||||
}
|
||||
|
||||
return ret;
|
||||
};
|
||||
|
||||
Promise.prototype._settlePromiseAtPostResolution = function (index) {
|
||||
if (this._isRejectionUnhandled()) this._unsetRejectionIsUnhandled();
|
||||
this._settlePromiseAt(index);
|
||||
};
|
||||
|
||||
Promise.prototype._length = function () {
|
||||
return this._bitField & 131071;
|
||||
};
|
||||
|
||||
Promise.prototype._isFollowingOrFulfilledOrRejected = function () {
|
||||
return (this._bitField & 939524096) > 0;
|
||||
};
|
||||
|
||||
Promise.prototype._isFollowing = function () {
|
||||
return (this._bitField & 536870912) === 536870912;
|
||||
};
|
||||
|
||||
Promise.prototype._setLength = function (len) {
|
||||
this._bitField = (this._bitField & -131072) |
|
||||
(len & 131071);
|
||||
};
|
||||
|
||||
Promise.prototype._setFulfilled = function () {
|
||||
this._bitField = this._bitField | 268435456;
|
||||
};
|
||||
|
||||
Promise.prototype._setRejected = function () {
|
||||
this._bitField = this._bitField | 134217728;
|
||||
};
|
||||
|
||||
Promise.prototype._setFollowing = function () {
|
||||
this._bitField = this._bitField | 536870912;
|
||||
};
|
||||
|
||||
Promise.prototype._setIsFinal = function () {
|
||||
this._bitField = this._bitField | 33554432;
|
||||
};
|
||||
|
||||
Promise.prototype._isFinal = function () {
|
||||
return (this._bitField & 33554432) > 0;
|
||||
};
|
||||
|
||||
Promise.prototype._cancellable = function () {
|
||||
return (this._bitField & 67108864) > 0;
|
||||
};
|
||||
|
||||
Promise.prototype._setCancellable = function () {
|
||||
this._bitField = this._bitField | 67108864;
|
||||
};
|
||||
|
||||
Promise.prototype._unsetCancellable = function () {
|
||||
this._bitField = this._bitField & (~67108864);
|
||||
};
|
||||
|
||||
Promise.prototype._setIsMigrated = function () {
|
||||
this._bitField = this._bitField | 4194304;
|
||||
};
|
||||
|
||||
Promise.prototype._unsetIsMigrated = function () {
|
||||
this._bitField = this._bitField & (~4194304);
|
||||
};
|
||||
|
||||
Promise.prototype._isMigrated = function () {
|
||||
return (this._bitField & 4194304) > 0;
|
||||
};
|
||||
|
||||
Promise.prototype._receiverAt = function (index) {
|
||||
var ret = index === 0
|
||||
? this._receiver0
|
||||
: this[
|
||||
index * 5 - 5 + 4];
|
||||
if (ret === undefined && this._isBound()) {
|
||||
return this._boundValue();
|
||||
}
|
||||
return ret;
|
||||
};
|
||||
|
||||
Promise.prototype._promiseAt = function (index) {
|
||||
return index === 0
|
||||
? this._promise0
|
||||
: this[index * 5 - 5 + 3];
|
||||
};
|
||||
|
||||
Promise.prototype._fulfillmentHandlerAt = function (index) {
|
||||
return index === 0
|
||||
? this._fulfillmentHandler0
|
||||
: this[index * 5 - 5 + 0];
|
||||
};
|
||||
|
||||
Promise.prototype._rejectionHandlerAt = function (index) {
|
||||
return index === 0
|
||||
? this._rejectionHandler0
|
||||
: this[index * 5 - 5 + 1];
|
||||
};
|
||||
|
||||
Promise.prototype._boundValue = function() {
|
||||
var ret = this._boundTo;
|
||||
if (ret !== undefined) {
|
||||
if (ret instanceof Promise) {
|
||||
if (ret.isFulfilled()) {
|
||||
return ret.value();
|
||||
} else {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
};
|
||||
|
||||
Promise.prototype._migrateCallbacks = function (follower, index) {
|
||||
var fulfill = follower._fulfillmentHandlerAt(index);
|
||||
var reject = follower._rejectionHandlerAt(index);
|
||||
var progress = follower._progressHandlerAt(index);
|
||||
var promise = follower._promiseAt(index);
|
||||
var receiver = follower._receiverAt(index);
|
||||
if (promise instanceof Promise) promise._setIsMigrated();
|
||||
this._addCallbacks(fulfill, reject, progress, promise, receiver, null);
|
||||
};
|
||||
|
||||
Promise.prototype._addCallbacks = function (
|
||||
fulfill,
|
||||
reject,
|
||||
progress,
|
||||
promise,
|
||||
receiver,
|
||||
domain
|
||||
) {
|
||||
var index = this._length();
|
||||
|
||||
if (index >= 131071 - 5) {
|
||||
index = 0;
|
||||
this._setLength(0);
|
||||
}
|
||||
|
||||
if (index === 0) {
|
||||
this._promise0 = promise;
|
||||
if (receiver !== undefined) this._receiver0 = receiver;
|
||||
if (typeof fulfill === "function" && !this._isCarryingStackTrace()) {
|
||||
this._fulfillmentHandler0 =
|
||||
domain === null ? fulfill : domain.bind(fulfill);
|
||||
}
|
||||
if (typeof reject === "function") {
|
||||
this._rejectionHandler0 =
|
||||
domain === null ? reject : domain.bind(reject);
|
||||
}
|
||||
if (typeof progress === "function") {
|
||||
this._progressHandler0 =
|
||||
domain === null ? progress : domain.bind(progress);
|
||||
}
|
||||
} else {
|
||||
var base = index * 5 - 5;
|
||||
this[base + 3] = promise;
|
||||
this[base + 4] = receiver;
|
||||
if (typeof fulfill === "function") {
|
||||
this[base + 0] =
|
||||
domain === null ? fulfill : domain.bind(fulfill);
|
||||
}
|
||||
if (typeof reject === "function") {
|
||||
this[base + 1] =
|
||||
domain === null ? reject : domain.bind(reject);
|
||||
}
|
||||
if (typeof progress === "function") {
|
||||
this[base + 2] =
|
||||
domain === null ? progress : domain.bind(progress);
|
||||
}
|
||||
}
|
||||
this._setLength(index + 1);
|
||||
return index;
|
||||
};
|
||||
|
||||
Promise.prototype._setProxyHandlers = function (receiver, promiseSlotValue) {
|
||||
var index = this._length();
|
||||
|
||||
if (index >= 131071 - 5) {
|
||||
index = 0;
|
||||
this._setLength(0);
|
||||
}
|
||||
if (index === 0) {
|
||||
this._promise0 = promiseSlotValue;
|
||||
this._receiver0 = receiver;
|
||||
} else {
|
||||
var base = index * 5 - 5;
|
||||
this[base + 3] = promiseSlotValue;
|
||||
this[base + 4] = receiver;
|
||||
}
|
||||
this._setLength(index + 1);
|
||||
};
|
||||
|
||||
Promise.prototype._proxyPromiseArray = function (promiseArray, index) {
|
||||
this._setProxyHandlers(promiseArray, index);
|
||||
};
|
||||
|
||||
Promise.prototype._resolveCallback = function(value, shouldBind) {
|
||||
if (this._isFollowingOrFulfilledOrRejected()) return;
|
||||
if (value === this)
|
||||
return this._rejectCallback(makeSelfResolutionError(), false, true);
|
||||
var maybePromise = tryConvertToPromise(value, this);
|
||||
if (!(maybePromise instanceof Promise)) return this._fulfill(value);
|
||||
|
||||
var propagationFlags = 1 | (shouldBind ? 4 : 0);
|
||||
this._propagateFrom(maybePromise, propagationFlags);
|
||||
var promise = maybePromise._target();
|
||||
if (promise._isPending()) {
|
||||
var len = this._length();
|
||||
for (var i = 0; i < len; ++i) {
|
||||
promise._migrateCallbacks(this, i);
|
||||
}
|
||||
this._setFollowing();
|
||||
this._setLength(0);
|
||||
this._setFollowee(promise);
|
||||
} else if (promise._isFulfilled()) {
|
||||
this._fulfillUnchecked(promise._value());
|
||||
} else {
|
||||
this._rejectUnchecked(promise._reason(),
|
||||
promise._getCarriedStackTrace());
|
||||
}
|
||||
};
|
||||
|
||||
Promise.prototype._rejectCallback =
|
||||
function(reason, synchronous, shouldNotMarkOriginatingFromRejection) {
|
||||
if (!shouldNotMarkOriginatingFromRejection) {
|
||||
util.markAsOriginatingFromRejection(reason);
|
||||
}
|
||||
var trace = util.ensureErrorObject(reason);
|
||||
var hasStack = trace === reason;
|
||||
this._attachExtraTrace(trace, synchronous ? hasStack : false);
|
||||
this._reject(reason, hasStack ? undefined : trace);
|
||||
};
|
||||
|
||||
Promise.prototype._resolveFromResolver = function (resolver) {
|
||||
var promise = this;
|
||||
this._captureStackTrace();
|
||||
this._pushContext();
|
||||
var synchronous = true;
|
||||
var r = tryCatch(resolver)(function(value) {
|
||||
if (promise === null) return;
|
||||
promise._resolveCallback(value);
|
||||
promise = null;
|
||||
}, function (reason) {
|
||||
if (promise === null) return;
|
||||
promise._rejectCallback(reason, synchronous);
|
||||
promise = null;
|
||||
});
|
||||
synchronous = false;
|
||||
this._popContext();
|
||||
|
||||
if (r !== undefined && r === errorObj && promise !== null) {
|
||||
promise._rejectCallback(r.e, true, true);
|
||||
promise = null;
|
||||
}
|
||||
};
|
||||
|
||||
Promise.prototype._settlePromiseFromHandler = function (
|
||||
handler, receiver, value, promise
|
||||
) {
|
||||
if (promise._isRejected()) return;
|
||||
promise._pushContext();
|
||||
var x;
|
||||
if (receiver === APPLY && !this._isRejected()) {
|
||||
x = tryCatch(handler).apply(this._boundValue(), value);
|
||||
} else {
|
||||
x = tryCatch(handler).call(receiver, value);
|
||||
}
|
||||
promise._popContext();
|
||||
|
||||
if (x === errorObj || x === promise || x === NEXT_FILTER) {
|
||||
var err = x === promise ? makeSelfResolutionError() : x.e;
|
||||
promise._rejectCallback(err, false, true);
|
||||
} else {
|
||||
promise._resolveCallback(x);
|
||||
}
|
||||
};
|
||||
|
||||
Promise.prototype._target = function() {
|
||||
var ret = this;
|
||||
while (ret._isFollowing()) ret = ret._followee();
|
||||
return ret;
|
||||
};
|
||||
|
||||
Promise.prototype._followee = function() {
|
||||
return this._rejectionHandler0;
|
||||
};
|
||||
|
||||
Promise.prototype._setFollowee = function(promise) {
|
||||
this._rejectionHandler0 = promise;
|
||||
};
|
||||
|
||||
Promise.prototype._cleanValues = function () {
|
||||
if (this._cancellable()) {
|
||||
this._cancellationParent = undefined;
|
||||
}
|
||||
};
|
||||
|
||||
Promise.prototype._propagateFrom = function (parent, flags) {
|
||||
if ((flags & 1) > 0 && parent._cancellable()) {
|
||||
this._setCancellable();
|
||||
this._cancellationParent = parent;
|
||||
}
|
||||
if ((flags & 4) > 0 && parent._isBound()) {
|
||||
this._setBoundTo(parent._boundTo);
|
||||
}
|
||||
};
|
||||
|
||||
Promise.prototype._fulfill = function (value) {
|
||||
if (this._isFollowingOrFulfilledOrRejected()) return;
|
||||
this._fulfillUnchecked(value);
|
||||
};
|
||||
|
||||
Promise.prototype._reject = function (reason, carriedStackTrace) {
|
||||
if (this._isFollowingOrFulfilledOrRejected()) return;
|
||||
this._rejectUnchecked(reason, carriedStackTrace);
|
||||
};
|
||||
|
||||
Promise.prototype._settlePromiseAt = function (index) {
|
||||
var promise = this._promiseAt(index);
|
||||
var isPromise = promise instanceof Promise;
|
||||
|
||||
if (isPromise && promise._isMigrated()) {
|
||||
promise._unsetIsMigrated();
|
||||
return async.invoke(this._settlePromiseAt, this, index);
|
||||
}
|
||||
var handler = this._isFulfilled()
|
||||
? this._fulfillmentHandlerAt(index)
|
||||
: this._rejectionHandlerAt(index);
|
||||
|
||||
var carriedStackTrace =
|
||||
this._isCarryingStackTrace() ? this._getCarriedStackTrace() : undefined;
|
||||
var value = this._settledValue;
|
||||
var receiver = this._receiverAt(index);
|
||||
this._clearCallbackDataAtIndex(index);
|
||||
|
||||
if (typeof handler === "function") {
|
||||
if (!isPromise) {
|
||||
handler.call(receiver, value, promise);
|
||||
} else {
|
||||
this._settlePromiseFromHandler(handler, receiver, value, promise);
|
||||
}
|
||||
} else if (receiver instanceof PromiseArray) {
|
||||
if (!receiver._isResolved()) {
|
||||
if (this._isFulfilled()) {
|
||||
receiver._promiseFulfilled(value, promise);
|
||||
}
|
||||
else {
|
||||
receiver._promiseRejected(value, promise);
|
||||
}
|
||||
}
|
||||
} else if (isPromise) {
|
||||
if (this._isFulfilled()) {
|
||||
promise._fulfill(value);
|
||||
} else {
|
||||
promise._reject(value, carriedStackTrace);
|
||||
}
|
||||
}
|
||||
|
||||
if (index >= 4 && (index & 31) === 4)
|
||||
async.invokeLater(this._setLength, this, 0);
|
||||
};
|
||||
|
||||
Promise.prototype._clearCallbackDataAtIndex = function(index) {
|
||||
if (index === 0) {
|
||||
if (!this._isCarryingStackTrace()) {
|
||||
this._fulfillmentHandler0 = undefined;
|
||||
}
|
||||
this._rejectionHandler0 =
|
||||
this._progressHandler0 =
|
||||
this._receiver0 =
|
||||
this._promise0 = undefined;
|
||||
} else {
|
||||
var base = index * 5 - 5;
|
||||
this[base + 3] =
|
||||
this[base + 4] =
|
||||
this[base + 0] =
|
||||
this[base + 1] =
|
||||
this[base + 2] = undefined;
|
||||
}
|
||||
};
|
||||
|
||||
Promise.prototype._isSettlePromisesQueued = function () {
|
||||
return (this._bitField &
|
||||
-1073741824) === -1073741824;
|
||||
};
|
||||
|
||||
Promise.prototype._setSettlePromisesQueued = function () {
|
||||
this._bitField = this._bitField | -1073741824;
|
||||
};
|
||||
|
||||
Promise.prototype._unsetSettlePromisesQueued = function () {
|
||||
this._bitField = this._bitField & (~-1073741824);
|
||||
};
|
||||
|
||||
Promise.prototype._queueSettlePromises = function() {
|
||||
async.settlePromises(this);
|
||||
this._setSettlePromisesQueued();
|
||||
};
|
||||
|
||||
Promise.prototype._fulfillUnchecked = function (value) {
|
||||
if (value === this) {
|
||||
var err = makeSelfResolutionError();
|
||||
this._attachExtraTrace(err);
|
||||
return this._rejectUnchecked(err, undefined);
|
||||
}
|
||||
this._setFulfilled();
|
||||
this._settledValue = value;
|
||||
this._cleanValues();
|
||||
|
||||
if (this._length() > 0) {
|
||||
this._queueSettlePromises();
|
||||
}
|
||||
};
|
||||
|
||||
Promise.prototype._rejectUncheckedCheckError = function (reason) {
|
||||
var trace = util.ensureErrorObject(reason);
|
||||
this._rejectUnchecked(reason, trace === reason ? undefined : trace);
|
||||
};
|
||||
|
||||
Promise.prototype._rejectUnchecked = function (reason, trace) {
|
||||
if (reason === this) {
|
||||
var err = makeSelfResolutionError();
|
||||
this._attachExtraTrace(err);
|
||||
return this._rejectUnchecked(err);
|
||||
}
|
||||
this._setRejected();
|
||||
this._settledValue = reason;
|
||||
this._cleanValues();
|
||||
|
||||
if (this._isFinal()) {
|
||||
async.throwLater(function(e) {
|
||||
if ("stack" in e) {
|
||||
async.invokeFirst(
|
||||
CapturedTrace.unhandledRejection, undefined, e);
|
||||
}
|
||||
throw e;
|
||||
}, trace === undefined ? reason : trace);
|
||||
return;
|
||||
}
|
||||
|
||||
if (trace !== undefined && trace !== reason) {
|
||||
this._setCarriedStackTrace(trace);
|
||||
}
|
||||
|
||||
if (this._length() > 0) {
|
||||
this._queueSettlePromises();
|
||||
} else {
|
||||
this._ensurePossibleRejectionHandled();
|
||||
}
|
||||
};
|
||||
|
||||
Promise.prototype._settlePromises = function () {
|
||||
this._unsetSettlePromisesQueued();
|
||||
var len = this._length();
|
||||
for (var i = 0; i < len; i++) {
|
||||
this._settlePromiseAt(i);
|
||||
}
|
||||
};
|
||||
|
||||
util.notEnumerableProp(Promise,
|
||||
"_makeSelfResolutionError",
|
||||
makeSelfResolutionError);
|
||||
|
||||
require("./progress.js")(Promise, PromiseArray);
|
||||
require("./method.js")(Promise, INTERNAL, tryConvertToPromise, apiRejection);
|
||||
require("./bind.js")(Promise, INTERNAL, tryConvertToPromise);
|
||||
require("./finally.js")(Promise, NEXT_FILTER, tryConvertToPromise);
|
||||
require("./direct_resolve.js")(Promise);
|
||||
require("./synchronous_inspection.js")(Promise);
|
||||
require("./join.js")(Promise, PromiseArray, tryConvertToPromise, INTERNAL);
|
||||
Promise.Promise = Promise;
|
||||
require('./map.js')(Promise, PromiseArray, apiRejection, tryConvertToPromise, INTERNAL);
|
||||
require('./cancel.js')(Promise);
|
||||
require('./using.js')(Promise, apiRejection, tryConvertToPromise, createContext);
|
||||
require('./generators.js')(Promise, apiRejection, INTERNAL, tryConvertToPromise);
|
||||
require('./nodeify.js')(Promise);
|
||||
require('./call_get.js')(Promise);
|
||||
require('./props.js')(Promise, PromiseArray, tryConvertToPromise, apiRejection);
|
||||
require('./race.js')(Promise, INTERNAL, tryConvertToPromise, apiRejection);
|
||||
require('./reduce.js')(Promise, PromiseArray, apiRejection, tryConvertToPromise, INTERNAL);
|
||||
require('./settle.js')(Promise, PromiseArray);
|
||||
require('./some.js')(Promise, PromiseArray, apiRejection);
|
||||
require('./promisify.js')(Promise, INTERNAL);
|
||||
require('./any.js')(Promise);
|
||||
require('./each.js')(Promise, INTERNAL);
|
||||
require('./timers.js')(Promise, INTERNAL);
|
||||
require('./filter.js')(Promise, INTERNAL);
|
||||
|
||||
util.toFastProperties(Promise);
|
||||
util.toFastProperties(Promise.prototype);
|
||||
function fillTypes(value) {
|
||||
var p = new Promise(INTERNAL);
|
||||
p._fulfillmentHandler0 = value;
|
||||
p._rejectionHandler0 = value;
|
||||
p._progressHandler0 = value;
|
||||
p._promise0 = value;
|
||||
p._receiver0 = value;
|
||||
p._settledValue = value;
|
||||
}
|
||||
// Complete slack tracking, opt out of field-type tracking and
|
||||
// stabilize map
|
||||
fillTypes({a: 1});
|
||||
fillTypes({b: 2});
|
||||
fillTypes({c: 3});
|
||||
fillTypes(1);
|
||||
fillTypes(function(){});
|
||||
fillTypes(undefined);
|
||||
fillTypes(false);
|
||||
fillTypes(new Promise(INTERNAL));
|
||||
CapturedTrace.setBounds(async.firstLineError, util.lastLineError);
|
||||
return Promise;
|
||||
|
||||
};
|
||||
142
node_modules/bluebird/js/main/promise_array.js
generated
vendored
142
node_modules/bluebird/js/main/promise_array.js
generated
vendored
@ -1,142 +0,0 @@
|
||||
"use strict";
|
||||
module.exports = function(Promise, INTERNAL, tryConvertToPromise,
|
||||
apiRejection) {
|
||||
var util = require("./util.js");
|
||||
var isArray = util.isArray;
|
||||
|
||||
function toResolutionValue(val) {
|
||||
switch(val) {
|
||||
case -2: return [];
|
||||
case -3: return {};
|
||||
}
|
||||
}
|
||||
|
||||
function PromiseArray(values) {
|
||||
var promise = this._promise = new Promise(INTERNAL);
|
||||
var parent;
|
||||
if (values instanceof Promise) {
|
||||
parent = values;
|
||||
promise._propagateFrom(parent, 1 | 4);
|
||||
}
|
||||
this._values = values;
|
||||
this._length = 0;
|
||||
this._totalResolved = 0;
|
||||
this._init(undefined, -2);
|
||||
}
|
||||
PromiseArray.prototype.length = function () {
|
||||
return this._length;
|
||||
};
|
||||
|
||||
PromiseArray.prototype.promise = function () {
|
||||
return this._promise;
|
||||
};
|
||||
|
||||
PromiseArray.prototype._init = function init(_, resolveValueIfEmpty) {
|
||||
var values = tryConvertToPromise(this._values, this._promise);
|
||||
if (values instanceof Promise) {
|
||||
values = values._target();
|
||||
this._values = values;
|
||||
if (values._isFulfilled()) {
|
||||
values = values._value();
|
||||
if (!isArray(values)) {
|
||||
var err = new Promise.TypeError("expecting an array, a promise or a thenable\u000a\u000a See http://goo.gl/s8MMhc\u000a");
|
||||
this.__hardReject__(err);
|
||||
return;
|
||||
}
|
||||
} else if (values._isPending()) {
|
||||
values._then(
|
||||
init,
|
||||
this._reject,
|
||||
undefined,
|
||||
this,
|
||||
resolveValueIfEmpty
|
||||
);
|
||||
return;
|
||||
} else {
|
||||
this._reject(values._reason());
|
||||
return;
|
||||
}
|
||||
} else if (!isArray(values)) {
|
||||
this._promise._reject(apiRejection("expecting an array, a promise or a thenable\u000a\u000a See http://goo.gl/s8MMhc\u000a")._reason());
|
||||
return;
|
||||
}
|
||||
|
||||
if (values.length === 0) {
|
||||
if (resolveValueIfEmpty === -5) {
|
||||
this._resolveEmptyArray();
|
||||
}
|
||||
else {
|
||||
this._resolve(toResolutionValue(resolveValueIfEmpty));
|
||||
}
|
||||
return;
|
||||
}
|
||||
var len = this.getActualLength(values.length);
|
||||
this._length = len;
|
||||
this._values = this.shouldCopyValues() ? new Array(len) : this._values;
|
||||
var promise = this._promise;
|
||||
for (var i = 0; i < len; ++i) {
|
||||
var isResolved = this._isResolved();
|
||||
var maybePromise = tryConvertToPromise(values[i], promise);
|
||||
if (maybePromise instanceof Promise) {
|
||||
maybePromise = maybePromise._target();
|
||||
if (isResolved) {
|
||||
maybePromise._ignoreRejections();
|
||||
} else if (maybePromise._isPending()) {
|
||||
maybePromise._proxyPromiseArray(this, i);
|
||||
} else if (maybePromise._isFulfilled()) {
|
||||
this._promiseFulfilled(maybePromise._value(), i);
|
||||
} else {
|
||||
this._promiseRejected(maybePromise._reason(), i);
|
||||
}
|
||||
} else if (!isResolved) {
|
||||
this._promiseFulfilled(maybePromise, i);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
PromiseArray.prototype._isResolved = function () {
|
||||
return this._values === null;
|
||||
};
|
||||
|
||||
PromiseArray.prototype._resolve = function (value) {
|
||||
this._values = null;
|
||||
this._promise._fulfill(value);
|
||||
};
|
||||
|
||||
PromiseArray.prototype.__hardReject__ =
|
||||
PromiseArray.prototype._reject = function (reason) {
|
||||
this._values = null;
|
||||
this._promise._rejectCallback(reason, false, true);
|
||||
};
|
||||
|
||||
PromiseArray.prototype._promiseProgressed = function (progressValue, index) {
|
||||
this._promise._progress({
|
||||
index: index,
|
||||
value: progressValue
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
PromiseArray.prototype._promiseFulfilled = function (value, index) {
|
||||
this._values[index] = value;
|
||||
var totalResolved = ++this._totalResolved;
|
||||
if (totalResolved >= this._length) {
|
||||
this._resolve(this._values);
|
||||
}
|
||||
};
|
||||
|
||||
PromiseArray.prototype._promiseRejected = function (reason, index) {
|
||||
this._totalResolved++;
|
||||
this._reject(reason);
|
||||
};
|
||||
|
||||
PromiseArray.prototype.shouldCopyValues = function () {
|
||||
return true;
|
||||
};
|
||||
|
||||
PromiseArray.prototype.getActualLength = function (len) {
|
||||
return len;
|
||||
};
|
||||
|
||||
return PromiseArray;
|
||||
};
|
||||
123
node_modules/bluebird/js/main/promise_resolver.js
generated
vendored
123
node_modules/bluebird/js/main/promise_resolver.js
generated
vendored
@ -1,123 +0,0 @@
|
||||
"use strict";
|
||||
var util = require("./util.js");
|
||||
var maybeWrapAsError = util.maybeWrapAsError;
|
||||
var errors = require("./errors.js");
|
||||
var TimeoutError = errors.TimeoutError;
|
||||
var OperationalError = errors.OperationalError;
|
||||
var haveGetters = util.haveGetters;
|
||||
var es5 = require("./es5.js");
|
||||
|
||||
function isUntypedError(obj) {
|
||||
return obj instanceof Error &&
|
||||
es5.getPrototypeOf(obj) === Error.prototype;
|
||||
}
|
||||
|
||||
var rErrorKey = /^(?:name|message|stack|cause)$/;
|
||||
function wrapAsOperationalError(obj) {
|
||||
var ret;
|
||||
if (isUntypedError(obj)) {
|
||||
ret = new OperationalError(obj);
|
||||
ret.name = obj.name;
|
||||
ret.message = obj.message;
|
||||
ret.stack = obj.stack;
|
||||
var keys = es5.keys(obj);
|
||||
for (var i = 0; i < keys.length; ++i) {
|
||||
var key = keys[i];
|
||||
if (!rErrorKey.test(key)) {
|
||||
ret[key] = obj[key];
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
util.markAsOriginatingFromRejection(obj);
|
||||
return obj;
|
||||
}
|
||||
|
||||
function nodebackForPromise(promise) {
|
||||
return function(err, value) {
|
||||
if (promise === null) return;
|
||||
|
||||
if (err) {
|
||||
var wrapped = wrapAsOperationalError(maybeWrapAsError(err));
|
||||
promise._attachExtraTrace(wrapped);
|
||||
promise._reject(wrapped);
|
||||
} else if (arguments.length > 2) {
|
||||
var $_len = arguments.length;var args = new Array($_len - 1); for(var $_i = 1; $_i < $_len; ++$_i) {args[$_i - 1] = arguments[$_i];}
|
||||
promise._fulfill(args);
|
||||
} else {
|
||||
promise._fulfill(value);
|
||||
}
|
||||
|
||||
promise = null;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
var PromiseResolver;
|
||||
if (!haveGetters) {
|
||||
PromiseResolver = function (promise) {
|
||||
this.promise = promise;
|
||||
this.asCallback = nodebackForPromise(promise);
|
||||
this.callback = this.asCallback;
|
||||
};
|
||||
}
|
||||
else {
|
||||
PromiseResolver = function (promise) {
|
||||
this.promise = promise;
|
||||
};
|
||||
}
|
||||
if (haveGetters) {
|
||||
var prop = {
|
||||
get: function() {
|
||||
return nodebackForPromise(this.promise);
|
||||
}
|
||||
};
|
||||
es5.defineProperty(PromiseResolver.prototype, "asCallback", prop);
|
||||
es5.defineProperty(PromiseResolver.prototype, "callback", prop);
|
||||
}
|
||||
|
||||
PromiseResolver._nodebackForPromise = nodebackForPromise;
|
||||
|
||||
PromiseResolver.prototype.toString = function () {
|
||||
return "[object PromiseResolver]";
|
||||
};
|
||||
|
||||
PromiseResolver.prototype.resolve =
|
||||
PromiseResolver.prototype.fulfill = function (value) {
|
||||
if (!(this instanceof PromiseResolver)) {
|
||||
throw new TypeError("Illegal invocation, resolver resolve/reject must be called within a resolver context. Consider using the promise constructor instead.\u000a\u000a See http://goo.gl/sdkXL9\u000a");
|
||||
}
|
||||
this.promise._resolveCallback(value);
|
||||
};
|
||||
|
||||
PromiseResolver.prototype.reject = function (reason) {
|
||||
if (!(this instanceof PromiseResolver)) {
|
||||
throw new TypeError("Illegal invocation, resolver resolve/reject must be called within a resolver context. Consider using the promise constructor instead.\u000a\u000a See http://goo.gl/sdkXL9\u000a");
|
||||
}
|
||||
this.promise._rejectCallback(reason);
|
||||
};
|
||||
|
||||
PromiseResolver.prototype.progress = function (value) {
|
||||
if (!(this instanceof PromiseResolver)) {
|
||||
throw new TypeError("Illegal invocation, resolver resolve/reject must be called within a resolver context. Consider using the promise constructor instead.\u000a\u000a See http://goo.gl/sdkXL9\u000a");
|
||||
}
|
||||
this.promise._progress(value);
|
||||
};
|
||||
|
||||
PromiseResolver.prototype.cancel = function (err) {
|
||||
this.promise.cancel(err);
|
||||
};
|
||||
|
||||
PromiseResolver.prototype.timeout = function () {
|
||||
this.reject(new TimeoutError("timeout"));
|
||||
};
|
||||
|
||||
PromiseResolver.prototype.isResolved = function () {
|
||||
return this.promise.isResolved();
|
||||
};
|
||||
|
||||
PromiseResolver.prototype.toJSON = function () {
|
||||
return this.promise.toJSON();
|
||||
};
|
||||
|
||||
module.exports = PromiseResolver;
|
||||
302
node_modules/bluebird/js/main/promisify.js
generated
vendored
302
node_modules/bluebird/js/main/promisify.js
generated
vendored
@ -1,302 +0,0 @@
|
||||
"use strict";
|
||||
module.exports = function(Promise, INTERNAL) {
|
||||
var THIS = {};
|
||||
var util = require("./util.js");
|
||||
var nodebackForPromise = require("./promise_resolver.js")
|
||||
._nodebackForPromise;
|
||||
var withAppended = util.withAppended;
|
||||
var maybeWrapAsError = util.maybeWrapAsError;
|
||||
var canEvaluate = util.canEvaluate;
|
||||
var TypeError = require("./errors").TypeError;
|
||||
var defaultSuffix = "Async";
|
||||
var defaultPromisified = {__isPromisified__: true};
|
||||
var noCopyProps = [
|
||||
"arity", "length",
|
||||
"name",
|
||||
"arguments",
|
||||
"caller",
|
||||
"callee",
|
||||
"prototype",
|
||||
"__isPromisified__"
|
||||
];
|
||||
var noCopyPropsPattern = new RegExp("^(?:" + noCopyProps.join("|") + ")$");
|
||||
|
||||
var defaultFilter = function(name) {
|
||||
return util.isIdentifier(name) &&
|
||||
name.charAt(0) !== "_" &&
|
||||
name !== "constructor";
|
||||
};
|
||||
|
||||
function propsFilter(key) {
|
||||
return !noCopyPropsPattern.test(key);
|
||||
}
|
||||
|
||||
function isPromisified(fn) {
|
||||
try {
|
||||
return fn.__isPromisified__ === true;
|
||||
}
|
||||
catch (e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function hasPromisified(obj, key, suffix) {
|
||||
var val = util.getDataPropertyOrDefault(obj, key + suffix,
|
||||
defaultPromisified);
|
||||
return val ? isPromisified(val) : false;
|
||||
}
|
||||
function checkValid(ret, suffix, suffixRegexp) {
|
||||
for (var i = 0; i < ret.length; i += 2) {
|
||||
var key = ret[i];
|
||||
if (suffixRegexp.test(key)) {
|
||||
var keyWithoutAsyncSuffix = key.replace(suffixRegexp, "");
|
||||
for (var j = 0; j < ret.length; j += 2) {
|
||||
if (ret[j] === keyWithoutAsyncSuffix) {
|
||||
throw new TypeError("Cannot promisify an API that has normal methods with '%s'-suffix\u000a\u000a See http://goo.gl/iWrZbw\u000a"
|
||||
.replace("%s", suffix));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function promisifiableMethods(obj, suffix, suffixRegexp, filter) {
|
||||
var keys = util.inheritedDataKeys(obj);
|
||||
var ret = [];
|
||||
for (var i = 0; i < keys.length; ++i) {
|
||||
var key = keys[i];
|
||||
var value = obj[key];
|
||||
var passesDefaultFilter = filter === defaultFilter
|
||||
? true : defaultFilter(key, value, obj);
|
||||
if (typeof value === "function" &&
|
||||
!isPromisified(value) &&
|
||||
!hasPromisified(obj, key, suffix) &&
|
||||
filter(key, value, obj, passesDefaultFilter)) {
|
||||
ret.push(key, value);
|
||||
}
|
||||
}
|
||||
checkValid(ret, suffix, suffixRegexp);
|
||||
return ret;
|
||||
}
|
||||
|
||||
var escapeIdentRegex = function(str) {
|
||||
return str.replace(/([$])/, "\\$");
|
||||
};
|
||||
|
||||
var makeNodePromisifiedEval;
|
||||
if (!false) {
|
||||
var switchCaseArgumentOrder = function(likelyArgumentCount) {
|
||||
var ret = [likelyArgumentCount];
|
||||
var min = Math.max(0, likelyArgumentCount - 1 - 3);
|
||||
for(var i = likelyArgumentCount - 1; i >= min; --i) {
|
||||
ret.push(i);
|
||||
}
|
||||
for(var i = likelyArgumentCount + 1; i <= 3; ++i) {
|
||||
ret.push(i);
|
||||
}
|
||||
return ret;
|
||||
};
|
||||
|
||||
var argumentSequence = function(argumentCount) {
|
||||
return util.filledRange(argumentCount, "_arg", "");
|
||||
};
|
||||
|
||||
var parameterDeclaration = function(parameterCount) {
|
||||
return util.filledRange(
|
||||
Math.max(parameterCount, 3), "_arg", "");
|
||||
};
|
||||
|
||||
var parameterCount = function(fn) {
|
||||
if (typeof fn.length === "number") {
|
||||
return Math.max(Math.min(fn.length, 1023 + 1), 0);
|
||||
}
|
||||
return 0;
|
||||
};
|
||||
|
||||
makeNodePromisifiedEval =
|
||||
function(callback, receiver, originalName, fn) {
|
||||
var newParameterCount = Math.max(0, parameterCount(fn) - 1);
|
||||
var argumentOrder = switchCaseArgumentOrder(newParameterCount);
|
||||
var shouldProxyThis = typeof callback === "string" || receiver === THIS;
|
||||
|
||||
function generateCallForArgumentCount(count) {
|
||||
var args = argumentSequence(count).join(", ");
|
||||
var comma = count > 0 ? ", " : "";
|
||||
var ret;
|
||||
if (shouldProxyThis) {
|
||||
ret = "ret = callback.call(this, {{args}}, nodeback); break;\n";
|
||||
} else {
|
||||
ret = receiver === undefined
|
||||
? "ret = callback({{args}}, nodeback); break;\n"
|
||||
: "ret = callback.call(receiver, {{args}}, nodeback); break;\n";
|
||||
}
|
||||
return ret.replace("{{args}}", args).replace(", ", comma);
|
||||
}
|
||||
|
||||
function generateArgumentSwitchCase() {
|
||||
var ret = "";
|
||||
for (var i = 0; i < argumentOrder.length; ++i) {
|
||||
ret += "case " + argumentOrder[i] +":" +
|
||||
generateCallForArgumentCount(argumentOrder[i]);
|
||||
}
|
||||
|
||||
ret += " \n\
|
||||
default: \n\
|
||||
var args = new Array(len + 1); \n\
|
||||
var i = 0; \n\
|
||||
for (var i = 0; i < len; ++i) { \n\
|
||||
args[i] = arguments[i]; \n\
|
||||
} \n\
|
||||
args[i] = nodeback; \n\
|
||||
[CodeForCall] \n\
|
||||
break; \n\
|
||||
".replace("[CodeForCall]", (shouldProxyThis
|
||||
? "ret = callback.apply(this, args);\n"
|
||||
: "ret = callback.apply(receiver, args);\n"));
|
||||
return ret;
|
||||
}
|
||||
|
||||
var getFunctionCode = typeof callback === "string"
|
||||
? ("this != null ? this['"+callback+"'] : fn")
|
||||
: "fn";
|
||||
|
||||
return new Function("Promise",
|
||||
"fn",
|
||||
"receiver",
|
||||
"withAppended",
|
||||
"maybeWrapAsError",
|
||||
"nodebackForPromise",
|
||||
"tryCatch",
|
||||
"errorObj",
|
||||
"notEnumerableProp",
|
||||
"INTERNAL","'use strict'; \n\
|
||||
var ret = function (Parameters) { \n\
|
||||
'use strict'; \n\
|
||||
var len = arguments.length; \n\
|
||||
var promise = new Promise(INTERNAL); \n\
|
||||
promise._captureStackTrace(); \n\
|
||||
var nodeback = nodebackForPromise(promise); \n\
|
||||
var ret; \n\
|
||||
var callback = tryCatch([GetFunctionCode]); \n\
|
||||
switch(len) { \n\
|
||||
[CodeForSwitchCase] \n\
|
||||
} \n\
|
||||
if (ret === errorObj) { \n\
|
||||
promise._rejectCallback(maybeWrapAsError(ret.e), true, true);\n\
|
||||
} \n\
|
||||
return promise; \n\
|
||||
}; \n\
|
||||
notEnumerableProp(ret, '__isPromisified__', true); \n\
|
||||
return ret; \n\
|
||||
"
|
||||
.replace("Parameters", parameterDeclaration(newParameterCount))
|
||||
.replace("[CodeForSwitchCase]", generateArgumentSwitchCase())
|
||||
.replace("[GetFunctionCode]", getFunctionCode))(
|
||||
Promise,
|
||||
fn,
|
||||
receiver,
|
||||
withAppended,
|
||||
maybeWrapAsError,
|
||||
nodebackForPromise,
|
||||
util.tryCatch,
|
||||
util.errorObj,
|
||||
util.notEnumerableProp,
|
||||
INTERNAL
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
function makeNodePromisifiedClosure(callback, receiver, _, fn) {
|
||||
var defaultThis = (function() {return this;})();
|
||||
var method = callback;
|
||||
if (typeof method === "string") {
|
||||
callback = fn;
|
||||
}
|
||||
function promisified() {
|
||||
var _receiver = receiver;
|
||||
if (receiver === THIS) _receiver = this;
|
||||
var promise = new Promise(INTERNAL);
|
||||
promise._captureStackTrace();
|
||||
var cb = typeof method === "string" && this !== defaultThis
|
||||
? this[method] : callback;
|
||||
var fn = nodebackForPromise(promise);
|
||||
try {
|
||||
cb.apply(_receiver, withAppended(arguments, fn));
|
||||
} catch(e) {
|
||||
promise._rejectCallback(maybeWrapAsError(e), true, true);
|
||||
}
|
||||
return promise;
|
||||
}
|
||||
util.notEnumerableProp(promisified, "__isPromisified__", true);
|
||||
return promisified;
|
||||
}
|
||||
|
||||
var makeNodePromisified = canEvaluate
|
||||
? makeNodePromisifiedEval
|
||||
: makeNodePromisifiedClosure;
|
||||
|
||||
function promisifyAll(obj, suffix, filter, promisifier) {
|
||||
var suffixRegexp = new RegExp(escapeIdentRegex(suffix) + "$");
|
||||
var methods =
|
||||
promisifiableMethods(obj, suffix, suffixRegexp, filter);
|
||||
|
||||
for (var i = 0, len = methods.length; i < len; i+= 2) {
|
||||
var key = methods[i];
|
||||
var fn = methods[i+1];
|
||||
var promisifiedKey = key + suffix;
|
||||
obj[promisifiedKey] = promisifier === makeNodePromisified
|
||||
? makeNodePromisified(key, THIS, key, fn, suffix)
|
||||
: promisifier(fn, function() {
|
||||
return makeNodePromisified(key, THIS, key, fn, suffix);
|
||||
});
|
||||
}
|
||||
util.toFastProperties(obj);
|
||||
return obj;
|
||||
}
|
||||
|
||||
function promisify(callback, receiver) {
|
||||
return makeNodePromisified(callback, receiver, undefined, callback);
|
||||
}
|
||||
|
||||
Promise.promisify = function (fn, receiver) {
|
||||
if (typeof fn !== "function") {
|
||||
throw new TypeError("fn must be a function\u000a\u000a See http://goo.gl/916lJJ\u000a");
|
||||
}
|
||||
if (isPromisified(fn)) {
|
||||
return fn;
|
||||
}
|
||||
var ret = promisify(fn, arguments.length < 2 ? THIS : receiver);
|
||||
util.copyDescriptors(fn, ret, propsFilter);
|
||||
return ret;
|
||||
};
|
||||
|
||||
Promise.promisifyAll = function (target, options) {
|
||||
if (typeof target !== "function" && typeof target !== "object") {
|
||||
throw new TypeError("the target of promisifyAll must be an object or a function\u000a\u000a See http://goo.gl/9ITlV0\u000a");
|
||||
}
|
||||
options = Object(options);
|
||||
var suffix = options.suffix;
|
||||
if (typeof suffix !== "string") suffix = defaultSuffix;
|
||||
var filter = options.filter;
|
||||
if (typeof filter !== "function") filter = defaultFilter;
|
||||
var promisifier = options.promisifier;
|
||||
if (typeof promisifier !== "function") promisifier = makeNodePromisified;
|
||||
|
||||
if (!util.isIdentifier(suffix)) {
|
||||
throw new RangeError("suffix must be a valid identifier\u000a\u000a See http://goo.gl/8FZo5V\u000a");
|
||||
}
|
||||
|
||||
var keys = util.inheritedDataKeys(target);
|
||||
for (var i = 0; i < keys.length; ++i) {
|
||||
var value = target[keys[i]];
|
||||
if (keys[i] !== "constructor" &&
|
||||
util.isClass(value)) {
|
||||
promisifyAll(value.prototype, suffix, filter, promisifier);
|
||||
promisifyAll(value, suffix, filter, promisifier);
|
||||
}
|
||||
}
|
||||
|
||||
return promisifyAll(target, suffix, filter, promisifier);
|
||||
};
|
||||
};
|
||||
|
||||
79
node_modules/bluebird/js/main/props.js
generated
vendored
79
node_modules/bluebird/js/main/props.js
generated
vendored
@ -1,79 +0,0 @@
|
||||
"use strict";
|
||||
module.exports = function(
|
||||
Promise, PromiseArray, tryConvertToPromise, apiRejection) {
|
||||
var util = require("./util.js");
|
||||
var isObject = util.isObject;
|
||||
var es5 = require("./es5.js");
|
||||
|
||||
function PropertiesPromiseArray(obj) {
|
||||
var keys = es5.keys(obj);
|
||||
var len = keys.length;
|
||||
var values = new Array(len * 2);
|
||||
for (var i = 0; i < len; ++i) {
|
||||
var key = keys[i];
|
||||
values[i] = obj[key];
|
||||
values[i + len] = key;
|
||||
}
|
||||
this.constructor$(values);
|
||||
}
|
||||
util.inherits(PropertiesPromiseArray, PromiseArray);
|
||||
|
||||
PropertiesPromiseArray.prototype._init = function () {
|
||||
this._init$(undefined, -3) ;
|
||||
};
|
||||
|
||||
PropertiesPromiseArray.prototype._promiseFulfilled = function (value, index) {
|
||||
this._values[index] = value;
|
||||
var totalResolved = ++this._totalResolved;
|
||||
if (totalResolved >= this._length) {
|
||||
var val = {};
|
||||
var keyOffset = this.length();
|
||||
for (var i = 0, len = this.length(); i < len; ++i) {
|
||||
val[this._values[i + keyOffset]] = this._values[i];
|
||||
}
|
||||
this._resolve(val);
|
||||
}
|
||||
};
|
||||
|
||||
PropertiesPromiseArray.prototype._promiseProgressed = function (value, index) {
|
||||
this._promise._progress({
|
||||
key: this._values[index + this.length()],
|
||||
value: value
|
||||
});
|
||||
};
|
||||
|
||||
PropertiesPromiseArray.prototype.shouldCopyValues = function () {
|
||||
return false;
|
||||
};
|
||||
|
||||
PropertiesPromiseArray.prototype.getActualLength = function (len) {
|
||||
return len >> 1;
|
||||
};
|
||||
|
||||
function props(promises) {
|
||||
var ret;
|
||||
var castValue = tryConvertToPromise(promises);
|
||||
|
||||
if (!isObject(castValue)) {
|
||||
return apiRejection("cannot await properties of a non-object\u000a\u000a See http://goo.gl/OsFKC8\u000a");
|
||||
} else if (castValue instanceof Promise) {
|
||||
ret = castValue._then(
|
||||
Promise.props, undefined, undefined, undefined, undefined);
|
||||
} else {
|
||||
ret = new PropertiesPromiseArray(castValue).promise();
|
||||
}
|
||||
|
||||
if (castValue instanceof Promise) {
|
||||
ret._propagateFrom(castValue, 4);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
Promise.prototype.props = function () {
|
||||
return props(this);
|
||||
};
|
||||
|
||||
Promise.props = function (promises) {
|
||||
return props(promises);
|
||||
};
|
||||
};
|
||||
90
node_modules/bluebird/js/main/queue.js
generated
vendored
90
node_modules/bluebird/js/main/queue.js
generated
vendored
@ -1,90 +0,0 @@
|
||||
"use strict";
|
||||
function arrayMove(src, srcIndex, dst, dstIndex, len) {
|
||||
for (var j = 0; j < len; ++j) {
|
||||
dst[j + dstIndex] = src[j + srcIndex];
|
||||
src[j + srcIndex] = void 0;
|
||||
}
|
||||
}
|
||||
|
||||
function Queue(capacity) {
|
||||
this._capacity = capacity;
|
||||
this._length = 0;
|
||||
this._front = 0;
|
||||
}
|
||||
|
||||
Queue.prototype._willBeOverCapacity = function (size) {
|
||||
return this._capacity < size;
|
||||
};
|
||||
|
||||
Queue.prototype._pushOne = function (arg) {
|
||||
var length = this.length();
|
||||
this._checkCapacity(length + 1);
|
||||
var i = (this._front + length) & (this._capacity - 1);
|
||||
this[i] = arg;
|
||||
this._length = length + 1;
|
||||
};
|
||||
|
||||
Queue.prototype._unshiftOne = function(value) {
|
||||
var capacity = this._capacity;
|
||||
this._checkCapacity(this.length() + 1);
|
||||
var front = this._front;
|
||||
var i = (((( front - 1 ) &
|
||||
( capacity - 1) ) ^ capacity ) - capacity );
|
||||
this[i] = value;
|
||||
this._front = i;
|
||||
this._length = this.length() + 1;
|
||||
};
|
||||
|
||||
Queue.prototype.unshift = function(fn, receiver, arg) {
|
||||
this._unshiftOne(arg);
|
||||
this._unshiftOne(receiver);
|
||||
this._unshiftOne(fn);
|
||||
};
|
||||
|
||||
Queue.prototype.push = function (fn, receiver, arg) {
|
||||
var length = this.length() + 3;
|
||||
if (this._willBeOverCapacity(length)) {
|
||||
this._pushOne(fn);
|
||||
this._pushOne(receiver);
|
||||
this._pushOne(arg);
|
||||
return;
|
||||
}
|
||||
var j = this._front + length - 3;
|
||||
this._checkCapacity(length);
|
||||
var wrapMask = this._capacity - 1;
|
||||
this[(j + 0) & wrapMask] = fn;
|
||||
this[(j + 1) & wrapMask] = receiver;
|
||||
this[(j + 2) & wrapMask] = arg;
|
||||
this._length = length;
|
||||
};
|
||||
|
||||
Queue.prototype.shift = function () {
|
||||
var front = this._front,
|
||||
ret = this[front];
|
||||
|
||||
this[front] = undefined;
|
||||
this._front = (front + 1) & (this._capacity - 1);
|
||||
this._length--;
|
||||
return ret;
|
||||
};
|
||||
|
||||
Queue.prototype.length = function () {
|
||||
return this._length;
|
||||
};
|
||||
|
||||
Queue.prototype._checkCapacity = function (size) {
|
||||
if (this._capacity < size) {
|
||||
this._resizeTo(this._capacity << 1);
|
||||
}
|
||||
};
|
||||
|
||||
Queue.prototype._resizeTo = function (capacity) {
|
||||
var oldCapacity = this._capacity;
|
||||
this._capacity = capacity;
|
||||
var front = this._front;
|
||||
var length = this._length;
|
||||
var moveItemsCount = (front + length) & (oldCapacity - 1);
|
||||
arrayMove(this, 0, this, oldCapacity, moveItemsCount);
|
||||
};
|
||||
|
||||
module.exports = Queue;
|
||||
47
node_modules/bluebird/js/main/race.js
generated
vendored
47
node_modules/bluebird/js/main/race.js
generated
vendored
@ -1,47 +0,0 @@
|
||||
"use strict";
|
||||
module.exports = function(
|
||||
Promise, INTERNAL, tryConvertToPromise, apiRejection) {
|
||||
var isArray = require("./util.js").isArray;
|
||||
|
||||
var raceLater = function (promise) {
|
||||
return promise.then(function(array) {
|
||||
return race(array, promise);
|
||||
});
|
||||
};
|
||||
|
||||
function race(promises, parent) {
|
||||
var maybePromise = tryConvertToPromise(promises);
|
||||
|
||||
if (maybePromise instanceof Promise) {
|
||||
return raceLater(maybePromise);
|
||||
} else if (!isArray(promises)) {
|
||||
return apiRejection("expecting an array, a promise or a thenable\u000a\u000a See http://goo.gl/s8MMhc\u000a");
|
||||
}
|
||||
|
||||
var ret = new Promise(INTERNAL);
|
||||
if (parent !== undefined) {
|
||||
ret._propagateFrom(parent, 4 | 1);
|
||||
}
|
||||
var fulfill = ret._fulfill;
|
||||
var reject = ret._reject;
|
||||
for (var i = 0, len = promises.length; i < len; ++i) {
|
||||
var val = promises[i];
|
||||
|
||||
if (val === undefined && !(i in promises)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Promise.cast(val)._then(fulfill, reject, undefined, ret, null);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
Promise.race = function (promises) {
|
||||
return race(promises, undefined);
|
||||
};
|
||||
|
||||
Promise.prototype.race = function () {
|
||||
return race(this, undefined);
|
||||
};
|
||||
|
||||
};
|
||||
148
node_modules/bluebird/js/main/reduce.js
generated
vendored
148
node_modules/bluebird/js/main/reduce.js
generated
vendored
@ -1,148 +0,0 @@
|
||||
"use strict";
|
||||
module.exports = function(Promise,
|
||||
PromiseArray,
|
||||
apiRejection,
|
||||
tryConvertToPromise,
|
||||
INTERNAL) {
|
||||
var getDomain = Promise._getDomain;
|
||||
var async = require("./async.js");
|
||||
var util = require("./util.js");
|
||||
var tryCatch = util.tryCatch;
|
||||
var errorObj = util.errorObj;
|
||||
function ReductionPromiseArray(promises, fn, accum, _each) {
|
||||
this.constructor$(promises);
|
||||
this._promise._captureStackTrace();
|
||||
this._preservedValues = _each === INTERNAL ? [] : null;
|
||||
this._zerothIsAccum = (accum === undefined);
|
||||
this._gotAccum = false;
|
||||
this._reducingIndex = (this._zerothIsAccum ? 1 : 0);
|
||||
this._valuesPhase = undefined;
|
||||
var maybePromise = tryConvertToPromise(accum, this._promise);
|
||||
var rejected = false;
|
||||
var isPromise = maybePromise instanceof Promise;
|
||||
if (isPromise) {
|
||||
maybePromise = maybePromise._target();
|
||||
if (maybePromise._isPending()) {
|
||||
maybePromise._proxyPromiseArray(this, -1);
|
||||
} else if (maybePromise._isFulfilled()) {
|
||||
accum = maybePromise._value();
|
||||
this._gotAccum = true;
|
||||
} else {
|
||||
this._reject(maybePromise._reason());
|
||||
rejected = true;
|
||||
}
|
||||
}
|
||||
if (!(isPromise || this._zerothIsAccum)) this._gotAccum = true;
|
||||
var domain = getDomain();
|
||||
this._callback = domain === null ? fn : domain.bind(fn);
|
||||
this._accum = accum;
|
||||
if (!rejected) async.invoke(init, this, undefined);
|
||||
}
|
||||
function init() {
|
||||
this._init$(undefined, -5);
|
||||
}
|
||||
util.inherits(ReductionPromiseArray, PromiseArray);
|
||||
|
||||
ReductionPromiseArray.prototype._init = function () {};
|
||||
|
||||
ReductionPromiseArray.prototype._resolveEmptyArray = function () {
|
||||
if (this._gotAccum || this._zerothIsAccum) {
|
||||
this._resolve(this._preservedValues !== null
|
||||
? [] : this._accum);
|
||||
}
|
||||
};
|
||||
|
||||
ReductionPromiseArray.prototype._promiseFulfilled = function (value, index) {
|
||||
var values = this._values;
|
||||
values[index] = value;
|
||||
var length = this.length();
|
||||
var preservedValues = this._preservedValues;
|
||||
var isEach = preservedValues !== null;
|
||||
var gotAccum = this._gotAccum;
|
||||
var valuesPhase = this._valuesPhase;
|
||||
var valuesPhaseIndex;
|
||||
if (!valuesPhase) {
|
||||
valuesPhase = this._valuesPhase = new Array(length);
|
||||
for (valuesPhaseIndex=0; valuesPhaseIndex<length; ++valuesPhaseIndex) {
|
||||
valuesPhase[valuesPhaseIndex] = 0;
|
||||
}
|
||||
}
|
||||
valuesPhaseIndex = valuesPhase[index];
|
||||
|
||||
if (index === 0 && this._zerothIsAccum) {
|
||||
this._accum = value;
|
||||
this._gotAccum = gotAccum = true;
|
||||
valuesPhase[index] = ((valuesPhaseIndex === 0)
|
||||
? 1 : 2);
|
||||
} else if (index === -1) {
|
||||
this._accum = value;
|
||||
this._gotAccum = gotAccum = true;
|
||||
} else {
|
||||
if (valuesPhaseIndex === 0) {
|
||||
valuesPhase[index] = 1;
|
||||
} else {
|
||||
valuesPhase[index] = 2;
|
||||
this._accum = value;
|
||||
}
|
||||
}
|
||||
if (!gotAccum) return;
|
||||
|
||||
var callback = this._callback;
|
||||
var receiver = this._promise._boundValue();
|
||||
var ret;
|
||||
|
||||
for (var i = this._reducingIndex; i < length; ++i) {
|
||||
valuesPhaseIndex = valuesPhase[i];
|
||||
if (valuesPhaseIndex === 2) {
|
||||
this._reducingIndex = i + 1;
|
||||
continue;
|
||||
}
|
||||
if (valuesPhaseIndex !== 1) return;
|
||||
value = values[i];
|
||||
this._promise._pushContext();
|
||||
if (isEach) {
|
||||
preservedValues.push(value);
|
||||
ret = tryCatch(callback).call(receiver, value, i, length);
|
||||
}
|
||||
else {
|
||||
ret = tryCatch(callback)
|
||||
.call(receiver, this._accum, value, i, length);
|
||||
}
|
||||
this._promise._popContext();
|
||||
|
||||
if (ret === errorObj) return this._reject(ret.e);
|
||||
|
||||
var maybePromise = tryConvertToPromise(ret, this._promise);
|
||||
if (maybePromise instanceof Promise) {
|
||||
maybePromise = maybePromise._target();
|
||||
if (maybePromise._isPending()) {
|
||||
valuesPhase[i] = 4;
|
||||
return maybePromise._proxyPromiseArray(this, i);
|
||||
} else if (maybePromise._isFulfilled()) {
|
||||
ret = maybePromise._value();
|
||||
} else {
|
||||
return this._reject(maybePromise._reason());
|
||||
}
|
||||
}
|
||||
|
||||
this._reducingIndex = i + 1;
|
||||
this._accum = ret;
|
||||
}
|
||||
|
||||
this._resolve(isEach ? preservedValues : this._accum);
|
||||
};
|
||||
|
||||
function reduce(promises, fn, initialValue, _each) {
|
||||
if (typeof fn !== "function") return apiRejection("fn must be a function\u000a\u000a See http://goo.gl/916lJJ\u000a");
|
||||
var array = new ReductionPromiseArray(promises, fn, initialValue, _each);
|
||||
return array.promise();
|
||||
}
|
||||
|
||||
Promise.prototype.reduce = function (fn, initialValue) {
|
||||
return reduce(this, fn, initialValue, null);
|
||||
};
|
||||
|
||||
Promise.reduce = function (promises, fn, initialValue, _each) {
|
||||
return reduce(promises, fn, initialValue, _each);
|
||||
};
|
||||
};
|
||||
35
node_modules/bluebird/js/main/schedule.js
generated
vendored
35
node_modules/bluebird/js/main/schedule.js
generated
vendored
@ -1,35 +0,0 @@
|
||||
"use strict";
|
||||
var schedule;
|
||||
var util = require("./util");
|
||||
var noAsyncScheduler = function() {
|
||||
throw new Error("No async scheduler available\u000a\u000a See http://goo.gl/m3OTXk\u000a");
|
||||
};
|
||||
if (util.isNode && typeof MutationObserver === "undefined") {
|
||||
var GlobalSetImmediate = global.setImmediate;
|
||||
var ProcessNextTick = process.nextTick;
|
||||
schedule = util.isRecentNode
|
||||
? function(fn) { GlobalSetImmediate.call(global, fn); }
|
||||
: function(fn) { ProcessNextTick.call(process, fn); };
|
||||
} else if ((typeof MutationObserver !== "undefined") &&
|
||||
!(typeof window !== "undefined" &&
|
||||
window.navigator &&
|
||||
window.navigator.standalone)) {
|
||||
schedule = function(fn) {
|
||||
var div = document.createElement("div");
|
||||
var observer = new MutationObserver(fn);
|
||||
observer.observe(div, {attributes: true});
|
||||
return function() { div.classList.toggle("foo"); };
|
||||
};
|
||||
schedule.isStatic = true;
|
||||
} else if (typeof setImmediate !== "undefined") {
|
||||
schedule = function (fn) {
|
||||
setImmediate(fn);
|
||||
};
|
||||
} else if (typeof setTimeout !== "undefined") {
|
||||
schedule = function (fn) {
|
||||
setTimeout(fn, 0);
|
||||
};
|
||||
} else {
|
||||
schedule = noAsyncScheduler;
|
||||
}
|
||||
module.exports = schedule;
|
||||
40
node_modules/bluebird/js/main/settle.js
generated
vendored
40
node_modules/bluebird/js/main/settle.js
generated
vendored
@ -1,40 +0,0 @@
|
||||
"use strict";
|
||||
module.exports =
|
||||
function(Promise, PromiseArray) {
|
||||
var PromiseInspection = Promise.PromiseInspection;
|
||||
var util = require("./util.js");
|
||||
|
||||
function SettledPromiseArray(values) {
|
||||
this.constructor$(values);
|
||||
}
|
||||
util.inherits(SettledPromiseArray, PromiseArray);
|
||||
|
||||
SettledPromiseArray.prototype._promiseResolved = function (index, inspection) {
|
||||
this._values[index] = inspection;
|
||||
var totalResolved = ++this._totalResolved;
|
||||
if (totalResolved >= this._length) {
|
||||
this._resolve(this._values);
|
||||
}
|
||||
};
|
||||
|
||||
SettledPromiseArray.prototype._promiseFulfilled = function (value, index) {
|
||||
var ret = new PromiseInspection();
|
||||
ret._bitField = 268435456;
|
||||
ret._settledValue = value;
|
||||
this._promiseResolved(index, ret);
|
||||
};
|
||||
SettledPromiseArray.prototype._promiseRejected = function (reason, index) {
|
||||
var ret = new PromiseInspection();
|
||||
ret._bitField = 134217728;
|
||||
ret._settledValue = reason;
|
||||
this._promiseResolved(index, ret);
|
||||
};
|
||||
|
||||
Promise.settle = function (promises) {
|
||||
return new SettledPromiseArray(promises).promise();
|
||||
};
|
||||
|
||||
Promise.prototype.settle = function () {
|
||||
return new SettledPromiseArray(this).promise();
|
||||
};
|
||||
};
|
||||
125
node_modules/bluebird/js/main/some.js
generated
vendored
125
node_modules/bluebird/js/main/some.js
generated
vendored
@ -1,125 +0,0 @@
|
||||
"use strict";
|
||||
module.exports =
|
||||
function(Promise, PromiseArray, apiRejection) {
|
||||
var util = require("./util.js");
|
||||
var RangeError = require("./errors.js").RangeError;
|
||||
var AggregateError = require("./errors.js").AggregateError;
|
||||
var isArray = util.isArray;
|
||||
|
||||
|
||||
function SomePromiseArray(values) {
|
||||
this.constructor$(values);
|
||||
this._howMany = 0;
|
||||
this._unwrap = false;
|
||||
this._initialized = false;
|
||||
}
|
||||
util.inherits(SomePromiseArray, PromiseArray);
|
||||
|
||||
SomePromiseArray.prototype._init = function () {
|
||||
if (!this._initialized) {
|
||||
return;
|
||||
}
|
||||
if (this._howMany === 0) {
|
||||
this._resolve([]);
|
||||
return;
|
||||
}
|
||||
this._init$(undefined, -5);
|
||||
var isArrayResolved = isArray(this._values);
|
||||
if (!this._isResolved() &&
|
||||
isArrayResolved &&
|
||||
this._howMany > this._canPossiblyFulfill()) {
|
||||
this._reject(this._getRangeError(this.length()));
|
||||
}
|
||||
};
|
||||
|
||||
SomePromiseArray.prototype.init = function () {
|
||||
this._initialized = true;
|
||||
this._init();
|
||||
};
|
||||
|
||||
SomePromiseArray.prototype.setUnwrap = function () {
|
||||
this._unwrap = true;
|
||||
};
|
||||
|
||||
SomePromiseArray.prototype.howMany = function () {
|
||||
return this._howMany;
|
||||
};
|
||||
|
||||
SomePromiseArray.prototype.setHowMany = function (count) {
|
||||
this._howMany = count;
|
||||
};
|
||||
|
||||
SomePromiseArray.prototype._promiseFulfilled = function (value) {
|
||||
this._addFulfilled(value);
|
||||
if (this._fulfilled() === this.howMany()) {
|
||||
this._values.length = this.howMany();
|
||||
if (this.howMany() === 1 && this._unwrap) {
|
||||
this._resolve(this._values[0]);
|
||||
} else {
|
||||
this._resolve(this._values);
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
SomePromiseArray.prototype._promiseRejected = function (reason) {
|
||||
this._addRejected(reason);
|
||||
if (this.howMany() > this._canPossiblyFulfill()) {
|
||||
var e = new AggregateError();
|
||||
for (var i = this.length(); i < this._values.length; ++i) {
|
||||
e.push(this._values[i]);
|
||||
}
|
||||
this._reject(e);
|
||||
}
|
||||
};
|
||||
|
||||
SomePromiseArray.prototype._fulfilled = function () {
|
||||
return this._totalResolved;
|
||||
};
|
||||
|
||||
SomePromiseArray.prototype._rejected = function () {
|
||||
return this._values.length - this.length();
|
||||
};
|
||||
|
||||
SomePromiseArray.prototype._addRejected = function (reason) {
|
||||
this._values.push(reason);
|
||||
};
|
||||
|
||||
SomePromiseArray.prototype._addFulfilled = function (value) {
|
||||
this._values[this._totalResolved++] = value;
|
||||
};
|
||||
|
||||
SomePromiseArray.prototype._canPossiblyFulfill = function () {
|
||||
return this.length() - this._rejected();
|
||||
};
|
||||
|
||||
SomePromiseArray.prototype._getRangeError = function (count) {
|
||||
var message = "Input array must contain at least " +
|
||||
this._howMany + " items but contains only " + count + " items";
|
||||
return new RangeError(message);
|
||||
};
|
||||
|
||||
SomePromiseArray.prototype._resolveEmptyArray = function () {
|
||||
this._reject(this._getRangeError(0));
|
||||
};
|
||||
|
||||
function some(promises, howMany) {
|
||||
if ((howMany | 0) !== howMany || howMany < 0) {
|
||||
return apiRejection("expecting a positive integer\u000a\u000a See http://goo.gl/1wAmHx\u000a");
|
||||
}
|
||||
var ret = new SomePromiseArray(promises);
|
||||
var promise = ret.promise();
|
||||
ret.setHowMany(howMany);
|
||||
ret.init();
|
||||
return promise;
|
||||
}
|
||||
|
||||
Promise.some = function (promises, howMany) {
|
||||
return some(promises, howMany);
|
||||
};
|
||||
|
||||
Promise.prototype.some = function (howMany) {
|
||||
return some(this, howMany);
|
||||
};
|
||||
|
||||
Promise._SomePromiseArray = SomePromiseArray;
|
||||
};
|
||||
94
node_modules/bluebird/js/main/synchronous_inspection.js
generated
vendored
94
node_modules/bluebird/js/main/synchronous_inspection.js
generated
vendored
@ -1,94 +0,0 @@
|
||||
"use strict";
|
||||
module.exports = function(Promise) {
|
||||
function PromiseInspection(promise) {
|
||||
if (promise !== undefined) {
|
||||
promise = promise._target();
|
||||
this._bitField = promise._bitField;
|
||||
this._settledValue = promise._settledValue;
|
||||
}
|
||||
else {
|
||||
this._bitField = 0;
|
||||
this._settledValue = undefined;
|
||||
}
|
||||
}
|
||||
|
||||
PromiseInspection.prototype.value = function () {
|
||||
if (!this.isFulfilled()) {
|
||||
throw new TypeError("cannot get fulfillment value of a non-fulfilled promise\u000a\u000a See http://goo.gl/hc1DLj\u000a");
|
||||
}
|
||||
return this._settledValue;
|
||||
};
|
||||
|
||||
PromiseInspection.prototype.error =
|
||||
PromiseInspection.prototype.reason = function () {
|
||||
if (!this.isRejected()) {
|
||||
throw new TypeError("cannot get rejection reason of a non-rejected promise\u000a\u000a See http://goo.gl/hPuiwB\u000a");
|
||||
}
|
||||
return this._settledValue;
|
||||
};
|
||||
|
||||
PromiseInspection.prototype.isFulfilled =
|
||||
Promise.prototype._isFulfilled = function () {
|
||||
return (this._bitField & 268435456) > 0;
|
||||
};
|
||||
|
||||
PromiseInspection.prototype.isRejected =
|
||||
Promise.prototype._isRejected = function () {
|
||||
return (this._bitField & 134217728) > 0;
|
||||
};
|
||||
|
||||
PromiseInspection.prototype.isPending =
|
||||
Promise.prototype._isPending = function () {
|
||||
return (this._bitField & 402653184) === 0;
|
||||
};
|
||||
|
||||
PromiseInspection.prototype.isResolved =
|
||||
Promise.prototype._isResolved = function () {
|
||||
return (this._bitField & 402653184) > 0;
|
||||
};
|
||||
|
||||
Promise.prototype.isPending = function() {
|
||||
return this._target()._isPending();
|
||||
};
|
||||
|
||||
Promise.prototype.isRejected = function() {
|
||||
return this._target()._isRejected();
|
||||
};
|
||||
|
||||
Promise.prototype.isFulfilled = function() {
|
||||
return this._target()._isFulfilled();
|
||||
};
|
||||
|
||||
Promise.prototype.isResolved = function() {
|
||||
return this._target()._isResolved();
|
||||
};
|
||||
|
||||
Promise.prototype._value = function() {
|
||||
return this._settledValue;
|
||||
};
|
||||
|
||||
Promise.prototype._reason = function() {
|
||||
this._unsetRejectionIsUnhandled();
|
||||
return this._settledValue;
|
||||
};
|
||||
|
||||
Promise.prototype.value = function() {
|
||||
var target = this._target();
|
||||
if (!target.isFulfilled()) {
|
||||
throw new TypeError("cannot get fulfillment value of a non-fulfilled promise\u000a\u000a See http://goo.gl/hc1DLj\u000a");
|
||||
}
|
||||
return target._settledValue;
|
||||
};
|
||||
|
||||
Promise.prototype.reason = function() {
|
||||
var target = this._target();
|
||||
if (!target.isRejected()) {
|
||||
throw new TypeError("cannot get rejection reason of a non-rejected promise\u000a\u000a See http://goo.gl/hPuiwB\u000a");
|
||||
}
|
||||
target._unsetRejectionIsUnhandled();
|
||||
return target._settledValue;
|
||||
};
|
||||
|
||||
|
||||
Promise.PromiseInspection = PromiseInspection;
|
||||
};
|
||||
84
node_modules/bluebird/js/main/thenables.js
generated
vendored
84
node_modules/bluebird/js/main/thenables.js
generated
vendored
@ -1,84 +0,0 @@
|
||||
"use strict";
|
||||
module.exports = function(Promise, INTERNAL) {
|
||||
var util = require("./util.js");
|
||||
var errorObj = util.errorObj;
|
||||
var isObject = util.isObject;
|
||||
|
||||
function tryConvertToPromise(obj, context) {
|
||||
if (isObject(obj)) {
|
||||
if (obj instanceof Promise) {
|
||||
return obj;
|
||||
}
|
||||
else if (isAnyBluebirdPromise(obj)) {
|
||||
var ret = new Promise(INTERNAL);
|
||||
obj._then(
|
||||
ret._fulfillUnchecked,
|
||||
ret._rejectUncheckedCheckError,
|
||||
ret._progressUnchecked,
|
||||
ret,
|
||||
null
|
||||
);
|
||||
return ret;
|
||||
}
|
||||
var then = util.tryCatch(getThen)(obj);
|
||||
if (then === errorObj) {
|
||||
if (context) context._pushContext();
|
||||
var ret = Promise.reject(then.e);
|
||||
if (context) context._popContext();
|
||||
return ret;
|
||||
} else if (typeof then === "function") {
|
||||
return doThenable(obj, then, context);
|
||||
}
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
|
||||
function getThen(obj) {
|
||||
return obj.then;
|
||||
}
|
||||
|
||||
var hasProp = {}.hasOwnProperty;
|
||||
function isAnyBluebirdPromise(obj) {
|
||||
return hasProp.call(obj, "_promise0");
|
||||
}
|
||||
|
||||
function doThenable(x, then, context) {
|
||||
var promise = new Promise(INTERNAL);
|
||||
var ret = promise;
|
||||
if (context) context._pushContext();
|
||||
promise._captureStackTrace();
|
||||
if (context) context._popContext();
|
||||
var synchronous = true;
|
||||
var result = util.tryCatch(then).call(x,
|
||||
resolveFromThenable,
|
||||
rejectFromThenable,
|
||||
progressFromThenable);
|
||||
synchronous = false;
|
||||
if (promise && result === errorObj) {
|
||||
promise._rejectCallback(result.e, true, true);
|
||||
promise = null;
|
||||
}
|
||||
|
||||
function resolveFromThenable(value) {
|
||||
if (!promise) return;
|
||||
promise._resolveCallback(value);
|
||||
promise = null;
|
||||
}
|
||||
|
||||
function rejectFromThenable(reason) {
|
||||
if (!promise) return;
|
||||
promise._rejectCallback(reason, synchronous, true);
|
||||
promise = null;
|
||||
}
|
||||
|
||||
function progressFromThenable(value) {
|
||||
if (!promise) return;
|
||||
if (typeof promise._progress === "function") {
|
||||
promise._progress(value);
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
return tryConvertToPromise;
|
||||
};
|
||||
58
node_modules/bluebird/js/main/timers.js
generated
vendored
58
node_modules/bluebird/js/main/timers.js
generated
vendored
@ -1,58 +0,0 @@
|
||||
"use strict";
|
||||
module.exports = function(Promise, INTERNAL) {
|
||||
var util = require("./util.js");
|
||||
var TimeoutError = Promise.TimeoutError;
|
||||
|
||||
var afterTimeout = function (promise, message) {
|
||||
if (!promise.isPending()) return;
|
||||
if (typeof message !== "string") {
|
||||
message = "operation timed out";
|
||||
}
|
||||
var err = new TimeoutError(message);
|
||||
util.markAsOriginatingFromRejection(err);
|
||||
promise._attachExtraTrace(err);
|
||||
promise._cancel(err);
|
||||
};
|
||||
|
||||
var afterValue = function(value) { return delay(+this).thenReturn(value); };
|
||||
var delay = Promise.delay = function (value, ms) {
|
||||
if (ms === undefined) {
|
||||
ms = value;
|
||||
value = undefined;
|
||||
var ret = new Promise(INTERNAL);
|
||||
setTimeout(function() { ret._fulfill(); }, ms);
|
||||
return ret;
|
||||
}
|
||||
ms = +ms;
|
||||
return Promise.resolve(value)._then(afterValue, null, null, ms, undefined);
|
||||
};
|
||||
|
||||
Promise.prototype.delay = function (ms) {
|
||||
return delay(this, ms);
|
||||
};
|
||||
|
||||
function successClear(value) {
|
||||
var handle = this;
|
||||
if (handle instanceof Number) handle = +handle;
|
||||
clearTimeout(handle);
|
||||
return value;
|
||||
}
|
||||
|
||||
function failureClear(reason) {
|
||||
var handle = this;
|
||||
if (handle instanceof Number) handle = +handle;
|
||||
clearTimeout(handle);
|
||||
throw reason;
|
||||
}
|
||||
|
||||
Promise.prototype.timeout = function (ms, message) {
|
||||
ms = +ms;
|
||||
var ret = this.then().cancellable();
|
||||
ret._cancellationParent = this;
|
||||
var handle = setTimeout(function timeoutTimeout() {
|
||||
afterTimeout(ret, message);
|
||||
}, ms);
|
||||
return ret._then(successClear, failureClear, undefined, handle, undefined);
|
||||
};
|
||||
|
||||
};
|
||||
202
node_modules/bluebird/js/main/using.js
generated
vendored
202
node_modules/bluebird/js/main/using.js
generated
vendored
@ -1,202 +0,0 @@
|
||||
"use strict";
|
||||
module.exports = function (Promise, apiRejection, tryConvertToPromise,
|
||||
createContext) {
|
||||
var TypeError = require("./errors.js").TypeError;
|
||||
var inherits = require("./util.js").inherits;
|
||||
var PromiseInspection = Promise.PromiseInspection;
|
||||
|
||||
function inspectionMapper(inspections) {
|
||||
var len = inspections.length;
|
||||
for (var i = 0; i < len; ++i) {
|
||||
var inspection = inspections[i];
|
||||
if (inspection.isRejected()) {
|
||||
return Promise.reject(inspection.error());
|
||||
}
|
||||
inspections[i] = inspection._settledValue;
|
||||
}
|
||||
return inspections;
|
||||
}
|
||||
|
||||
function thrower(e) {
|
||||
setTimeout(function(){throw e;}, 0);
|
||||
}
|
||||
|
||||
function castPreservingDisposable(thenable) {
|
||||
var maybePromise = tryConvertToPromise(thenable);
|
||||
if (maybePromise !== thenable &&
|
||||
typeof thenable._isDisposable === "function" &&
|
||||
typeof thenable._getDisposer === "function" &&
|
||||
thenable._isDisposable()) {
|
||||
maybePromise._setDisposable(thenable._getDisposer());
|
||||
}
|
||||
return maybePromise;
|
||||
}
|
||||
function dispose(resources, inspection) {
|
||||
var i = 0;
|
||||
var len = resources.length;
|
||||
var ret = Promise.defer();
|
||||
function iterator() {
|
||||
if (i >= len) return ret.resolve();
|
||||
var maybePromise = castPreservingDisposable(resources[i++]);
|
||||
if (maybePromise instanceof Promise &&
|
||||
maybePromise._isDisposable()) {
|
||||
try {
|
||||
maybePromise = tryConvertToPromise(
|
||||
maybePromise._getDisposer().tryDispose(inspection),
|
||||
resources.promise);
|
||||
} catch (e) {
|
||||
return thrower(e);
|
||||
}
|
||||
if (maybePromise instanceof Promise) {
|
||||
return maybePromise._then(iterator, thrower,
|
||||
null, null, null);
|
||||
}
|
||||
}
|
||||
iterator();
|
||||
}
|
||||
iterator();
|
||||
return ret.promise;
|
||||
}
|
||||
|
||||
function disposerSuccess(value) {
|
||||
var inspection = new PromiseInspection();
|
||||
inspection._settledValue = value;
|
||||
inspection._bitField = 268435456;
|
||||
return dispose(this, inspection).thenReturn(value);
|
||||
}
|
||||
|
||||
function disposerFail(reason) {
|
||||
var inspection = new PromiseInspection();
|
||||
inspection._settledValue = reason;
|
||||
inspection._bitField = 134217728;
|
||||
return dispose(this, inspection).thenThrow(reason);
|
||||
}
|
||||
|
||||
function Disposer(data, promise, context) {
|
||||
this._data = data;
|
||||
this._promise = promise;
|
||||
this._context = context;
|
||||
}
|
||||
|
||||
Disposer.prototype.data = function () {
|
||||
return this._data;
|
||||
};
|
||||
|
||||
Disposer.prototype.promise = function () {
|
||||
return this._promise;
|
||||
};
|
||||
|
||||
Disposer.prototype.resource = function () {
|
||||
if (this.promise().isFulfilled()) {
|
||||
return this.promise().value();
|
||||
}
|
||||
return null;
|
||||
};
|
||||
|
||||
Disposer.prototype.tryDispose = function(inspection) {
|
||||
var resource = this.resource();
|
||||
var context = this._context;
|
||||
if (context !== undefined) context._pushContext();
|
||||
var ret = resource !== null
|
||||
? this.doDispose(resource, inspection) : null;
|
||||
if (context !== undefined) context._popContext();
|
||||
this._promise._unsetDisposable();
|
||||
this._data = null;
|
||||
return ret;
|
||||
};
|
||||
|
||||
Disposer.isDisposer = function (d) {
|
||||
return (d != null &&
|
||||
typeof d.resource === "function" &&
|
||||
typeof d.tryDispose === "function");
|
||||
};
|
||||
|
||||
function FunctionDisposer(fn, promise, context) {
|
||||
this.constructor$(fn, promise, context);
|
||||
}
|
||||
inherits(FunctionDisposer, Disposer);
|
||||
|
||||
FunctionDisposer.prototype.doDispose = function (resource, inspection) {
|
||||
var fn = this.data();
|
||||
return fn.call(resource, resource, inspection);
|
||||
};
|
||||
|
||||
function maybeUnwrapDisposer(value) {
|
||||
if (Disposer.isDisposer(value)) {
|
||||
this.resources[this.index]._setDisposable(value);
|
||||
return value.promise();
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
Promise.using = function () {
|
||||
var len = arguments.length;
|
||||
if (len < 2) return apiRejection(
|
||||
"you must pass at least 2 arguments to Promise.using");
|
||||
var fn = arguments[len - 1];
|
||||
if (typeof fn !== "function") return apiRejection("fn must be a function\u000a\u000a See http://goo.gl/916lJJ\u000a");
|
||||
len--;
|
||||
var resources = new Array(len);
|
||||
for (var i = 0; i < len; ++i) {
|
||||
var resource = arguments[i];
|
||||
if (Disposer.isDisposer(resource)) {
|
||||
var disposer = resource;
|
||||
resource = resource.promise();
|
||||
resource._setDisposable(disposer);
|
||||
} else {
|
||||
var maybePromise = tryConvertToPromise(resource);
|
||||
if (maybePromise instanceof Promise) {
|
||||
resource =
|
||||
maybePromise._then(maybeUnwrapDisposer, null, null, {
|
||||
resources: resources,
|
||||
index: i
|
||||
}, undefined);
|
||||
}
|
||||
}
|
||||
resources[i] = resource;
|
||||
}
|
||||
|
||||
var promise = Promise.settle(resources)
|
||||
.then(inspectionMapper)
|
||||
.then(function(vals) {
|
||||
promise._pushContext();
|
||||
var ret;
|
||||
try {
|
||||
ret = fn.apply(undefined, vals);
|
||||
} finally {
|
||||
promise._popContext();
|
||||
}
|
||||
return ret;
|
||||
})
|
||||
._then(
|
||||
disposerSuccess, disposerFail, undefined, resources, undefined);
|
||||
resources.promise = promise;
|
||||
return promise;
|
||||
};
|
||||
|
||||
Promise.prototype._setDisposable = function (disposer) {
|
||||
this._bitField = this._bitField | 262144;
|
||||
this._disposer = disposer;
|
||||
};
|
||||
|
||||
Promise.prototype._isDisposable = function () {
|
||||
return (this._bitField & 262144) > 0;
|
||||
};
|
||||
|
||||
Promise.prototype._getDisposer = function () {
|
||||
return this._disposer;
|
||||
};
|
||||
|
||||
Promise.prototype._unsetDisposable = function () {
|
||||
this._bitField = this._bitField & (~262144);
|
||||
this._disposer = undefined;
|
||||
};
|
||||
|
||||
Promise.prototype.disposer = function (fn) {
|
||||
if (typeof fn === "function") {
|
||||
return new FunctionDisposer(fn, this, createContext());
|
||||
}
|
||||
throw new TypeError();
|
||||
};
|
||||
|
||||
};
|
||||
321
node_modules/bluebird/js/main/util.js
generated
vendored
321
node_modules/bluebird/js/main/util.js
generated
vendored
@ -1,321 +0,0 @@
|
||||
"use strict";
|
||||
var es5 = require("./es5.js");
|
||||
var canEvaluate = typeof navigator == "undefined";
|
||||
var haveGetters = (function(){
|
||||
try {
|
||||
var o = {};
|
||||
es5.defineProperty(o, "f", {
|
||||
get: function () {
|
||||
return 3;
|
||||
}
|
||||
});
|
||||
return o.f === 3;
|
||||
}
|
||||
catch (e) {
|
||||
return false;
|
||||
}
|
||||
|
||||
})();
|
||||
|
||||
var errorObj = {e: {}};
|
||||
var tryCatchTarget;
|
||||
function tryCatcher() {
|
||||
try {
|
||||
var target = tryCatchTarget;
|
||||
tryCatchTarget = null;
|
||||
return target.apply(this, arguments);
|
||||
} catch (e) {
|
||||
errorObj.e = e;
|
||||
return errorObj;
|
||||
}
|
||||
}
|
||||
function tryCatch(fn) {
|
||||
tryCatchTarget = fn;
|
||||
return tryCatcher;
|
||||
}
|
||||
|
||||
var inherits = function(Child, Parent) {
|
||||
var hasProp = {}.hasOwnProperty;
|
||||
|
||||
function T() {
|
||||
this.constructor = Child;
|
||||
this.constructor$ = Parent;
|
||||
for (var propertyName in Parent.prototype) {
|
||||
if (hasProp.call(Parent.prototype, propertyName) &&
|
||||
propertyName.charAt(propertyName.length-1) !== "$"
|
||||
) {
|
||||
this[propertyName + "$"] = Parent.prototype[propertyName];
|
||||
}
|
||||
}
|
||||
}
|
||||
T.prototype = Parent.prototype;
|
||||
Child.prototype = new T();
|
||||
return Child.prototype;
|
||||
};
|
||||
|
||||
|
||||
function isPrimitive(val) {
|
||||
return val == null || val === true || val === false ||
|
||||
typeof val === "string" || typeof val === "number";
|
||||
|
||||
}
|
||||
|
||||
function isObject(value) {
|
||||
return !isPrimitive(value);
|
||||
}
|
||||
|
||||
function maybeWrapAsError(maybeError) {
|
||||
if (!isPrimitive(maybeError)) return maybeError;
|
||||
|
||||
return new Error(safeToString(maybeError));
|
||||
}
|
||||
|
||||
function withAppended(target, appendee) {
|
||||
var len = target.length;
|
||||
var ret = new Array(len + 1);
|
||||
var i;
|
||||
for (i = 0; i < len; ++i) {
|
||||
ret[i] = target[i];
|
||||
}
|
||||
ret[i] = appendee;
|
||||
return ret;
|
||||
}
|
||||
|
||||
function getDataPropertyOrDefault(obj, key, defaultValue) {
|
||||
if (es5.isES5) {
|
||||
var desc = Object.getOwnPropertyDescriptor(obj, key);
|
||||
|
||||
if (desc != null) {
|
||||
return desc.get == null && desc.set == null
|
||||
? desc.value
|
||||
: defaultValue;
|
||||
}
|
||||
} else {
|
||||
return {}.hasOwnProperty.call(obj, key) ? obj[key] : undefined;
|
||||
}
|
||||
}
|
||||
|
||||
function notEnumerableProp(obj, name, value) {
|
||||
if (isPrimitive(obj)) return obj;
|
||||
var descriptor = {
|
||||
value: value,
|
||||
configurable: true,
|
||||
enumerable: false,
|
||||
writable: true
|
||||
};
|
||||
es5.defineProperty(obj, name, descriptor);
|
||||
return obj;
|
||||
}
|
||||
|
||||
function thrower(r) {
|
||||
throw r;
|
||||
}
|
||||
|
||||
var inheritedDataKeys = (function() {
|
||||
var excludedPrototypes = [
|
||||
Array.prototype,
|
||||
Object.prototype,
|
||||
Function.prototype
|
||||
];
|
||||
|
||||
var isExcludedProto = function(val) {
|
||||
for (var i = 0; i < excludedPrototypes.length; ++i) {
|
||||
if (excludedPrototypes[i] === val) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
if (es5.isES5) {
|
||||
var getKeys = Object.getOwnPropertyNames;
|
||||
return function(obj) {
|
||||
var ret = [];
|
||||
var visitedKeys = Object.create(null);
|
||||
while (obj != null && !isExcludedProto(obj)) {
|
||||
var keys;
|
||||
try {
|
||||
keys = getKeys(obj);
|
||||
} catch (e) {
|
||||
return ret;
|
||||
}
|
||||
for (var i = 0; i < keys.length; ++i) {
|
||||
var key = keys[i];
|
||||
if (visitedKeys[key]) continue;
|
||||
visitedKeys[key] = true;
|
||||
var desc = Object.getOwnPropertyDescriptor(obj, key);
|
||||
if (desc != null && desc.get == null && desc.set == null) {
|
||||
ret.push(key);
|
||||
}
|
||||
}
|
||||
obj = es5.getPrototypeOf(obj);
|
||||
}
|
||||
return ret;
|
||||
};
|
||||
} else {
|
||||
var hasProp = {}.hasOwnProperty;
|
||||
return function(obj) {
|
||||
if (isExcludedProto(obj)) return [];
|
||||
var ret = [];
|
||||
|
||||
/*jshint forin:false */
|
||||
enumeration: for (var key in obj) {
|
||||
if (hasProp.call(obj, key)) {
|
||||
ret.push(key);
|
||||
} else {
|
||||
for (var i = 0; i < excludedPrototypes.length; ++i) {
|
||||
if (hasProp.call(excludedPrototypes[i], key)) {
|
||||
continue enumeration;
|
||||
}
|
||||
}
|
||||
ret.push(key);
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
};
|
||||
}
|
||||
|
||||
})();
|
||||
|
||||
var thisAssignmentPattern = /this\s*\.\s*\S+\s*=/;
|
||||
function isClass(fn) {
|
||||
try {
|
||||
if (typeof fn === "function") {
|
||||
var keys = es5.names(fn.prototype);
|
||||
|
||||
var hasMethods = es5.isES5 && keys.length > 1;
|
||||
var hasMethodsOtherThanConstructor = keys.length > 0 &&
|
||||
!(keys.length === 1 && keys[0] === "constructor");
|
||||
var hasThisAssignmentAndStaticMethods =
|
||||
thisAssignmentPattern.test(fn + "") && es5.names(fn).length > 0;
|
||||
|
||||
if (hasMethods || hasMethodsOtherThanConstructor ||
|
||||
hasThisAssignmentAndStaticMethods) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
} catch (e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function toFastProperties(obj) {
|
||||
/*jshint -W027,-W055,-W031*/
|
||||
function f() {}
|
||||
f.prototype = obj;
|
||||
var l = 8;
|
||||
while (l--) new f();
|
||||
return obj;
|
||||
eval(obj);
|
||||
}
|
||||
|
||||
var rident = /^[a-z$_][a-z$_0-9]*$/i;
|
||||
function isIdentifier(str) {
|
||||
return rident.test(str);
|
||||
}
|
||||
|
||||
function filledRange(count, prefix, suffix) {
|
||||
var ret = new Array(count);
|
||||
for(var i = 0; i < count; ++i) {
|
||||
ret[i] = prefix + i + suffix;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
function safeToString(obj) {
|
||||
try {
|
||||
return obj + "";
|
||||
} catch (e) {
|
||||
return "[no string representation]";
|
||||
}
|
||||
}
|
||||
|
||||
function markAsOriginatingFromRejection(e) {
|
||||
try {
|
||||
notEnumerableProp(e, "isOperational", true);
|
||||
}
|
||||
catch(ignore) {}
|
||||
}
|
||||
|
||||
function originatesFromRejection(e) {
|
||||
if (e == null) return false;
|
||||
return ((e instanceof Error["__BluebirdErrorTypes__"].OperationalError) ||
|
||||
e["isOperational"] === true);
|
||||
}
|
||||
|
||||
function canAttachTrace(obj) {
|
||||
return obj instanceof Error && es5.propertyIsWritable(obj, "stack");
|
||||
}
|
||||
|
||||
var ensureErrorObject = (function() {
|
||||
if (!("stack" in new Error())) {
|
||||
return function(value) {
|
||||
if (canAttachTrace(value)) return value;
|
||||
try {throw new Error(safeToString(value));}
|
||||
catch(err) {return err;}
|
||||
};
|
||||
} else {
|
||||
return function(value) {
|
||||
if (canAttachTrace(value)) return value;
|
||||
return new Error(safeToString(value));
|
||||
};
|
||||
}
|
||||
})();
|
||||
|
||||
function classString(obj) {
|
||||
return {}.toString.call(obj);
|
||||
}
|
||||
|
||||
function copyDescriptors(from, to, filter) {
|
||||
var keys = es5.names(from);
|
||||
for (var i = 0; i < keys.length; ++i) {
|
||||
var key = keys[i];
|
||||
if (filter(key)) {
|
||||
try {
|
||||
es5.defineProperty(to, key, es5.getDescriptor(from, key));
|
||||
} catch (ignore) {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var ret = {
|
||||
isClass: isClass,
|
||||
isIdentifier: isIdentifier,
|
||||
inheritedDataKeys: inheritedDataKeys,
|
||||
getDataPropertyOrDefault: getDataPropertyOrDefault,
|
||||
thrower: thrower,
|
||||
isArray: es5.isArray,
|
||||
haveGetters: haveGetters,
|
||||
notEnumerableProp: notEnumerableProp,
|
||||
isPrimitive: isPrimitive,
|
||||
isObject: isObject,
|
||||
canEvaluate: canEvaluate,
|
||||
errorObj: errorObj,
|
||||
tryCatch: tryCatch,
|
||||
inherits: inherits,
|
||||
withAppended: withAppended,
|
||||
maybeWrapAsError: maybeWrapAsError,
|
||||
toFastProperties: toFastProperties,
|
||||
filledRange: filledRange,
|
||||
toString: safeToString,
|
||||
canAttachTrace: canAttachTrace,
|
||||
ensureErrorObject: ensureErrorObject,
|
||||
originatesFromRejection: originatesFromRejection,
|
||||
markAsOriginatingFromRejection: markAsOriginatingFromRejection,
|
||||
classString: classString,
|
||||
copyDescriptors: copyDescriptors,
|
||||
hasDevTools: typeof chrome !== "undefined" && chrome &&
|
||||
typeof chrome.loadTimes === "function",
|
||||
isNode: typeof process !== "undefined" &&
|
||||
classString(process).toLowerCase() === "[object process]"
|
||||
};
|
||||
ret.isRecentNode = ret.isNode && (function() {
|
||||
var version = process.versions.node.split(".").map(Number);
|
||||
return (version[0] === 0 && version[1] > 10) || (version[0] > 0);
|
||||
})();
|
||||
|
||||
if (ret.isNode) ret.toFastProperties(process);
|
||||
|
||||
try {throw new Error(); } catch (e) {ret.lastLineError = e;}
|
||||
module.exports = ret;
|
||||
99
node_modules/bluebird/package.json
generated
vendored
99
node_modules/bluebird/package.json
generated
vendored
@ -1,99 +0,0 @@
|
||||
{
|
||||
"name": "bluebird",
|
||||
"description": "Full featured Promises/A+ implementation with exceptionally good performance",
|
||||
"version": "2.9.34",
|
||||
"keywords": [
|
||||
"promise",
|
||||
"performance",
|
||||
"promises",
|
||||
"promises-a",
|
||||
"promises-aplus",
|
||||
"async",
|
||||
"await",
|
||||
"deferred",
|
||||
"deferreds",
|
||||
"future",
|
||||
"flow control",
|
||||
"dsl",
|
||||
"fluent interface",
|
||||
"parallel",
|
||||
"thread",
|
||||
"concurrency"
|
||||
],
|
||||
"scripts": {
|
||||
"lint": "node scripts/jshint.js",
|
||||
"test": "node tools/test.js",
|
||||
"istanbul": "istanbul",
|
||||
"prepublish": "node tools/build.js --no-debug --main --zalgo --browser --minify"
|
||||
},
|
||||
"homepage": "https://github.com/petkaantonov/bluebird",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/petkaantonov/bluebird.git"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "http://github.com/petkaantonov/bluebird/issues"
|
||||
},
|
||||
"license": "MIT",
|
||||
"author": {
|
||||
"name": "Petka Antonov",
|
||||
"email": "petka_antonov@hotmail.com",
|
||||
"url": "http://github.com/petkaantonov/"
|
||||
},
|
||||
"devDependencies": {
|
||||
"acorn": "~0.6.0",
|
||||
"baconjs": "^0.7.43",
|
||||
"bluebird": "^2.9.2",
|
||||
"body-parser": "^1.10.2",
|
||||
"browserify": "^8.1.1",
|
||||
"cli-table": "~0.3.1",
|
||||
"co": "^4.2.0",
|
||||
"cross-spawn": "^0.2.3",
|
||||
"glob": "^4.3.2",
|
||||
"grunt-saucelabs": "~8.4.1",
|
||||
"highland": "^2.3.0",
|
||||
"istanbul": "^0.3.5",
|
||||
"jshint": "^2.6.0",
|
||||
"jshint-stylish": "~0.2.0",
|
||||
"mkdirp": "~0.5.0",
|
||||
"mocha": "~2.1",
|
||||
"open": "~0.0.5",
|
||||
"optimist": "~0.6.1",
|
||||
"rimraf": "~2.2.6",
|
||||
"rx": "^2.3.25",
|
||||
"serve-static": "^1.7.1",
|
||||
"sinon": "~1.7.3",
|
||||
"uglify-js": "~2.4.16",
|
||||
"kefir": "^2.4.1"
|
||||
},
|
||||
"main": "./js/main/bluebird.js",
|
||||
"browser": "./js/browser/bluebird.js",
|
||||
"files": [
|
||||
"js/browser",
|
||||
"js/main",
|
||||
"js/zalgo",
|
||||
"zalgo.js"
|
||||
],
|
||||
"gitHead": "386ba4f7d588693e5d675290a6b7fade08e0d626",
|
||||
"_id": "bluebird@2.9.34",
|
||||
"_shasum": "2f7b4ec80216328a9fddebdf69c8d4942feff7d8",
|
||||
"_from": "bluebird@>=2.9.34 <2.10.0",
|
||||
"_npmVersion": "2.11.1",
|
||||
"_nodeVersion": "2.3.0",
|
||||
"_npmUser": {
|
||||
"name": "esailija",
|
||||
"email": "petka_antonov@hotmail.com"
|
||||
},
|
||||
"maintainers": [
|
||||
{
|
||||
"name": "esailija",
|
||||
"email": "petka_antonov@hotmail.com"
|
||||
}
|
||||
],
|
||||
"dist": {
|
||||
"shasum": "2f7b4ec80216328a9fddebdf69c8d4942feff7d8",
|
||||
"tarball": "http://registry.npmjs.org/bluebird/-/bluebird-2.9.34.tgz"
|
||||
},
|
||||
"directories": {},
|
||||
"_resolved": "https://registry.npmjs.org/bluebird/-/bluebird-2.9.34.tgz"
|
||||
}
|
||||
84
node_modules/buffer-browserify/buffer_ieee754.js
generated
vendored
84
node_modules/buffer-browserify/buffer_ieee754.js
generated
vendored
@ -1,84 +0,0 @@
|
||||
exports.readIEEE754 = function(buffer, offset, isBE, mLen, nBytes) {
|
||||
var e, m,
|
||||
eLen = nBytes * 8 - mLen - 1,
|
||||
eMax = (1 << eLen) - 1,
|
||||
eBias = eMax >> 1,
|
||||
nBits = -7,
|
||||
i = isBE ? 0 : (nBytes - 1),
|
||||
d = isBE ? 1 : -1,
|
||||
s = buffer[offset + i];
|
||||
|
||||
i += d;
|
||||
|
||||
e = s & ((1 << (-nBits)) - 1);
|
||||
s >>= (-nBits);
|
||||
nBits += eLen;
|
||||
for (; nBits > 0; e = e * 256 + buffer[offset + i], i += d, nBits -= 8);
|
||||
|
||||
m = e & ((1 << (-nBits)) - 1);
|
||||
e >>= (-nBits);
|
||||
nBits += mLen;
|
||||
for (; nBits > 0; m = m * 256 + buffer[offset + i], i += d, nBits -= 8);
|
||||
|
||||
if (e === 0) {
|
||||
e = 1 - eBias;
|
||||
} else if (e === eMax) {
|
||||
return m ? NaN : ((s ? -1 : 1) * Infinity);
|
||||
} else {
|
||||
m = m + Math.pow(2, mLen);
|
||||
e = e - eBias;
|
||||
}
|
||||
return (s ? -1 : 1) * m * Math.pow(2, e - mLen);
|
||||
};
|
||||
|
||||
exports.writeIEEE754 = function(buffer, value, offset, isBE, mLen, nBytes) {
|
||||
var e, m, c,
|
||||
eLen = nBytes * 8 - mLen - 1,
|
||||
eMax = (1 << eLen) - 1,
|
||||
eBias = eMax >> 1,
|
||||
rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0),
|
||||
i = isBE ? (nBytes - 1) : 0,
|
||||
d = isBE ? -1 : 1,
|
||||
s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0;
|
||||
|
||||
value = Math.abs(value);
|
||||
|
||||
if (isNaN(value) || value === Infinity) {
|
||||
m = isNaN(value) ? 1 : 0;
|
||||
e = eMax;
|
||||
} else {
|
||||
e = Math.floor(Math.log(value) / Math.LN2);
|
||||
if (value * (c = Math.pow(2, -e)) < 1) {
|
||||
e--;
|
||||
c *= 2;
|
||||
}
|
||||
if (e + eBias >= 1) {
|
||||
value += rt / c;
|
||||
} else {
|
||||
value += rt * Math.pow(2, 1 - eBias);
|
||||
}
|
||||
if (value * c >= 2) {
|
||||
e++;
|
||||
c /= 2;
|
||||
}
|
||||
|
||||
if (e + eBias >= eMax) {
|
||||
m = 0;
|
||||
e = eMax;
|
||||
} else if (e + eBias >= 1) {
|
||||
m = (value * c - 1) * Math.pow(2, mLen);
|
||||
e = e + eBias;
|
||||
} else {
|
||||
m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen);
|
||||
e = 0;
|
||||
}
|
||||
}
|
||||
|
||||
for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8);
|
||||
|
||||
e = (e << mLen) | m;
|
||||
eLen += mLen;
|
||||
for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8);
|
||||
|
||||
buffer[offset + i - d] |= s * 128;
|
||||
};
|
||||
1127
node_modules/buffer-browserify/index.js
generated
vendored
1127
node_modules/buffer-browserify/index.js
generated
vendored
File diff suppressed because it is too large
Load Diff
14
node_modules/buffer-browserify/node_modules/base64-js/README.md
generated
vendored
14
node_modules/buffer-browserify/node_modules/base64-js/README.md
generated
vendored
@ -1,14 +0,0 @@
|
||||
Intro
|
||||
=====
|
||||
|
||||
`base64-js` does basic base64 encoding/decoding in pure JS. Many browsers already have this functionality, but it is for text data, not all-purpose binary data.
|
||||
|
||||
Sometimes encoding/decoding binary data in the browser is useful, and that is what this module does.
|
||||
|
||||
API
|
||||
===
|
||||
|
||||
`base64-js` has two exposed functions, `toByteArray` and `fromByteArray`, which both take a single argument.
|
||||
|
||||
* toByteArray- Takes a base64 string and returns a byte array
|
||||
* fromByteArray- Takes a byte array and returns a base64 string
|
||||
84
node_modules/buffer-browserify/node_modules/base64-js/lib/b64.js
generated
vendored
84
node_modules/buffer-browserify/node_modules/base64-js/lib/b64.js
generated
vendored
@ -1,84 +0,0 @@
|
||||
(function (exports) {
|
||||
'use strict';
|
||||
|
||||
var lookup = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
|
||||
|
||||
function b64ToByteArray(b64) {
|
||||
var i, j, l, tmp, placeHolders, arr;
|
||||
|
||||
if (b64.length % 4 > 0) {
|
||||
throw 'Invalid string. Length must be a multiple of 4';
|
||||
}
|
||||
|
||||
// the number of equal signs (place holders)
|
||||
// if there are two placeholders, than the two characters before it
|
||||
// represent one byte
|
||||
// if there is only one, then the three characters before it represent 2 bytes
|
||||
// this is just a cheap hack to not do indexOf twice
|
||||
placeHolders = b64.indexOf('=');
|
||||
placeHolders = placeHolders > 0 ? b64.length - placeHolders : 0;
|
||||
|
||||
// base64 is 4/3 + up to two characters of the original data
|
||||
arr = [];//new Uint8Array(b64.length * 3 / 4 - placeHolders);
|
||||
|
||||
// if there are placeholders, only get up to the last complete 4 chars
|
||||
l = placeHolders > 0 ? b64.length - 4 : b64.length;
|
||||
|
||||
for (i = 0, j = 0; i < l; i += 4, j += 3) {
|
||||
tmp = (lookup.indexOf(b64[i]) << 18) | (lookup.indexOf(b64[i + 1]) << 12) | (lookup.indexOf(b64[i + 2]) << 6) | lookup.indexOf(b64[i + 3]);
|
||||
arr.push((tmp & 0xFF0000) >> 16);
|
||||
arr.push((tmp & 0xFF00) >> 8);
|
||||
arr.push(tmp & 0xFF);
|
||||
}
|
||||
|
||||
if (placeHolders === 2) {
|
||||
tmp = (lookup.indexOf(b64[i]) << 2) | (lookup.indexOf(b64[i + 1]) >> 4);
|
||||
arr.push(tmp & 0xFF);
|
||||
} else if (placeHolders === 1) {
|
||||
tmp = (lookup.indexOf(b64[i]) << 10) | (lookup.indexOf(b64[i + 1]) << 4) | (lookup.indexOf(b64[i + 2]) >> 2);
|
||||
arr.push((tmp >> 8) & 0xFF);
|
||||
arr.push(tmp & 0xFF);
|
||||
}
|
||||
|
||||
return arr;
|
||||
}
|
||||
|
||||
function uint8ToBase64(uint8) {
|
||||
var i,
|
||||
extraBytes = uint8.length % 3, // if we have 1 byte left, pad 2 bytes
|
||||
output = "",
|
||||
temp, length;
|
||||
|
||||
function tripletToBase64 (num) {
|
||||
return lookup[num >> 18 & 0x3F] + lookup[num >> 12 & 0x3F] + lookup[num >> 6 & 0x3F] + lookup[num & 0x3F];
|
||||
};
|
||||
|
||||
// go through the array every three bytes, we'll deal with trailing stuff later
|
||||
for (i = 0, length = uint8.length - extraBytes; i < length; i += 3) {
|
||||
temp = (uint8[i] << 16) + (uint8[i + 1] << 8) + (uint8[i + 2]);
|
||||
output += tripletToBase64(temp);
|
||||
}
|
||||
|
||||
// pad the end with zeros, but make sure to not forget the extra bytes
|
||||
switch (extraBytes) {
|
||||
case 1:
|
||||
temp = uint8[uint8.length - 1];
|
||||
output += lookup[temp >> 2];
|
||||
output += lookup[(temp << 4) & 0x3F];
|
||||
output += '==';
|
||||
break;
|
||||
case 2:
|
||||
temp = (uint8[uint8.length - 2] << 8) + (uint8[uint8.length - 1]);
|
||||
output += lookup[temp >> 10];
|
||||
output += lookup[(temp >> 4) & 0x3F];
|
||||
output += lookup[(temp << 2) & 0x3F];
|
||||
output += '=';
|
||||
break;
|
||||
}
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
module.exports.toByteArray = b64ToByteArray;
|
||||
module.exports.fromByteArray = uint8ToBase64;
|
||||
}());
|
||||
45
node_modules/buffer-browserify/node_modules/base64-js/package.json
generated
vendored
45
node_modules/buffer-browserify/node_modules/base64-js/package.json
generated
vendored
@ -1,45 +0,0 @@
|
||||
{
|
||||
"author": {
|
||||
"name": "T. Jameson Little",
|
||||
"email": "t.jameson.little@gmail.com"
|
||||
},
|
||||
"name": "base64-js",
|
||||
"description": "Base64 encoding/decoding in pure JS",
|
||||
"version": "0.0.2",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/beatgammit/deflate-js.git"
|
||||
},
|
||||
"main": "lib/b64.js",
|
||||
"scripts": {
|
||||
"test": "cd test; node runner.js; cd -"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
},
|
||||
"dependencies": {},
|
||||
"devDependencies": {},
|
||||
"_npmUser": {
|
||||
"name": "beatgammit",
|
||||
"email": "t.jameson.little@gmail.com"
|
||||
},
|
||||
"_id": "base64-js@0.0.2",
|
||||
"_engineSupported": true,
|
||||
"_npmVersion": "1.0.106",
|
||||
"_nodeVersion": "v0.6.2",
|
||||
"_defaultsLoaded": true,
|
||||
"dist": {
|
||||
"shasum": "024f0f72afa25b75f9c0ee73cd4f55ec1bed9784",
|
||||
"tarball": "http://registry.npmjs.org/base64-js/-/base64-js-0.0.2.tgz"
|
||||
},
|
||||
"maintainers": [
|
||||
{
|
||||
"name": "beatgammit",
|
||||
"email": "t.jameson.little@gmail.com"
|
||||
}
|
||||
],
|
||||
"directories": {},
|
||||
"_shasum": "024f0f72afa25b75f9c0ee73cd4f55ec1bed9784",
|
||||
"_from": "base64-js@0.0.2",
|
||||
"_resolved": "https://registry.npmjs.org/base64-js/-/base64-js-0.0.2.tgz"
|
||||
}
|
||||
74
node_modules/buffer-browserify/package.json
generated
vendored
74
node_modules/buffer-browserify/package.json
generated
vendored
@ -1,74 +0,0 @@
|
||||
{
|
||||
"name": "buffer-browserify",
|
||||
"version": "0.2.3",
|
||||
"description": "buffer module compatibility for browserify",
|
||||
"main": "index.js",
|
||||
"browserify": "index.js",
|
||||
"directories": {
|
||||
"test": "test"
|
||||
},
|
||||
"dependencies": {
|
||||
"base64-js": "0.0.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"tape": "~2.1.0",
|
||||
"tap": "~0.4.4"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "http://github.com/toots/buffer-browserify.git"
|
||||
},
|
||||
"testling": {
|
||||
"files": "test/*.js",
|
||||
"browsers": [
|
||||
"ie/6..latest",
|
||||
"chrome/20..latest",
|
||||
"firefox/10..latest",
|
||||
"safari/latest",
|
||||
"opera/11.0..latest",
|
||||
"iphone/6",
|
||||
"ipad/6"
|
||||
]
|
||||
},
|
||||
"keywords": [
|
||||
"buffer",
|
||||
"browserify",
|
||||
"compatible",
|
||||
"meatless",
|
||||
"browser"
|
||||
],
|
||||
"author": {
|
||||
"name": "Romain Beauxis",
|
||||
"email": "toots@rastageeks.org"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "tap test/*.js"
|
||||
},
|
||||
"license": "MIT/X11",
|
||||
"engine": {
|
||||
"node": ">=0.6"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/toots/buffer-browserify/issues"
|
||||
},
|
||||
"homepage": "https://github.com/toots/buffer-browserify",
|
||||
"_id": "buffer-browserify@0.2.3",
|
||||
"dist": {
|
||||
"shasum": "5f6b880d93d7db441c547d064a4881f29ee6d5b2",
|
||||
"tarball": "http://registry.npmjs.org/buffer-browserify/-/buffer-browserify-0.2.3.tgz"
|
||||
},
|
||||
"_from": "buffer-browserify@",
|
||||
"_npmVersion": "1.3.21",
|
||||
"_npmUser": {
|
||||
"name": "toots",
|
||||
"email": "toots@rastageeks.org"
|
||||
},
|
||||
"maintainers": [
|
||||
{
|
||||
"name": "toots",
|
||||
"email": "toots@rastageeks.org"
|
||||
}
|
||||
],
|
||||
"_shasum": "5f6b880d93d7db441c547d064a4881f29ee6d5b2",
|
||||
"_resolved": "https://registry.npmjs.org/buffer-browserify/-/buffer-browserify-0.2.3.tgz"
|
||||
}
|
||||
17
node_modules/catharsis/LICENSE
generated
vendored
17
node_modules/catharsis/LICENSE
generated
vendored
@ -1,17 +0,0 @@
|
||||
Copyright (c) 2014 Google Inc.
|
||||
Copyright (c) 2012-2014 Jeff Williams
|
||||
|
||||
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.
|
||||
166
node_modules/catharsis/catharsis.js
generated
vendored
166
node_modules/catharsis/catharsis.js
generated
vendored
@ -1,166 +0,0 @@
|
||||
/**
|
||||
* Catharsis
|
||||
* A parser for Google Closure Compiler type expressions, powered by PEG.js.
|
||||
*
|
||||
* @author Jeff Williams <jeffrey.l.williams@gmail.com>
|
||||
* @license MIT License <http://opensource.org/licenses/mit-license.php/>
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
var describe = require('./lib/describe');
|
||||
var parse = require('./lib/parser').parse;
|
||||
var stringify = require('./lib/stringify');
|
||||
|
||||
var typeExpressionCache = {
|
||||
normal: {},
|
||||
jsdoc: {}
|
||||
};
|
||||
|
||||
var parsedTypeCache = {
|
||||
normal: {},
|
||||
htmlSafe: {}
|
||||
};
|
||||
|
||||
var descriptionCache = {
|
||||
normal: {}
|
||||
};
|
||||
|
||||
function getTypeExpressionCache(options) {
|
||||
if (options.useCache === false) {
|
||||
return null;
|
||||
} else if (options.jsdoc === true) {
|
||||
return typeExpressionCache.jsdoc;
|
||||
} else {
|
||||
return typeExpressionCache.normal;
|
||||
}
|
||||
}
|
||||
|
||||
function getParsedTypeCache(options) {
|
||||
if (options.useCache === false || options.links !== null || options.links !== undefined) {
|
||||
return null;
|
||||
} else if (options.htmlSafe === true) {
|
||||
return parsedTypeCache.htmlSafe;
|
||||
} else {
|
||||
return parsedTypeCache.normal;
|
||||
}
|
||||
}
|
||||
|
||||
function getDescriptionCache(options) {
|
||||
if (options.useCache === false || options.links !== null || options.links !== undefined) {
|
||||
return null;
|
||||
} else {
|
||||
return descriptionCache.normal;
|
||||
}
|
||||
}
|
||||
|
||||
// can't return the original if any of the following are true:
|
||||
// 1. restringification was requested
|
||||
// 2. htmlSafe option was requested
|
||||
// 3. links option was provided
|
||||
// 4. typeExpression property is missing
|
||||
function canReturnOriginalExpression(parsedType, options) {
|
||||
return options.restringify !== true && options.htmlSafe !== true &&
|
||||
(options.links === null || options.links === undefined) &&
|
||||
Object.prototype.hasOwnProperty.call(parsedType, 'typeExpression');
|
||||
}
|
||||
|
||||
// Add non-enumerable properties to a result object, then freeze it.
|
||||
function prepareFrozenObject(obj, expr, options) {
|
||||
Object.defineProperty(obj, 'jsdoc', {
|
||||
value: options.jsdoc === true ? true : false
|
||||
});
|
||||
|
||||
if (expr) {
|
||||
Object.defineProperty(obj, 'typeExpression', {
|
||||
value: expr
|
||||
});
|
||||
}
|
||||
|
||||
return Object.freeze(obj);
|
||||
}
|
||||
|
||||
function cachedParse(expr, options) {
|
||||
var cache = getTypeExpressionCache(options);
|
||||
var parsedType;
|
||||
|
||||
if (cache && Object.prototype.hasOwnProperty.call(cache, expr)) {
|
||||
return cache[expr];
|
||||
} else {
|
||||
parsedType = parse(expr, options);
|
||||
parsedType = prepareFrozenObject(parsedType, expr, options);
|
||||
|
||||
if (cache) {
|
||||
cache[expr] = parsedType;
|
||||
}
|
||||
|
||||
return parsedType;
|
||||
}
|
||||
}
|
||||
|
||||
function cachedStringify(parsedType, options) {
|
||||
var cache = getParsedTypeCache(options);
|
||||
var json;
|
||||
|
||||
if (canReturnOriginalExpression(parsedType, options)) {
|
||||
return parsedType.typeExpression;
|
||||
} else if (cache) {
|
||||
json = JSON.stringify(parsedType);
|
||||
cache[json] = cache[json] || stringify(parsedType, options);
|
||||
return cache[json];
|
||||
} else {
|
||||
return stringify(parsedType, options);
|
||||
}
|
||||
}
|
||||
|
||||
function cachedDescribe(parsedType, options) {
|
||||
var cache = getDescriptionCache(options);
|
||||
var json;
|
||||
var result;
|
||||
|
||||
if (cache) {
|
||||
json = JSON.stringify(parsedType);
|
||||
cache[json] = cache[json] || describe(parsedType, options);
|
||||
return cache[json];
|
||||
} else {
|
||||
result = describe(parsedType, options);
|
||||
result = prepareFrozenObject(result, null, options);
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
function Catharsis() {
|
||||
this.Types = require('./lib/types');
|
||||
}
|
||||
|
||||
Catharsis.prototype.parse = function(typeExpr, options) {
|
||||
options = options || {};
|
||||
|
||||
typeExpr = typeExpr.replace(/[\r\n]/g, '')
|
||||
.replace(/\s+/g, ' ')
|
||||
.trim();
|
||||
|
||||
return cachedParse(typeExpr, options);
|
||||
};
|
||||
|
||||
Catharsis.prototype.stringify = function(parsedType, options) {
|
||||
var result;
|
||||
|
||||
options = options || {};
|
||||
|
||||
result = cachedStringify(parsedType, options);
|
||||
if (options.validate) {
|
||||
this.parse(result, options);
|
||||
}
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
Catharsis.prototype.describe = function(parsedType, options) {
|
||||
options = options || {};
|
||||
|
||||
return cachedDescribe(parsedType, options);
|
||||
};
|
||||
|
||||
module.exports = new Catharsis();
|
||||
531
node_modules/catharsis/lib/describe.js
generated
vendored
531
node_modules/catharsis/lib/describe.js
generated
vendored
@ -1,531 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
var _ = require('underscore-contrib');
|
||||
var fs = require('fs');
|
||||
var path = require('path');
|
||||
var stringify = require('./stringify');
|
||||
var Types = require('./types');
|
||||
var util = require('util');
|
||||
|
||||
var DEFAULT_OPTIONS = {
|
||||
language: 'en',
|
||||
resources: {
|
||||
en: JSON.parse(fs.readFileSync(path.join(__dirname, '../res/en.json'), 'utf8'))
|
||||
}
|
||||
};
|
||||
|
||||
// order matters for these!
|
||||
var FUNCTION_DETAILS = ['new', 'this'];
|
||||
var FUNCTION_DETAILS_VARIABLES = ['functionNew', 'functionThis'];
|
||||
var MODIFIERS = ['optional', 'nullable', 'repeatable'];
|
||||
|
||||
var TEMPLATE_VARIABLES = [
|
||||
'application',
|
||||
'codeTagClose',
|
||||
'codeTagOpen',
|
||||
'element',
|
||||
'field',
|
||||
'functionNew',
|
||||
'functionParams',
|
||||
'functionReturns',
|
||||
'functionThis',
|
||||
'keyApplication',
|
||||
'name',
|
||||
'nullable',
|
||||
'optional',
|
||||
'param',
|
||||
'prefix',
|
||||
'repeatable',
|
||||
'suffix',
|
||||
'type'
|
||||
];
|
||||
|
||||
var FORMATS = {
|
||||
EXTENDED: 'extended',
|
||||
SIMPLE: 'simple'
|
||||
};
|
||||
|
||||
function makeTagOpen(codeTag, codeClass) {
|
||||
var tagOpen = '';
|
||||
var tags = codeTag ? codeTag.split(' ') : [];
|
||||
|
||||
tags.forEach(function(tag) {
|
||||
var tagClass = codeClass ? util.format(' class="%s"', codeClass) : '';
|
||||
tagOpen += util.format('<%s%s>', tag, tagClass);
|
||||
});
|
||||
|
||||
return tagOpen;
|
||||
}
|
||||
|
||||
function makeTagClose(codeTag) {
|
||||
var tagClose = '';
|
||||
var tags = codeTag ? codeTag.split(' ') : [];
|
||||
|
||||
tags.reverse();
|
||||
tags.forEach(function(tag) {
|
||||
tagClose += util.format('</%s>', tag);
|
||||
});
|
||||
|
||||
return tagClose;
|
||||
}
|
||||
|
||||
function Result() {
|
||||
this.description = '';
|
||||
this.modifiers = {
|
||||
functionNew: '',
|
||||
functionThis: '',
|
||||
optional: '',
|
||||
nullable: '',
|
||||
repeatable: ''
|
||||
};
|
||||
this.returns = '';
|
||||
}
|
||||
|
||||
function Context(props) {
|
||||
var self = this;
|
||||
|
||||
props = props || {};
|
||||
|
||||
TEMPLATE_VARIABLES.forEach(function(variable) {
|
||||
self[variable] = props[variable] || '';
|
||||
});
|
||||
}
|
||||
|
||||
function Describer(opts) {
|
||||
var options;
|
||||
|
||||
this._useLongFormat = true;
|
||||
options = this._options = _.defaults(opts || {}, DEFAULT_OPTIONS);
|
||||
this._stringifyOptions = _.defaults(options, {_ignoreModifiers: true});
|
||||
|
||||
// use a dictionary, not a Context object, so we can more easily merge this into Context objects
|
||||
this._i18nContext = {
|
||||
codeTagClose: makeTagClose(options.codeTag),
|
||||
codeTagOpen: makeTagOpen(options.codeTag, options.codeClass)
|
||||
};
|
||||
|
||||
// templates start out as strings; we lazily replace them with template functions
|
||||
this._templates = options.resources[options.language];
|
||||
if (!this._templates) {
|
||||
throw new Error('I18N resources are not available for the language ' + options.language);
|
||||
}
|
||||
}
|
||||
|
||||
function modifierKind(useLongFormat) {
|
||||
return useLongFormat ? FORMATS.EXTENDED : FORMATS.SIMPLE;
|
||||
}
|
||||
|
||||
function buildModifierStrings(describer, modifiers, type, useLongFormat) {
|
||||
var result = {};
|
||||
|
||||
modifiers.forEach(function(modifier) {
|
||||
var key = modifierKind(useLongFormat);
|
||||
var modifierStrings = describer[modifier](type[modifier]);
|
||||
|
||||
result[modifier] = modifierStrings[key];
|
||||
});
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
function addModifiers(describer, context, result, type, useLongFormat) {
|
||||
var keyPrefix = 'modifiers.' + modifierKind(useLongFormat);
|
||||
var modifiers = buildModifierStrings(describer, MODIFIERS, type, useLongFormat);
|
||||
|
||||
MODIFIERS.forEach(function(modifier) {
|
||||
var modifierText = modifiers[modifier] || '';
|
||||
|
||||
result.modifiers[modifier] = modifierText;
|
||||
if (!useLongFormat) {
|
||||
context[modifier] = modifierText;
|
||||
}
|
||||
});
|
||||
|
||||
context.prefix = describer._translate(keyPrefix + '.prefix', context);
|
||||
context.suffix = describer._translate(keyPrefix + '.suffix', context);
|
||||
}
|
||||
|
||||
function addFunctionModifiers(describer, context, result, type, useLongFormat) {
|
||||
var functionDetails = buildModifierStrings(describer, FUNCTION_DETAILS, type, useLongFormat);
|
||||
var kind = modifierKind(useLongFormat);
|
||||
var strings = [];
|
||||
|
||||
FUNCTION_DETAILS.forEach(function(functionDetail, i) {
|
||||
var functionExtraInfo = functionDetails[functionDetail] || '';
|
||||
var functionDetailsVariable = FUNCTION_DETAILS_VARIABLES[i];
|
||||
|
||||
result.modifiers[functionDetailsVariable] = functionExtraInfo;
|
||||
if (!useLongFormat) {
|
||||
context[functionDetailsVariable] += functionExtraInfo;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Replace 2+ whitespace characters with a single whitespace character.
|
||||
function collapseSpaces(string) {
|
||||
return string.replace(/(\s)+/g, '$1');
|
||||
}
|
||||
|
||||
Describer.prototype._stringify = function(type, typeString, useLongFormat) {
|
||||
var context = new Context({
|
||||
type: typeString || stringify(type, this._stringifyOptions)
|
||||
});
|
||||
var result = new Result();
|
||||
|
||||
addModifiers(this, context, result, type, useLongFormat);
|
||||
result.description = this._translate('type', context).trim();
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
Describer.prototype._translate = function(key, context) {
|
||||
var result;
|
||||
var templateFunction = _.getPath(this._templates, key);
|
||||
|
||||
context = context || new Context();
|
||||
|
||||
if (templateFunction === undefined) {
|
||||
throw new Error(util.format('The template %s does not exist for the language %s', key,
|
||||
this._options.language));
|
||||
}
|
||||
|
||||
// compile and cache the template function if necessary
|
||||
if (typeof templateFunction === 'string') {
|
||||
// force the templates to use the `context` object
|
||||
templateFunction = templateFunction.replace(/\<\%\= /g, '<%= context.');
|
||||
templateFunction = _.template(templateFunction, null, {variable: 'context'});
|
||||
_.setPath(this._templates, templateFunction, key);
|
||||
}
|
||||
|
||||
result = (templateFunction(_.extend(context, this._i18nContext)) || '')
|
||||
// strip leading spaces
|
||||
.replace(/^\s+/, '');
|
||||
result = collapseSpaces(result);
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
Describer.prototype._modifierHelper = function(key, modifierPrefix, context) {
|
||||
modifierPrefix = modifierPrefix || '';
|
||||
|
||||
return {
|
||||
extended: key ?
|
||||
this._translate(util.format('%s.%s.%s', modifierPrefix, FORMATS.EXTENDED, key),
|
||||
context) :
|
||||
'',
|
||||
simple: key ?
|
||||
this._translate(util.format('%s.%s.%s', modifierPrefix, FORMATS.SIMPLE, key), context) :
|
||||
''
|
||||
};
|
||||
};
|
||||
|
||||
Describer.prototype._translateModifier = function(key, context) {
|
||||
return this._modifierHelper(key, 'modifiers', context);
|
||||
};
|
||||
|
||||
Describer.prototype._translateFunctionModifier = function(key, context) {
|
||||
return this._modifierHelper(key, 'function', context);
|
||||
};
|
||||
|
||||
function getApplicationKey(applications) {
|
||||
if (applications.length === 1) {
|
||||
return 'array';
|
||||
} else if (/[Ss]tring/.test(applications[0].name)) {
|
||||
// object with string keys
|
||||
return 'object';
|
||||
} else {
|
||||
// object with non-string keys
|
||||
return 'objectNonString';
|
||||
}
|
||||
}
|
||||
|
||||
Describer.prototype.application = function(type, useLongFormat) {
|
||||
var applications = type.applications.slice(0);
|
||||
var context = new Context();
|
||||
var key = 'application.' + getApplicationKey(applications);
|
||||
var result = new Result();
|
||||
var self = this;
|
||||
|
||||
addModifiers(this, context, result, type, useLongFormat);
|
||||
|
||||
context.application = this.type(applications.pop()).description;
|
||||
context.keyApplication = applications.length ? this.type(applications.pop()).description : '';
|
||||
|
||||
result.description = this._translate(key, context).trim();
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
function reduceMultiple(context, keyName, contextName, translate, previous, current, index, items) {
|
||||
var key =
|
||||
index === 0 ? '.first.many' :
|
||||
index === (items.length - 1) ? '.last.many' :
|
||||
'.middle.many';
|
||||
|
||||
key = keyName + key;
|
||||
context[contextName] = items[index];
|
||||
|
||||
return previous + translate(key, context);
|
||||
}
|
||||
|
||||
Describer.prototype.elements = function(type, useLongFormat) {
|
||||
var context = new Context();
|
||||
var items = type.elements.slice(0);
|
||||
var result = new Result();
|
||||
|
||||
addModifiers(this, context, result, type, useLongFormat);
|
||||
result.description = this._combineMultiple(items, context, 'union', 'element', useLongFormat);
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
Describer.prototype.new = function(funcNew) {
|
||||
var context = new Context({'functionNew': this.type(funcNew).description});
|
||||
var key = funcNew ? 'new' : '';
|
||||
|
||||
return this._translateFunctionModifier(key, context);
|
||||
};
|
||||
|
||||
Describer.prototype.nullable = function(nullable) {
|
||||
var key = nullable === true ? 'nullable' :
|
||||
nullable === false ? 'nonNullable' :
|
||||
'';
|
||||
|
||||
return this._translateModifier(key);
|
||||
};
|
||||
|
||||
Describer.prototype.optional = function(optional) {
|
||||
var key = (optional === true) ? 'optional' : '';
|
||||
|
||||
return this._translateModifier(key);
|
||||
};
|
||||
|
||||
Describer.prototype.repeatable = function(repeatable) {
|
||||
var key = (repeatable === true) ? 'repeatable' : '';
|
||||
|
||||
return this._translateModifier(key);
|
||||
};
|
||||
|
||||
Describer.prototype._combineMultiple = function(items, context, keyName, contextName,
|
||||
useLongFormat) {
|
||||
var result = new Result();
|
||||
var self = this;
|
||||
var strings;
|
||||
|
||||
strings = typeof items[0] === 'string' ?
|
||||
items.slice(0) :
|
||||
items.map(function(item) {
|
||||
return self.type(item).description;
|
||||
});
|
||||
|
||||
switch(strings.length) {
|
||||
case 0:
|
||||
// falls through
|
||||
case 1:
|
||||
context[contextName] = strings[0] || '';
|
||||
result.description = this._translate(keyName + '.first.one', context);
|
||||
break;
|
||||
case 2:
|
||||
strings.forEach(function(item, idx) {
|
||||
var key = keyName + (idx === 0 ? '.first' : '.last' ) + '.two';
|
||||
|
||||
context[contextName] = item;
|
||||
result.description += self._translate(key, context);
|
||||
});
|
||||
break;
|
||||
default:
|
||||
result.description = strings.reduce(reduceMultiple.bind(null, context, keyName,
|
||||
contextName, this._translate.bind(this)), '');
|
||||
}
|
||||
|
||||
return result.description.trim();
|
||||
};
|
||||
|
||||
Describer.prototype.params = function(params, functionContext) {
|
||||
var context = new Context();
|
||||
var result = new Result();
|
||||
var self = this;
|
||||
var strings;
|
||||
|
||||
// TODO: this hardcodes the order and placement of functionNew and functionThis; need to move
|
||||
// this to the template (and also track whether to put a comma after the last modifier)
|
||||
functionContext = functionContext || {};
|
||||
params = params || [];
|
||||
strings = params.map(function(param) {
|
||||
return self.type(param).description;
|
||||
});
|
||||
|
||||
if (functionContext.functionThis) {
|
||||
strings.unshift(functionContext.functionThis);
|
||||
}
|
||||
if (functionContext.functionNew) {
|
||||
strings.unshift(functionContext.functionNew);
|
||||
}
|
||||
result.description = this._combineMultiple(strings, context, 'params', 'param', false);
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
Describer.prototype.this = function(funcThis) {
|
||||
var context = new Context({'functionThis': this.type(funcThis).description});
|
||||
var key = funcThis ? 'this' : '';
|
||||
|
||||
return this._translateFunctionModifier(key, context);
|
||||
};
|
||||
|
||||
Describer.prototype.type = function(type, useLongFormat) {
|
||||
var result = new Result();
|
||||
|
||||
if (useLongFormat === undefined) {
|
||||
useLongFormat = this._useLongFormat;
|
||||
}
|
||||
// ensure we don't use the long format for inner types
|
||||
this._useLongFormat = false;
|
||||
|
||||
if (!type) {
|
||||
return result;
|
||||
}
|
||||
|
||||
switch(type.type) {
|
||||
case Types.AllLiteral:
|
||||
result = this._stringify(type, this._translate('all'), useLongFormat);
|
||||
break;
|
||||
case Types.FunctionType:
|
||||
result = this._signature(type, useLongFormat);
|
||||
break;
|
||||
case Types.NameExpression:
|
||||
result = this._stringify(type, null, useLongFormat);
|
||||
break;
|
||||
case Types.NullLiteral:
|
||||
result = this._stringify(type, this._translate('null'), useLongFormat);
|
||||
break;
|
||||
case Types.RecordType:
|
||||
result = this._record(type, useLongFormat);
|
||||
break;
|
||||
case Types.TypeApplication:
|
||||
result = this.application(type, useLongFormat);
|
||||
break;
|
||||
case Types.TypeUnion:
|
||||
result = this.elements(type, useLongFormat);
|
||||
break;
|
||||
case Types.UndefinedLiteral:
|
||||
result = this._stringify(type, this._translate('undefined'), useLongFormat);
|
||||
break;
|
||||
case Types.UnknownLiteral:
|
||||
result = this._stringify(type, this._translate('unknown'), useLongFormat);
|
||||
break;
|
||||
default:
|
||||
throw new Error('Unknown type: ' + JSON.stringify(type));
|
||||
}
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
Describer.prototype._record = function(type, useLongFormat) {
|
||||
var context = new Context();
|
||||
var items;
|
||||
var result = new Result();
|
||||
|
||||
items = this._recordFields(type.fields);
|
||||
|
||||
addModifiers(this, context, result, type, useLongFormat);
|
||||
result.description = this._combineMultiple(items, context, 'record', 'field', useLongFormat);
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
Describer.prototype._recordFields = function(fields) {
|
||||
var context = new Context();
|
||||
var result = [];
|
||||
var self = this;
|
||||
|
||||
if (!fields.length) {
|
||||
return result;
|
||||
}
|
||||
|
||||
result = fields.map(function(field) {
|
||||
var key = 'field.' + (field.value ? 'typed' : 'untyped');
|
||||
|
||||
context.name = self.type(field.key).description;
|
||||
if (field.value) {
|
||||
context.type = self.type(field.value).description;
|
||||
}
|
||||
|
||||
return self._translate(key, context);
|
||||
});
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
Describer.prototype._addLinks = function(nameString) {
|
||||
var linkClass = '';
|
||||
var options = this._options;
|
||||
var result = nameString;
|
||||
|
||||
|
||||
if (options.links && Object.prototype.hasOwnProperty.call(options.links, nameString)) {
|
||||
if (options.linkClass) {
|
||||
linkClass = util.format(' class="%s"', options.linkClass);
|
||||
}
|
||||
|
||||
nameString = util.format('<a href="%s"%s>%s</a>', options.links[nameString], linkClass,
|
||||
nameString);
|
||||
}
|
||||
|
||||
return nameString;
|
||||
};
|
||||
|
||||
Describer.prototype.result = function(type, useLongFormat) {
|
||||
var context = new Context();
|
||||
var description;
|
||||
var key = 'function.' + modifierKind(useLongFormat) + '.returns';
|
||||
var result = new Result();
|
||||
|
||||
context.type = this.type(type).description;
|
||||
|
||||
addModifiers(this, context, result, type, useLongFormat);
|
||||
result.description = this._translate(key, context);
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
Describer.prototype._signature = function(type, useLongFormat) {
|
||||
var context = new Context();
|
||||
var functionModifiers;
|
||||
var kind = modifierKind(useLongFormat);
|
||||
var result = new Result();
|
||||
var returns;
|
||||
var self = this;
|
||||
|
||||
addModifiers(this, context, result, type, useLongFormat);
|
||||
addFunctionModifiers(this, context, result, type, useLongFormat);
|
||||
|
||||
context.functionParams = this.params(type.params || [], context).description;
|
||||
|
||||
if (type.result) {
|
||||
returns = this.result(type.result, useLongFormat);
|
||||
if (useLongFormat) {
|
||||
result.returns = returns.description;
|
||||
} else {
|
||||
context.functionReturns = returns.description;
|
||||
}
|
||||
}
|
||||
|
||||
result.description += this._translate('function.' + kind + '.signature', context).trim();
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
module.exports = function(type, options) {
|
||||
var simple = new Describer(options).type(type, false);
|
||||
var extended = new Describer(options).type(type);
|
||||
|
||||
[simple, extended].forEach(function(result) {
|
||||
result.description = collapseSpaces(result.description.trim());
|
||||
});
|
||||
|
||||
return {
|
||||
simple: simple.description,
|
||||
extended: extended
|
||||
};
|
||||
};
|
||||
5702
node_modules/catharsis/lib/parser.js
generated
vendored
5702
node_modules/catharsis/lib/parser.js
generated
vendored
File diff suppressed because one or more lines are too long
69
node_modules/catharsis/lib/schema.js
generated
vendored
69
node_modules/catharsis/lib/schema.js
generated
vendored
@ -1,69 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
var _ = require('underscore-contrib');
|
||||
|
||||
// JSON schema types
|
||||
var ARRAY = 'array';
|
||||
var BOOLEAN = 'boolean';
|
||||
var OBJECT = 'object';
|
||||
var STRING = 'string';
|
||||
var UNDEFINED = 'undefined';
|
||||
|
||||
var TYPES = require('./types');
|
||||
var TYPE_NAMES = _.values(TYPES);
|
||||
|
||||
module.exports = {
|
||||
id: '#parsedType',
|
||||
type: [OBJECT, UNDEFINED],
|
||||
additionalProperties: false,
|
||||
properties: {
|
||||
type: {
|
||||
type: STRING,
|
||||
enum: TYPE_NAMES
|
||||
},
|
||||
|
||||
// field type
|
||||
key: { '$ref': '#parsedType' },
|
||||
value: { '$ref': '#parsedType' },
|
||||
|
||||
// function type
|
||||
params: {
|
||||
type: ARRAY,
|
||||
items: { '$ref': '#parsedType' }
|
||||
},
|
||||
'new': { '$ref': '#parsedType' },
|
||||
'this': { '$ref': '#parsedType' },
|
||||
result: {'$ref': '#parsedType' },
|
||||
|
||||
// name expression
|
||||
name: STRING,
|
||||
|
||||
// record type
|
||||
fields: {
|
||||
type: ARRAY,
|
||||
items: { '$ref': '#parsedType' }
|
||||
},
|
||||
|
||||
// type application
|
||||
expression: { '$ref': '#parsedType' },
|
||||
applications: {
|
||||
type: ARRAY,
|
||||
minItems: 1,
|
||||
maxItems: 2,
|
||||
items: { '$ref': '#parsedType' }
|
||||
},
|
||||
|
||||
// type union
|
||||
elements: {
|
||||
type: ARRAY,
|
||||
minItems: 1,
|
||||
items: { '$ref': '#parsedType' }
|
||||
},
|
||||
|
||||
optional: BOOLEAN,
|
||||
nullable: BOOLEAN,
|
||||
repeatable: BOOLEAN,
|
||||
reservedWord: BOOLEAN
|
||||
},
|
||||
required: [ 'type' ]
|
||||
};
|
||||
258
node_modules/catharsis/lib/stringify.js
generated
vendored
258
node_modules/catharsis/lib/stringify.js
generated
vendored
@ -1,258 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
var Types = require('./types');
|
||||
|
||||
function Stringifier(options) {
|
||||
this._options = options || {};
|
||||
this._options.linkClass = this._options.linkClass || this._options.cssClass;
|
||||
}
|
||||
|
||||
Stringifier.prototype.applications = function(applications) {
|
||||
var result = '';
|
||||
var strings = [];
|
||||
|
||||
if (!applications) {
|
||||
return result;
|
||||
}
|
||||
|
||||
for (var i = 0, l = applications.length; i < l; i++) {
|
||||
strings.push(this.type(applications[i]));
|
||||
}
|
||||
|
||||
if (this._options.htmlSafe) {
|
||||
result = '.<';
|
||||
} else {
|
||||
result = '.<';
|
||||
}
|
||||
|
||||
result += strings.join(', ') + '>';
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
Stringifier.prototype.elements = function(elements) {
|
||||
var result = '';
|
||||
var strings = [];
|
||||
|
||||
if (!elements) {
|
||||
return result;
|
||||
}
|
||||
|
||||
for (var i = 0, l = elements.length; i < l; i++) {
|
||||
strings.push(this.type(elements[i]));
|
||||
}
|
||||
|
||||
result = '(' + strings.join('|') + ')';
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
Stringifier.prototype.name = function(name) {
|
||||
return name || '';
|
||||
};
|
||||
|
||||
Stringifier.prototype.new = function(funcNew) {
|
||||
return funcNew ? 'new:' + this.type(funcNew) : '';
|
||||
};
|
||||
|
||||
Stringifier.prototype.nullable = function(nullable) {
|
||||
switch (nullable) {
|
||||
case true:
|
||||
return '?';
|
||||
case false:
|
||||
return '!';
|
||||
default:
|
||||
return '';
|
||||
}
|
||||
};
|
||||
|
||||
Stringifier.prototype.optional = function(optional) {
|
||||
if (optional === true) {
|
||||
return '=';
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
};
|
||||
|
||||
Stringifier.prototype.params = function(params) {
|
||||
var result = '';
|
||||
var strings = [];
|
||||
|
||||
if (!params || params.length === 0) {
|
||||
return result;
|
||||
}
|
||||
|
||||
for (var i = 0, l = params.length; i < l; i++) {
|
||||
strings.push(this.type(params[i]));
|
||||
}
|
||||
|
||||
result = strings.join(', ');
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
Stringifier.prototype.result = function(result) {
|
||||
return result ? ': ' + this.type(result) : '';
|
||||
};
|
||||
|
||||
Stringifier.prototype.this = function(funcThis) {
|
||||
return funcThis ? 'this:' + this.type(funcThis) : '';
|
||||
};
|
||||
|
||||
Stringifier.prototype.type = function(type) {
|
||||
var typeString = '';
|
||||
|
||||
if (!type) {
|
||||
return typeString;
|
||||
}
|
||||
|
||||
switch(type.type) {
|
||||
case Types.AllLiteral:
|
||||
typeString = this._formatNameAndType(type, '*');
|
||||
break;
|
||||
case Types.FunctionType:
|
||||
typeString = this._signature(type);
|
||||
break;
|
||||
case Types.NullLiteral:
|
||||
typeString = this._formatNameAndType(type, 'null');
|
||||
break;
|
||||
case Types.RecordType:
|
||||
typeString = this._record(type);
|
||||
break;
|
||||
case Types.TypeApplication:
|
||||
typeString = this.type(type.expression) + this.applications(type.applications);
|
||||
break;
|
||||
case Types.UndefinedLiteral:
|
||||
typeString = this._formatNameAndType(type, 'undefined');
|
||||
break;
|
||||
case Types.TypeUnion:
|
||||
typeString = this.elements(type.elements);
|
||||
break;
|
||||
case Types.UnknownLiteral:
|
||||
typeString = this._formatNameAndType(type, '?');
|
||||
break;
|
||||
default:
|
||||
typeString = this._formatNameAndType(type);
|
||||
}
|
||||
|
||||
// add optional/nullable/repeatable modifiers
|
||||
if (!this._options._ignoreModifiers) {
|
||||
typeString = this._addModifiers(type, typeString);
|
||||
}
|
||||
|
||||
return typeString;
|
||||
};
|
||||
|
||||
Stringifier.prototype.stringify = Stringifier.prototype.type;
|
||||
|
||||
Stringifier.prototype.key = Stringifier.prototype.type;
|
||||
|
||||
Stringifier.prototype._record = function(type) {
|
||||
var fields = this._recordFields(type.fields);
|
||||
|
||||
return '{' + fields.join(', ') + '}';
|
||||
};
|
||||
|
||||
Stringifier.prototype._recordFields = function(fields) {
|
||||
var field;
|
||||
var keyAndValue;
|
||||
|
||||
var result = [];
|
||||
|
||||
if (!fields) {
|
||||
return result;
|
||||
}
|
||||
|
||||
for (var i = 0, l = fields.length; i < l; i++) {
|
||||
field = fields[i];
|
||||
|
||||
keyAndValue = this.key(field.key);
|
||||
keyAndValue += field.value ? ': ' + this.type(field.value) : '';
|
||||
|
||||
result.push(keyAndValue);
|
||||
}
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
function combineNameAndType(nameString, typeString) {
|
||||
var separator = (nameString && typeString) ? ':' : '';
|
||||
|
||||
return nameString + separator + typeString;
|
||||
}
|
||||
|
||||
// Adds optional, nullable, and repeatable modifiers if necessary.
|
||||
Stringifier.prototype._addModifiers = function(type, typeString) {
|
||||
var combined;
|
||||
|
||||
var optional = '';
|
||||
var repeatable = '';
|
||||
|
||||
if (type.repeatable) {
|
||||
repeatable = '...';
|
||||
}
|
||||
|
||||
combined = this.nullable(type.nullable) + combineNameAndType('', typeString);
|
||||
optional = this.optional(type.optional);
|
||||
|
||||
return repeatable + combined + optional;
|
||||
};
|
||||
|
||||
Stringifier.prototype._addLinks = function(nameString) {
|
||||
var openTag;
|
||||
|
||||
var linkClass = '';
|
||||
var options = this._options;
|
||||
|
||||
if (options.links && Object.prototype.hasOwnProperty.call(options.links, nameString)) {
|
||||
if (options.linkClass) {
|
||||
linkClass = ' class="' + options.linkClass + '"';
|
||||
}
|
||||
|
||||
openTag = '<a href="' + options.links[nameString] + '"' + linkClass + '>';
|
||||
nameString = openTag + nameString + '</a>';
|
||||
}
|
||||
|
||||
return nameString;
|
||||
};
|
||||
|
||||
Stringifier.prototype._formatNameAndType = function(type, literal) {
|
||||
var nameString = type.name || literal || '';
|
||||
var typeString = type.type ? this.type(type.type) : '';
|
||||
|
||||
nameString = this._addLinks(nameString);
|
||||
|
||||
return combineNameAndType(nameString, typeString);
|
||||
};
|
||||
|
||||
Stringifier.prototype._signature = function(type) {
|
||||
var param;
|
||||
var prop;
|
||||
var signature;
|
||||
|
||||
var params = [];
|
||||
// these go within the signature's parens, in this order
|
||||
var props = [
|
||||
'new',
|
||||
'this',
|
||||
'params'
|
||||
];
|
||||
|
||||
for (var i = 0, l = props.length; i < l; i++) {
|
||||
prop = props[i];
|
||||
param = this[prop](type[prop]);
|
||||
if (param.length > 0) {
|
||||
params.push(param);
|
||||
}
|
||||
}
|
||||
|
||||
signature = 'function(' + params.join(', ') + ')';
|
||||
signature += this.result(type.result);
|
||||
|
||||
return signature;
|
||||
};
|
||||
|
||||
|
||||
module.exports = function(type, options) {
|
||||
return new Stringifier(options).stringify(type);
|
||||
};
|
||||
24
node_modules/catharsis/lib/types.js
generated
vendored
24
node_modules/catharsis/lib/types.js
generated
vendored
@ -1,24 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
module.exports = Object.freeze({
|
||||
// `*`
|
||||
AllLiteral: 'AllLiteral',
|
||||
// like `blah` in `{blah: string}`
|
||||
FieldType: 'FieldType',
|
||||
// like `function(string): string`
|
||||
FunctionType: 'FunctionType',
|
||||
// any string literal, such as `string` or `My.Namespace`
|
||||
NameExpression: 'NameExpression',
|
||||
// null
|
||||
NullLiteral: 'NullLiteral',
|
||||
// like `{foo: string}`
|
||||
RecordType: 'RecordType',
|
||||
// like `Array.<string>`
|
||||
TypeApplication: 'TypeApplication',
|
||||
// like `(number|string)`
|
||||
TypeUnion: 'TypeUnion',
|
||||
// undefined
|
||||
UndefinedLiteral: 'UndefinedLiteral',
|
||||
// `?`
|
||||
UnknownLiteral: 'UnknownLiteral'
|
||||
});
|
||||
22
node_modules/catharsis/node_modules/underscore-contrib/LICENSE
generated
vendored
22
node_modules/catharsis/node_modules/underscore-contrib/LICENSE
generated
vendored
@ -1,22 +0,0 @@
|
||||
Copyright (c) 2013 Jeremy Ashkenas, Michael Fogus, DocumentCloud and Investigative Reporters & Editors
|
||||
|
||||
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.
|
||||
16
node_modules/catharsis/node_modules/underscore-contrib/index.js
generated
vendored
16
node_modules/catharsis/node_modules/underscore-contrib/index.js
generated
vendored
@ -1,16 +0,0 @@
|
||||
require('./underscore.array.builders');
|
||||
require('./underscore.array.selectors');
|
||||
require('./underscore.collections.walk');
|
||||
require('./underscore.function.arity');
|
||||
require('./underscore.function.combinators');
|
||||
require('./underscore.function.dispatch');
|
||||
require('./underscore.function.iterators');
|
||||
require('./underscore.function.predicates');
|
||||
require('./underscore.object.builders');
|
||||
require('./underscore.object.selectors');
|
||||
require('./underscore.util.existential');
|
||||
require('./underscore.util.operators');
|
||||
require('./underscore.util.strings');
|
||||
require('./underscore.util.trampolines');
|
||||
|
||||
module.exports = require('underscore');
|
||||
61
node_modules/catharsis/node_modules/underscore-contrib/package.json
generated
vendored
61
node_modules/catharsis/node_modules/underscore-contrib/package.json
generated
vendored
@ -1,61 +0,0 @@
|
||||
{
|
||||
"name": "underscore-contrib",
|
||||
"version": "0.3.0",
|
||||
"main": "index.js",
|
||||
"dependencies": {
|
||||
"underscore": "1.6.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"grunt": "~0.4.1",
|
||||
"grunt-contrib-concat": "0.3.0",
|
||||
"grunt-contrib-uglify": "0.2.0",
|
||||
"grunt-contrib-qunit": "~0.2.2",
|
||||
"grunt-contrib-watch": "~0.5.3",
|
||||
"grunt-contrib-jshint": "~0.6.4",
|
||||
"grunt-docco": "~0.3.0",
|
||||
"grunt-tocdoc": "~0.1.0",
|
||||
"grunt-cli": "~0.1.11"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/documentcloud/underscore-contrib.git"
|
||||
},
|
||||
"license": "MIT",
|
||||
"author": {
|
||||
"name": "Fogus",
|
||||
"email": "me@fogus.me",
|
||||
"url": "http://www.fogus.me"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "node ./node_modules/grunt-cli/bin/grunt test"
|
||||
},
|
||||
"homepage": "https://github.com/documentcloud/underscore-contrib",
|
||||
"description": "underscore-contrib ==================",
|
||||
"bugs": {
|
||||
"url": "https://github.com/documentcloud/underscore-contrib/issues"
|
||||
},
|
||||
"_id": "underscore-contrib@0.3.0",
|
||||
"dist": {
|
||||
"shasum": "665b66c24783f8fa2b18c9f8cbb0e2c7d48c26c7",
|
||||
"tarball": "http://registry.npmjs.org/underscore-contrib/-/underscore-contrib-0.3.0.tgz"
|
||||
},
|
||||
"_from": "underscore-contrib@>=0.3.0 <0.4.0",
|
||||
"_npmVersion": "1.3.21",
|
||||
"_npmUser": {
|
||||
"name": "joshuacc",
|
||||
"email": "joshua.clanton@gmail.com"
|
||||
},
|
||||
"maintainers": [
|
||||
{
|
||||
"name": "fogus",
|
||||
"email": "mefogus@gmail.com"
|
||||
},
|
||||
{
|
||||
"name": "joshuacc",
|
||||
"email": "joshua.clanton@gmail.com"
|
||||
}
|
||||
],
|
||||
"directories": {},
|
||||
"_shasum": "665b66c24783f8fa2b18c9f8cbb0e2c7d48c26c7",
|
||||
"_resolved": "https://registry.npmjs.org/underscore-contrib/-/underscore-contrib-0.3.0.tgz"
|
||||
}
|
||||
197
node_modules/catharsis/node_modules/underscore-contrib/underscore.array.builders.js
generated
vendored
197
node_modules/catharsis/node_modules/underscore-contrib/underscore.array.builders.js
generated
vendored
@ -1,197 +0,0 @@
|
||||
// Underscore-contrib (underscore.array.builders.js 0.3.0)
|
||||
// (c) 2013 Michael Fogus, DocumentCloud and Investigative Reporters & Editors
|
||||
// Underscore-contrib may be freely distributed under the MIT license.
|
||||
|
||||
(function(root) {
|
||||
|
||||
// Baseline setup
|
||||
// --------------
|
||||
|
||||
// Establish the root object, `window` in the browser, or `global` on the server.
|
||||
var _ = root._ || require('underscore');
|
||||
|
||||
// Helpers
|
||||
// -------
|
||||
|
||||
// Create quick reference variables for speed access to core prototypes.
|
||||
var slice = Array.prototype.slice,
|
||||
concat = Array.prototype.concat;
|
||||
|
||||
var existy = function(x) { return x != null; };
|
||||
|
||||
// Mixing in the array builders
|
||||
// ----------------------------
|
||||
|
||||
_.mixin({
|
||||
// Concatenates one or more arrays given as arguments. If given objects and
|
||||
// scalars as arguments `cat` will plop them down in place in the result
|
||||
// array. If given an `arguments` object, `cat` will treat it like an array
|
||||
// and concatenate it likewise.
|
||||
cat: function() {
|
||||
return _.reduce(arguments, function(acc, elem) {
|
||||
if (_.isArguments(elem)) {
|
||||
return concat.call(acc, slice.call(elem));
|
||||
}
|
||||
else {
|
||||
return concat.call(acc, elem);
|
||||
}
|
||||
}, []);
|
||||
},
|
||||
|
||||
// 'Constructs' an array by putting an element at its front
|
||||
cons: function(head, tail) {
|
||||
return _.cat([head], tail);
|
||||
},
|
||||
|
||||
// Takes an array and chunks it some number of times into
|
||||
// sub-arrays of size n. Allows and optional padding array as
|
||||
// the third argument to fill in the tail chunk when n is
|
||||
// not sufficient to build chunks of the same size.
|
||||
chunk: function(array, n, pad) {
|
||||
var p = function(array) {
|
||||
if (array == null) return [];
|
||||
|
||||
var part = _.take(array, n);
|
||||
|
||||
if (n === _.size(part)) {
|
||||
return _.cons(part, p(_.drop(array, n)));
|
||||
}
|
||||
else {
|
||||
return pad ? [_.take(_.cat(part, pad), n)] : [];
|
||||
}
|
||||
};
|
||||
|
||||
return p(array);
|
||||
},
|
||||
|
||||
// Takes an array and chunks it some number of times into
|
||||
// sub-arrays of size n. If the array given cannot fill the size
|
||||
// needs of the final chunk then a smaller chunk is used
|
||||
// for the last.
|
||||
chunkAll: function(array, n, step) {
|
||||
step = (step != null) ? step : n;
|
||||
|
||||
var p = function(array, n, step) {
|
||||
if (_.isEmpty(array)) return [];
|
||||
|
||||
return _.cons(_.take(array, n),
|
||||
p(_.drop(array, step), n, step));
|
||||
};
|
||||
|
||||
return p(array, n, step);
|
||||
},
|
||||
|
||||
// Maps a function over an array and concatenates all of the results.
|
||||
mapcat: function(array, fun) {
|
||||
return _.cat.apply(null, _.map(array, fun));
|
||||
},
|
||||
|
||||
// Returns an array with some item between each element
|
||||
// of a given array.
|
||||
interpose: function(array, inter) {
|
||||
if (!_.isArray(array)) throw new TypeError;
|
||||
var sz = _.size(array);
|
||||
if (sz === 0) return array;
|
||||
if (sz === 1) return array;
|
||||
|
||||
return slice.call(_.mapcat(array, function(elem) {
|
||||
return _.cons(elem, [inter]);
|
||||
}), 0, -1);
|
||||
},
|
||||
|
||||
// Weaves two or more arrays together
|
||||
weave: function(/* args */) {
|
||||
if (!_.some(arguments)) return [];
|
||||
if (arguments.length == 1) return arguments[0];
|
||||
|
||||
return _.filter(_.flatten(_.zip.apply(null, arguments), true), function(elem) {
|
||||
return elem != null;
|
||||
});
|
||||
},
|
||||
interleave: _.weave,
|
||||
|
||||
// Returns an array of a value repeated a certain number of
|
||||
// times.
|
||||
repeat: function(t, elem) {
|
||||
return _.times(t, function() { return elem; });
|
||||
},
|
||||
|
||||
// Returns an array built from the contents of a given array repeated
|
||||
// a certain number of times.
|
||||
cycle: function(t, elems) {
|
||||
return _.flatten(_.times(t, function() { return elems; }), true);
|
||||
},
|
||||
|
||||
// Returns an array with two internal arrays built from
|
||||
// taking an original array and spliting it at an index.
|
||||
splitAt: function(array, index) {
|
||||
return [_.take(array, index), _.drop(array, index)];
|
||||
},
|
||||
|
||||
// Call a function recursively f(f(f(args))) until a second
|
||||
// given function goes falsey. Expects a seed value to start.
|
||||
iterateUntil: function(doit, checkit, seed) {
|
||||
var ret = [];
|
||||
var result = doit(seed);
|
||||
|
||||
while (checkit(result)) {
|
||||
ret.push(result);
|
||||
result = doit(result);
|
||||
}
|
||||
|
||||
return ret;
|
||||
},
|
||||
|
||||
// Takes every nth item from an array, returning an array of
|
||||
// the results.
|
||||
takeSkipping: function(array, n) {
|
||||
var ret = [];
|
||||
var sz = _.size(array);
|
||||
|
||||
if (n <= 0) return [];
|
||||
if (n === 1) return array;
|
||||
|
||||
for(var index = 0; index < sz; index += n) {
|
||||
ret.push(array[index]);
|
||||
}
|
||||
|
||||
return ret;
|
||||
},
|
||||
|
||||
// Returns an array of each intermediate stage of a call to
|
||||
// a `reduce`-like function.
|
||||
reductions: function(array, fun, init) {
|
||||
var ret = [];
|
||||
var acc = init;
|
||||
|
||||
_.each(array, function(v,k) {
|
||||
acc = fun(acc, array[k]);
|
||||
ret.push(acc);
|
||||
});
|
||||
|
||||
return ret;
|
||||
},
|
||||
|
||||
// Runs its given function on the index of the elements rather than
|
||||
// the elements themselves, keeping all of the truthy values in the end.
|
||||
keepIndexed: function(array, pred) {
|
||||
return _.filter(_.map(_.range(_.size(array)), function(i) {
|
||||
return pred(i, array[i]);
|
||||
}),
|
||||
existy);
|
||||
},
|
||||
|
||||
// Accepts an array-like object (other than strings) as an argument and
|
||||
// returns an array whose elements are in the reverse order. Unlike the
|
||||
// built-in `Array.prototype.reverse` method, this does not mutate the
|
||||
// original object. Note: attempting to use this method on a string will
|
||||
// result in a `TypeError`, as it cannot properly reverse unicode strings.
|
||||
|
||||
reverseOrder: function(obj) {
|
||||
if (typeof obj == 'string')
|
||||
throw new TypeError('Strings cannot be reversed by _.reverseOrder');
|
||||
return slice.call(obj).reverse();
|
||||
}
|
||||
});
|
||||
|
||||
})(this);
|
||||
117
node_modules/catharsis/node_modules/underscore-contrib/underscore.array.selectors.js
generated
vendored
117
node_modules/catharsis/node_modules/underscore-contrib/underscore.array.selectors.js
generated
vendored
@ -1,117 +0,0 @@
|
||||
// Underscore-contrib (underscore.array.selectors.js 0.3.0)
|
||||
// (c) 2013 Michael Fogus, DocumentCloud and Investigative Reporters & Editors
|
||||
// Underscore-contrib may be freely distributed under the MIT license.
|
||||
|
||||
(function(root) {
|
||||
|
||||
// Baseline setup
|
||||
// --------------
|
||||
|
||||
// Establish the root object, `window` in the browser, or `global` on the server.
|
||||
var _ = root._ || require('underscore');
|
||||
|
||||
// Helpers
|
||||
// -------
|
||||
|
||||
// Create quick reference variables for speed access to core prototypes.
|
||||
var slice = Array.prototype.slice,
|
||||
concat = Array.prototype.concat;
|
||||
|
||||
var existy = function(x) { return x != null; };
|
||||
var truthy = function(x) { return (x !== false) && existy(x); };
|
||||
var isSeq = function(x) { return (_.isArray(x)) || (_.isArguments(x)); };
|
||||
|
||||
// Mixing in the array selectors
|
||||
// ----------------------------
|
||||
|
||||
_.mixin({
|
||||
// Returns the second element of an array. Passing **n** will return all but
|
||||
// the first of the head N values in the array. The **guard** check allows it
|
||||
// to work with `_.map`.
|
||||
second: function(array, n, guard) {
|
||||
if (array == null) return void 0;
|
||||
return (n != null) && !guard ? slice.call(array, 1, n) : array[1];
|
||||
},
|
||||
|
||||
// Returns the third element of an array. Passing **n** will return all but
|
||||
// the first two of the head N values in the array. The **guard** check allows it
|
||||
// to work with `_.map`.
|
||||
third: function(array, n, guard) {
|
||||
if (array == null) return void 0;
|
||||
return (n != null) && !guard ? slice.call(array, 2, n) : array[2];
|
||||
},
|
||||
|
||||
// A function to get at an index into an array
|
||||
nth: function(array, index, guard) {
|
||||
if ((index != null) && !guard) return array[index];
|
||||
},
|
||||
|
||||
// Takes all items in an array while a given predicate returns truthy.
|
||||
takeWhile: function(array, pred) {
|
||||
if (!isSeq(array)) throw new TypeError;
|
||||
|
||||
var sz = _.size(array);
|
||||
|
||||
for (var index = 0; index < sz; index++) {
|
||||
if(!truthy(pred(array[index]))) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return _.take(array, index);
|
||||
},
|
||||
|
||||
// Drops all items from an array while a given predicate returns truthy.
|
||||
dropWhile: function(array, pred) {
|
||||
if (!isSeq(array)) throw new TypeError;
|
||||
|
||||
var sz = _.size(array);
|
||||
|
||||
for (var index = 0; index < sz; index++) {
|
||||
if(!truthy(pred(array[index])))
|
||||
break;
|
||||
}
|
||||
|
||||
return _.drop(array, index);
|
||||
},
|
||||
|
||||
// Returns an array with two internal arrays built from
|
||||
// taking an original array and spliting it at the index
|
||||
// where a given function goes falsey.
|
||||
splitWith: function(array, pred) {
|
||||
return [_.takeWhile(array, pred), _.dropWhile(array, pred)];
|
||||
},
|
||||
|
||||
// Takes an array and partitions it as the given predicate changes
|
||||
// truth sense.
|
||||
partitionBy: function(array, fun){
|
||||
if (_.isEmpty(array) || !existy(array)) return [];
|
||||
|
||||
var fst = _.first(array);
|
||||
var fstVal = fun(fst);
|
||||
var run = concat.call([fst], _.takeWhile(_.rest(array), function(e) {
|
||||
return _.isEqual(fstVal, fun(e));
|
||||
}));
|
||||
|
||||
return concat.call([run], _.partitionBy(_.drop(array, _.size(run)), fun));
|
||||
},
|
||||
|
||||
// Returns the 'best' value in an array based on the result of a
|
||||
// given function.
|
||||
best: function(array, fun) {
|
||||
return _.reduce(array, function(x, y) {
|
||||
return fun(x, y) ? x : y;
|
||||
});
|
||||
},
|
||||
|
||||
// Returns an array of existy results of a function over an source array.
|
||||
keep: function(array, fun) {
|
||||
if (!isSeq(array)) throw new TypeError("expected an array as the first argument");
|
||||
|
||||
return _.filter(_.map(array, function(e) {
|
||||
return fun(e);
|
||||
}), existy);
|
||||
}
|
||||
});
|
||||
|
||||
})(this);
|
||||
196
node_modules/catharsis/node_modules/underscore-contrib/underscore.collections.walk.js
generated
vendored
196
node_modules/catharsis/node_modules/underscore-contrib/underscore.collections.walk.js
generated
vendored
@ -1,196 +0,0 @@
|
||||
// Underscore-contrib (underscore.collections.walk.js 0.3.0)
|
||||
// (c) 2013 Patrick Dubroy
|
||||
// Underscore-contrib may be freely distributed under the MIT license.
|
||||
|
||||
(function(root) {
|
||||
|
||||
// Baseline setup
|
||||
// --------------
|
||||
|
||||
// Establish the root object, `window` in the browser, or `global` on the server.
|
||||
var _ = root._ || require('underscore');
|
||||
|
||||
// Helpers
|
||||
// -------
|
||||
|
||||
// An internal object that can be returned from a visitor function to
|
||||
// prevent a top-down walk from walking subtrees of a node.
|
||||
var stopRecursion = {};
|
||||
|
||||
// An internal object that can be returned from a visitor function to
|
||||
// cause the walk to immediately stop.
|
||||
var stopWalk = {};
|
||||
|
||||
var notTreeError = 'Not a tree: same object found in two different branches';
|
||||
|
||||
// Implements the default traversal strategy: if `obj` is a DOM node, walk
|
||||
// its DOM children; otherwise, walk all the objects it references.
|
||||
function defaultTraversal(obj) {
|
||||
return _.isElement(obj) ? obj.children : obj;
|
||||
}
|
||||
|
||||
// Walk the tree recursively beginning with `root`, calling `beforeFunc`
|
||||
// before visiting an objects descendents, and `afterFunc` afterwards.
|
||||
// If `collectResults` is true, the last argument to `afterFunc` will be a
|
||||
// collection of the results of walking the node's subtrees.
|
||||
function walkImpl(root, traversalStrategy, beforeFunc, afterFunc, context, collectResults) {
|
||||
var visited = [];
|
||||
return (function _walk(value, key, parent) {
|
||||
// Keep track of objects that have been visited, and throw an exception
|
||||
// when trying to visit the same object twice.
|
||||
if (_.isObject(value)) {
|
||||
if (visited.indexOf(value) >= 0) throw new TypeError(notTreeError);
|
||||
visited.push(value);
|
||||
}
|
||||
|
||||
if (beforeFunc) {
|
||||
var result = beforeFunc.call(context, value, key, parent);
|
||||
if (result === stopWalk) return stopWalk;
|
||||
if (result === stopRecursion) return;
|
||||
}
|
||||
|
||||
var subResults;
|
||||
var target = traversalStrategy(value);
|
||||
if (_.isObject(target) && !_.isEmpty(target)) {
|
||||
// If collecting results from subtrees, collect them in the same shape
|
||||
// as the parent node.
|
||||
if (collectResults) subResults = _.isArray(value) ? [] : {};
|
||||
|
||||
var stop = _.any(target, function(obj, key) {
|
||||
var result = _walk(obj, key, value);
|
||||
if (result === stopWalk) return true;
|
||||
if (subResults) subResults[key] = result;
|
||||
});
|
||||
if (stop) return stopWalk;
|
||||
}
|
||||
if (afterFunc) return afterFunc.call(context, value, key, parent, subResults);
|
||||
})(root);
|
||||
}
|
||||
|
||||
// Internal helper providing the implementation for `pluck` and `pluckRec`.
|
||||
function pluck(obj, propertyName, recursive) {
|
||||
var results = [];
|
||||
this.preorder(obj, function(value, key) {
|
||||
if (!recursive && key == propertyName)
|
||||
return stopRecursion;
|
||||
if (_.has(value, propertyName))
|
||||
results[results.length] = value[propertyName];
|
||||
});
|
||||
return results;
|
||||
}
|
||||
|
||||
var exports = {
|
||||
// Performs a preorder traversal of `obj` and returns the first value
|
||||
// which passes a truth test.
|
||||
find: function(obj, visitor, context) {
|
||||
var result;
|
||||
this.preorder(obj, function(value, key, parent) {
|
||||
if (visitor.call(context, value, key, parent)) {
|
||||
result = value;
|
||||
return stopWalk;
|
||||
}
|
||||
}, context);
|
||||
return result;
|
||||
},
|
||||
|
||||
// Recursively traverses `obj` and returns all the elements that pass a
|
||||
// truth test. `strategy` is the traversal function to use, e.g. `preorder`
|
||||
// or `postorder`.
|
||||
filter: function(obj, strategy, visitor, context) {
|
||||
var results = [];
|
||||
if (obj == null) return results;
|
||||
strategy(obj, function(value, key, parent) {
|
||||
if (visitor.call(context, value, key, parent)) results.push(value);
|
||||
}, null, this._traversalStrategy);
|
||||
return results;
|
||||
},
|
||||
|
||||
// Recursively traverses `obj` and returns all the elements for which a
|
||||
// truth test fails.
|
||||
reject: function(obj, strategy, visitor, context) {
|
||||
return this.filter(obj, strategy, function(value, key, parent) {
|
||||
return !visitor.call(context, value, key, parent);
|
||||
});
|
||||
},
|
||||
|
||||
// Produces a new array of values by recursively traversing `obj` and
|
||||
// mapping each value through the transformation function `visitor`.
|
||||
// `strategy` is the traversal function to use, e.g. `preorder` or
|
||||
// `postorder`.
|
||||
map: function(obj, strategy, visitor, context) {
|
||||
var results = [];
|
||||
strategy(obj, function(value, key, parent) {
|
||||
results[results.length] = visitor.call(context, value, key, parent);
|
||||
}, null, this._traversalStrategy);
|
||||
return results;
|
||||
},
|
||||
|
||||
// Return the value of properties named `propertyName` reachable from the
|
||||
// tree rooted at `obj`. Results are not recursively searched; use
|
||||
// `pluckRec` for that.
|
||||
pluck: function(obj, propertyName) {
|
||||
return pluck.call(this, obj, propertyName, false);
|
||||
},
|
||||
|
||||
// Version of `pluck` which recursively searches results for nested objects
|
||||
// with a property named `propertyName`.
|
||||
pluckRec: function(obj, propertyName) {
|
||||
return pluck.call(this, obj, propertyName, true);
|
||||
},
|
||||
|
||||
// Recursively traverses `obj` in a depth-first fashion, invoking the
|
||||
// `visitor` function for each object only after traversing its children.
|
||||
// `traversalStrategy` is intended for internal callers, and is not part
|
||||
// of the public API.
|
||||
postorder: function(obj, visitor, context, traversalStrategy) {
|
||||
traversalStrategy = traversalStrategy || this._traversalStrategy;
|
||||
walkImpl(obj, traversalStrategy, null, visitor, context);
|
||||
},
|
||||
|
||||
// Recursively traverses `obj` in a depth-first fashion, invoking the
|
||||
// `visitor` function for each object before traversing its children.
|
||||
// `traversalStrategy` is intended for internal callers, and is not part
|
||||
// of the public API.
|
||||
preorder: function(obj, visitor, context, traversalStrategy) {
|
||||
traversalStrategy = traversalStrategy || this._traversalStrategy;
|
||||
walkImpl(obj, traversalStrategy, visitor, null, context);
|
||||
},
|
||||
|
||||
// Builds up a single value by doing a post-order traversal of `obj` and
|
||||
// calling the `visitor` function on each object in the tree. For leaf
|
||||
// objects, the `memo` argument to `visitor` is the value of the `leafMemo`
|
||||
// argument to `reduce`. For non-leaf objects, `memo` is a collection of
|
||||
// the results of calling `reduce` on the object's children.
|
||||
reduce: function(obj, visitor, leafMemo, context) {
|
||||
var reducer = function(value, key, parent, subResults) {
|
||||
return visitor(subResults || leafMemo, value, key, parent);
|
||||
};
|
||||
return walkImpl(obj, this._traversalStrategy, null, reducer, context, true);
|
||||
}
|
||||
};
|
||||
|
||||
// Set up aliases to match those in underscore.js.
|
||||
exports.collect = exports.map;
|
||||
exports.detect = exports.find;
|
||||
exports.select = exports.filter;
|
||||
|
||||
// Returns an object containing the walk functions. If `traversalStrategy`
|
||||
// is specified, it is a function determining how objects should be
|
||||
// traversed. Given an object, it returns the object to be recursively
|
||||
// walked. The default strategy is equivalent to `_.identity` for regular
|
||||
// objects, and for DOM nodes it returns the node's DOM children.
|
||||
_.walk = function(traversalStrategy) {
|
||||
var walker = _.clone(exports);
|
||||
|
||||
// Bind all of the public functions in the walker to itself. This allows
|
||||
// the traversal strategy to be dynamically scoped.
|
||||
_.bindAll.apply(null, [walker].concat(_.keys(walker)));
|
||||
|
||||
walker._traversalStrategy = traversalStrategy || defaultTraversal;
|
||||
return walker;
|
||||
};
|
||||
|
||||
// Use `_.walk` as a namespace to hold versions of the walk functions which
|
||||
// use the default traversal strategy.
|
||||
_.extend(_.walk, _.walk());
|
||||
})(this);
|
||||
200
node_modules/catharsis/node_modules/underscore-contrib/underscore.function.arity.js
generated
vendored
200
node_modules/catharsis/node_modules/underscore-contrib/underscore.function.arity.js
generated
vendored
@ -1,200 +0,0 @@
|
||||
// Underscore-contrib (underscore.function.arity.js 0.3.0)
|
||||
// (c) 2013 Michael Fogus, DocumentCloud and Investigative Reporters & Editors
|
||||
// Underscore-contrib may be freely distributed under the MIT license.
|
||||
|
||||
(function(root) {
|
||||
|
||||
// Baseline setup
|
||||
// --------------
|
||||
|
||||
// Establish the root object, `window` in the browser, or `global` on the server.
|
||||
var _ = root._ || require('underscore');
|
||||
|
||||
// Helpers
|
||||
// -------
|
||||
|
||||
function enforcesUnary (fn) {
|
||||
return function mustBeUnary () {
|
||||
if (arguments.length === 1) {
|
||||
return fn.apply(this, arguments);
|
||||
}
|
||||
else throw new RangeError('Only a single argument may be accepted.');
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
// Curry
|
||||
// -------
|
||||
var curry = (function () {
|
||||
function collectArgs(func, that, argCount, args, newArg, reverse) {
|
||||
if (reverse === true) {
|
||||
args.unshift(newArg);
|
||||
} else {
|
||||
args.push(newArg);
|
||||
}
|
||||
if (args.length == argCount) {
|
||||
return func.apply(that, args);
|
||||
} else {
|
||||
return enforcesUnary(function () {
|
||||
return collectArgs(func, that, argCount, args.slice(0), arguments[0], reverse);
|
||||
});
|
||||
}
|
||||
}
|
||||
return function curry (func, reverse) {
|
||||
var that = this;
|
||||
return enforcesUnary(function () {
|
||||
return collectArgs(func, that, func.length, [], arguments[0], reverse);
|
||||
});
|
||||
};
|
||||
}());
|
||||
|
||||
// Enforce Arity
|
||||
// --------------------
|
||||
var enforce = (function () {
|
||||
var CACHE = [];
|
||||
return function enforce (func) {
|
||||
if (typeof func !== 'function') {
|
||||
throw new Error('Argument 1 must be a function.');
|
||||
}
|
||||
var funcLength = func.length;
|
||||
if (CACHE[funcLength] === undefined) {
|
||||
CACHE[funcLength] = function (enforceFunc) {
|
||||
return function () {
|
||||
if (arguments.length !== funcLength) {
|
||||
throw new RangeError(funcLength + ' arguments must be applied.');
|
||||
}
|
||||
return enforceFunc.apply(this, arguments);
|
||||
};
|
||||
};
|
||||
}
|
||||
return CACHE[funcLength](func);
|
||||
};
|
||||
}());
|
||||
|
||||
// Mixing in the arity functions
|
||||
// -----------------------------
|
||||
|
||||
_.mixin({
|
||||
// ### Fixed arguments
|
||||
|
||||
// Fixes the arguments to a function based on the parameter template defined by
|
||||
// the presence of values and the `_` placeholder.
|
||||
fix: function(fun) {
|
||||
var fixArgs = _.rest(arguments);
|
||||
|
||||
var f = function() {
|
||||
var args = fixArgs.slice();
|
||||
var arg = 0;
|
||||
|
||||
for ( var i = 0; i < (args.length || arg < arguments.length); i++ ) {
|
||||
if ( args[i] === _ ) {
|
||||
args[i] = arguments[arg++];
|
||||
}
|
||||
}
|
||||
|
||||
return fun.apply(null, args);
|
||||
};
|
||||
|
||||
f._original = fun;
|
||||
|
||||
return f;
|
||||
},
|
||||
|
||||
unary: function (fun) {
|
||||
return function unary (a) {
|
||||
return fun.call(this, a);
|
||||
};
|
||||
},
|
||||
|
||||
binary: function (fun) {
|
||||
return function binary (a, b) {
|
||||
return fun.call(this, a, b);
|
||||
};
|
||||
},
|
||||
|
||||
ternary: function (fun) {
|
||||
return function ternary (a, b, c) {
|
||||
return fun.call(this, a, b, c);
|
||||
};
|
||||
},
|
||||
|
||||
quaternary: function (fun) {
|
||||
return function quaternary (a, b, c, d) {
|
||||
return fun.call(this, a, b, c, d);
|
||||
};
|
||||
},
|
||||
|
||||
// Flexible curry function with strict arity.
|
||||
// Argument application left to right.
|
||||
// source: https://github.com/eborden/js-curry
|
||||
curry: curry,
|
||||
|
||||
// Flexible right to left curry with strict arity.
|
||||
rCurry: function (func) {
|
||||
return curry.call(this, func, true);
|
||||
},
|
||||
|
||||
|
||||
curry2: function (fun) {
|
||||
return enforcesUnary(function curried (first) {
|
||||
return enforcesUnary(function (last) {
|
||||
return fun.call(this, first, last);
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
curry3: function (fun) {
|
||||
return enforcesUnary(function (first) {
|
||||
return enforcesUnary(function (second) {
|
||||
return enforcesUnary(function (last) {
|
||||
return fun.call(this, first, second, last);
|
||||
});
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
// reverse currying for functions taking two arguments.
|
||||
rcurry2: function (fun) {
|
||||
return enforcesUnary(function (last) {
|
||||
return enforcesUnary(function (first) {
|
||||
return fun.call(this, first, last);
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
rcurry3: function (fun) {
|
||||
return enforcesUnary(function (last) {
|
||||
return enforcesUnary(function (second) {
|
||||
return enforcesUnary(function (first) {
|
||||
return fun.call(this, first, second, last);
|
||||
});
|
||||
});
|
||||
});
|
||||
},
|
||||
// Dynamic decorator to enforce function arity and defeat varargs.
|
||||
enforce: enforce
|
||||
});
|
||||
|
||||
_.arity = (function () {
|
||||
// Allow 'new Function', as that is currently the only reliable way
|
||||
// to manipulate function.length
|
||||
/* jshint -W054 */
|
||||
var FUNCTIONS = {};
|
||||
return function arity (numberOfArgs, fun) {
|
||||
if (FUNCTIONS[numberOfArgs] == null) {
|
||||
var parameters = new Array(numberOfArgs);
|
||||
for (var i = 0; i < numberOfArgs; ++i) {
|
||||
parameters[i] = "__" + i;
|
||||
}
|
||||
var pstr = parameters.join();
|
||||
var code = "return function ("+pstr+") { return fun.apply(this, arguments); };";
|
||||
FUNCTIONS[numberOfArgs] = new Function(['fun'], code);
|
||||
}
|
||||
if (fun == null) {
|
||||
return function (fun) { return arity(numberOfArgs, fun); };
|
||||
}
|
||||
else return FUNCTIONS[numberOfArgs](fun);
|
||||
};
|
||||
})();
|
||||
|
||||
})(this);
|
||||
266
node_modules/catharsis/node_modules/underscore-contrib/underscore.function.combinators.js
generated
vendored
266
node_modules/catharsis/node_modules/underscore-contrib/underscore.function.combinators.js
generated
vendored
@ -1,266 +0,0 @@
|
||||
// Underscore-contrib (underscore.function.combinators.js 0.3.0)
|
||||
// (c) 2013 Michael Fogus, DocumentCloud and Investigative Reporters & Editors
|
||||
// Underscore-contrib may be freely distributed under the MIT license.
|
||||
|
||||
(function(root) {
|
||||
|
||||
// Baseline setup
|
||||
// --------------
|
||||
|
||||
// Establish the root object, `window` in the browser, or `global` on the server.
|
||||
var _ = root._ || require('underscore');
|
||||
|
||||
// Helpers
|
||||
// -------
|
||||
|
||||
var existy = function(x) { return x != null; };
|
||||
var truthy = function(x) { return (x !== false) && existy(x); };
|
||||
var __reverse = [].reverse;
|
||||
var __slice = [].slice;
|
||||
var __map = [].map;
|
||||
var curry2 = function (fun) {
|
||||
return function curried (first, optionalLast) {
|
||||
if (arguments.length === 1) {
|
||||
return function (last) {
|
||||
return fun(first, last);
|
||||
};
|
||||
}
|
||||
else return fun(first, optionalLast);
|
||||
};
|
||||
};
|
||||
|
||||
// n.b. depends on underscore.function.arity.js
|
||||
|
||||
// Takes a target function and a mapping function. Returns a function
|
||||
// that applies the mapper to its arguments before evaluating the body.
|
||||
function baseMapArgs (fun, mapFun) {
|
||||
return _.arity(fun.length, function () {
|
||||
return fun.apply(this, __map.call(arguments, mapFun));
|
||||
});
|
||||
}
|
||||
|
||||
// Mixing in the combinator functions
|
||||
// ----------------------------------
|
||||
|
||||
_.mixin({
|
||||
// Provide "always" alias for backwards compatibility
|
||||
always: _.constant,
|
||||
|
||||
// Takes some number of functions, either as an array or variadically
|
||||
// and returns a function that takes some value as its first argument
|
||||
// and runs it through a pipeline of the original functions given.
|
||||
pipeline: function(/*, funs */){
|
||||
var funs = (_.isArray(arguments[0])) ? arguments[0] : arguments;
|
||||
|
||||
return function(seed) {
|
||||
return _.reduce(funs,
|
||||
function(l,r) { return r(l); },
|
||||
seed);
|
||||
};
|
||||
},
|
||||
|
||||
// Composes a bunch of predicates into a single predicate that
|
||||
// checks all elements of an array for conformance to all of the
|
||||
// original predicates.
|
||||
conjoin: function(/* preds */) {
|
||||
var preds = arguments;
|
||||
|
||||
return function(array) {
|
||||
return _.every(array, function(e) {
|
||||
return _.every(preds, function(p) {
|
||||
return p(e);
|
||||
});
|
||||
});
|
||||
};
|
||||
},
|
||||
|
||||
// Composes a bunch of predicates into a single predicate that
|
||||
// checks all elements of an array for conformance to any of the
|
||||
// original predicates.
|
||||
disjoin: function(/* preds */) {
|
||||
var preds = arguments;
|
||||
|
||||
return function(array) {
|
||||
return _.some(array, function(e) {
|
||||
return _.some(preds, function(p) {
|
||||
return p(e);
|
||||
});
|
||||
});
|
||||
};
|
||||
},
|
||||
|
||||
// Takes a predicate-like and returns a comparator (-1,0,1).
|
||||
comparator: function(fun) {
|
||||
return function(x, y) {
|
||||
if (truthy(fun(x, y)))
|
||||
return -1;
|
||||
else if (truthy(fun(y, x)))
|
||||
return 1;
|
||||
else
|
||||
return 0;
|
||||
};
|
||||
},
|
||||
|
||||
// Returns a function that reverses the sense of a given predicate-like.
|
||||
complement: function(pred) {
|
||||
return function() {
|
||||
return !pred.apply(this, arguments);
|
||||
};
|
||||
},
|
||||
|
||||
// Takes a function expecting varargs and
|
||||
// returns a function that takes an array and
|
||||
// uses its elements as the args to the original
|
||||
// function
|
||||
splat: function(fun) {
|
||||
return function(array) {
|
||||
return fun.apply(this, array);
|
||||
};
|
||||
},
|
||||
|
||||
// Takes a function expecting an array and returns
|
||||
// a function that takes varargs and wraps all
|
||||
// in an array that is passed to the original function.
|
||||
unsplat: function(fun) {
|
||||
var funLength = fun.length;
|
||||
|
||||
if (funLength < 1) {
|
||||
return fun;
|
||||
}
|
||||
else if (funLength === 1) {
|
||||
return function () {
|
||||
return fun.call(this, __slice.call(arguments, 0));
|
||||
};
|
||||
}
|
||||
else {
|
||||
return function () {
|
||||
var numberOfArgs = arguments.length,
|
||||
namedArgs = __slice.call(arguments, 0, funLength - 1),
|
||||
numberOfMissingNamedArgs = Math.max(funLength - numberOfArgs - 1, 0),
|
||||
argPadding = new Array(numberOfMissingNamedArgs),
|
||||
variadicArgs = __slice.call(arguments, fun.length - 1);
|
||||
|
||||
return fun.apply(this, namedArgs.concat(argPadding).concat([variadicArgs]));
|
||||
};
|
||||
}
|
||||
},
|
||||
|
||||
// Same as unsplat, but the rest of the arguments are collected in the
|
||||
// first parameter, e.g. unsplatl( function (args, callback) { ... ]})
|
||||
unsplatl: function(fun) {
|
||||
var funLength = fun.length;
|
||||
|
||||
if (funLength < 1) {
|
||||
return fun;
|
||||
}
|
||||
else if (funLength === 1) {
|
||||
return function () {
|
||||
return fun.call(this, __slice.call(arguments, 0));
|
||||
};
|
||||
}
|
||||
else {
|
||||
return function () {
|
||||
var numberOfArgs = arguments.length,
|
||||
namedArgs = __slice.call(arguments, Math.max(numberOfArgs - funLength + 1, 0)),
|
||||
variadicArgs = __slice.call(arguments, 0, Math.max(numberOfArgs - funLength + 1, 0));
|
||||
|
||||
return fun.apply(this, [variadicArgs].concat(namedArgs));
|
||||
};
|
||||
}
|
||||
},
|
||||
|
||||
// map the arguments of a function
|
||||
mapArgs: curry2(baseMapArgs),
|
||||
|
||||
// Returns a function that returns an array of the calls to each
|
||||
// given function for some arguments.
|
||||
juxt: function(/* funs */) {
|
||||
var funs = arguments;
|
||||
|
||||
return function(/* args */) {
|
||||
var args = arguments;
|
||||
return _.map(funs, function(f) {
|
||||
return f.apply(this, args);
|
||||
}, this);
|
||||
};
|
||||
},
|
||||
|
||||
// Returns a function that protects a given function from receiving
|
||||
// non-existy values. Each subsequent value provided to `fnull` acts
|
||||
// as the default to the original function should a call receive non-existy
|
||||
// values in the defaulted arg slots.
|
||||
fnull: function(fun /*, defaults */) {
|
||||
var defaults = _.rest(arguments);
|
||||
|
||||
return function(/*args*/) {
|
||||
var args = _.toArray(arguments);
|
||||
var sz = _.size(defaults);
|
||||
|
||||
for(var i = 0; i < sz; i++) {
|
||||
if (!existy(args[i]))
|
||||
args[i] = defaults[i];
|
||||
}
|
||||
|
||||
return fun.apply(this, args);
|
||||
};
|
||||
},
|
||||
|
||||
// Flips the first two args of a function
|
||||
flip2: function(fun) {
|
||||
return function(/* args */) {
|
||||
var flipped = __slice.call(arguments);
|
||||
flipped[0] = arguments[1];
|
||||
flipped[1] = arguments[0];
|
||||
|
||||
return fun.apply(this, flipped);
|
||||
};
|
||||
},
|
||||
|
||||
// Flips an arbitrary number of args of a function
|
||||
flip: function(fun) {
|
||||
return function(/* args */) {
|
||||
var reversed = __reverse.call(arguments);
|
||||
|
||||
return fun.apply(this, reversed);
|
||||
};
|
||||
},
|
||||
|
||||
// Takes a method-style function (one which uses `this`) and pushes
|
||||
// `this` into the argument list. The returned function uses its first
|
||||
// argument as the receiver/context of the original function, and the rest
|
||||
// of the arguments are used as the original's entire argument list.
|
||||
functionalize: function(method) {
|
||||
return function(ctx /*, args */) {
|
||||
return method.apply(ctx, _.rest(arguments));
|
||||
};
|
||||
},
|
||||
|
||||
// Takes a function and pulls the first argument out of the argument
|
||||
// list and into `this` position. The returned function calls the original
|
||||
// with its receiver (`this`) prepending the argument list. The original
|
||||
// is called with a receiver of `null`.
|
||||
methodize: function(func) {
|
||||
return function(/* args */) {
|
||||
return func.apply(null, _.cons(this, arguments));
|
||||
};
|
||||
},
|
||||
|
||||
k: _.always,
|
||||
t: _.pipeline
|
||||
});
|
||||
|
||||
_.unsplatr = _.unsplat;
|
||||
|
||||
// map the arguments of a function, takes the mapping function
|
||||
// first so it can be used as a combinator
|
||||
_.mapArgsWith = curry2(_.flip(baseMapArgs));
|
||||
|
||||
// Returns function property of object by name, bound to object
|
||||
_.bound = function(obj, fname) {
|
||||
var fn = obj[fname];
|
||||
if (!_.isFunction(fn))
|
||||
throw new TypeError("Expected property to be a function");
|
||||
return _.bind(fn, obj);
|
||||
};
|
||||
|
||||
})(this);
|
||||
33
node_modules/catharsis/node_modules/underscore-contrib/underscore.function.dispatch.js
generated
vendored
33
node_modules/catharsis/node_modules/underscore-contrib/underscore.function.dispatch.js
generated
vendored
@ -1,33 +0,0 @@
|
||||
// Underscore-contrib (underscore.function.dispatch.js 0.3.0)
|
||||
// (c) 2013 Justin Ridgewell
|
||||
// Underscore-contrib may be freely distributed under the MIT license.
|
||||
|
||||
(function(root) {
|
||||
|
||||
// Baseline setup
|
||||
// --------------
|
||||
|
||||
// Establish the root object, `window` in the browser, or `global` on the server.
|
||||
var _ = root._ || require('underscore');
|
||||
|
||||
// Helpers
|
||||
// -------
|
||||
|
||||
// Create quick reference variable for speed.
|
||||
var slice = Array.prototype.slice;
|
||||
|
||||
// Mixing in the attempt function
|
||||
// ------------------------
|
||||
|
||||
_.mixin({
|
||||
// If object is not undefined or null then invoke the named `method` function
|
||||
// with `object` as context and arguments; otherwise, return undefined.
|
||||
attempt: function(object, method) {
|
||||
if (object == null) return void 0;
|
||||
var func = object[method];
|
||||
var args = slice.call(arguments, 2);
|
||||
return _.isFunction(func) ? func.apply(object, args) : void 0;
|
||||
}
|
||||
});
|
||||
|
||||
})(this);
|
||||
334
node_modules/catharsis/node_modules/underscore-contrib/underscore.function.iterators.js
generated
vendored
334
node_modules/catharsis/node_modules/underscore-contrib/underscore.function.iterators.js
generated
vendored
@ -1,334 +0,0 @@
|
||||
// Underscore-contrib (underscore.function.iterators.js 0.3.0)
|
||||
// (c) 2013 Michael Fogus and DocumentCloud Inc.
|
||||
// Underscore-contrib may be freely distributed under the MIT license.
|
||||
|
||||
(function(root, undefined) {
|
||||
|
||||
// Baseline setup
|
||||
// --------------
|
||||
|
||||
// Establish the root object, `window` in the browser, or `global` on the server.
|
||||
var _ = root._ || require('underscore');
|
||||
|
||||
// Helpers
|
||||
// -------
|
||||
|
||||
var HASNTBEENRUN = {};
|
||||
|
||||
function unary (fun) {
|
||||
return function (first) {
|
||||
return fun.call(this, first);
|
||||
};
|
||||
}
|
||||
|
||||
function binary (fun) {
|
||||
return function (first, second) {
|
||||
return fun.call(this, first, second);
|
||||
};
|
||||
}
|
||||
|
||||
// Mixing in the iterator functions
|
||||
// --------------------------------
|
||||
|
||||
function foldl (iter, binaryFn, seed) {
|
||||
var state, element;
|
||||
if (seed !== void 0) {
|
||||
state = seed;
|
||||
}
|
||||
else {
|
||||
state = iter();
|
||||
}
|
||||
element = iter();
|
||||
while (element != null) {
|
||||
state = binaryFn.call(element, state, element);
|
||||
element = iter();
|
||||
}
|
||||
return state;
|
||||
}
|
||||
|
||||
function unfold (seed, unaryFn) {
|
||||
var state = HASNTBEENRUN;
|
||||
return function () {
|
||||
if (state === HASNTBEENRUN) {
|
||||
state = seed;
|
||||
} else if (state != null) {
|
||||
state = unaryFn.call(state, state);
|
||||
}
|
||||
|
||||
return state;
|
||||
};
|
||||
}
|
||||
|
||||
// note that the unfoldWithReturn behaves differently than
|
||||
// unfold with respect to the first value returned
|
||||
function unfoldWithReturn (seed, unaryFn) {
|
||||
var state = seed,
|
||||
pair,
|
||||
value;
|
||||
return function () {
|
||||
if (state != null) {
|
||||
pair = unaryFn.call(state, state);
|
||||
value = pair[1];
|
||||
state = value != null ? pair[0] : void 0;
|
||||
return value;
|
||||
}
|
||||
else return void 0;
|
||||
};
|
||||
}
|
||||
|
||||
function accumulate (iter, binaryFn, initial) {
|
||||
var state = initial;
|
||||
return function () {
|
||||
var element = iter();
|
||||
if (element == null) {
|
||||
return element;
|
||||
}
|
||||
else {
|
||||
if (state === void 0) {
|
||||
state = element;
|
||||
} else {
|
||||
state = binaryFn.call(element, state, element);
|
||||
}
|
||||
|
||||
return state;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function accumulateWithReturn (iter, binaryFn, initial) {
|
||||
var state = initial,
|
||||
stateAndReturnValue,
|
||||
element;
|
||||
return function () {
|
||||
element = iter();
|
||||
if (element == null) {
|
||||
return element;
|
||||
}
|
||||
else {
|
||||
if (state === void 0) {
|
||||
state = element;
|
||||
return state;
|
||||
}
|
||||
else {
|
||||
stateAndReturnValue = binaryFn.call(element, state, element);
|
||||
state = stateAndReturnValue[0];
|
||||
return stateAndReturnValue[1];
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function map (iter, unaryFn) {
|
||||
return function() {
|
||||
var element;
|
||||
element = iter();
|
||||
if (element != null) {
|
||||
return unaryFn.call(element, element);
|
||||
} else {
|
||||
return void 0;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function mapcat(iter, unaryFn) {
|
||||
var lastIter = null;
|
||||
return function() {
|
||||
var element;
|
||||
var gen;
|
||||
if (lastIter == null) {
|
||||
gen = iter();
|
||||
if (gen == null) {
|
||||
lastIter = null;
|
||||
return void 0;
|
||||
}
|
||||
lastIter = unaryFn.call(gen, gen);
|
||||
}
|
||||
while (element == null) {
|
||||
element = lastIter();
|
||||
if (element == null) {
|
||||
gen = iter();
|
||||
if (gen == null) {
|
||||
lastIter = null;
|
||||
return void 0;
|
||||
}
|
||||
else {
|
||||
lastIter = unaryFn.call(gen, gen);
|
||||
}
|
||||
}
|
||||
}
|
||||
return element;
|
||||
};
|
||||
}
|
||||
|
||||
function select (iter, unaryPredicateFn) {
|
||||
return function() {
|
||||
var element;
|
||||
element = iter();
|
||||
while (element != null) {
|
||||
if (unaryPredicateFn.call(element, element)) {
|
||||
return element;
|
||||
}
|
||||
element = iter();
|
||||
}
|
||||
return void 0;
|
||||
};
|
||||
}
|
||||
|
||||
function reject (iter, unaryPredicateFn) {
|
||||
return select(iter, function (something) {
|
||||
return !unaryPredicateFn(something);
|
||||
});
|
||||
}
|
||||
|
||||
function find (iter, unaryPredicateFn) {
|
||||
return select(iter, unaryPredicateFn)();
|
||||
}
|
||||
|
||||
function slice (iter, numberToDrop, numberToTake) {
|
||||
var count = 0;
|
||||
while (numberToDrop-- > 0) {
|
||||
iter();
|
||||
}
|
||||
if (numberToTake != null) {
|
||||
return function() {
|
||||
if (++count <= numberToTake) {
|
||||
return iter();
|
||||
} else {
|
||||
return void 0;
|
||||
}
|
||||
};
|
||||
}
|
||||
else return iter;
|
||||
}
|
||||
|
||||
function drop (iter, numberToDrop) {
|
||||
return slice(iter, numberToDrop == null ? 1 : numberToDrop);
|
||||
}
|
||||
|
||||
function take (iter, numberToTake) {
|
||||
return slice(iter, 0, numberToTake == null ? 1 : numberToTake);
|
||||
}
|
||||
|
||||
function List (array) {
|
||||
var index = 0;
|
||||
return function() {
|
||||
return array[index++];
|
||||
};
|
||||
}
|
||||
|
||||
function Tree (array) {
|
||||
var index, myself, state;
|
||||
index = 0;
|
||||
state = [];
|
||||
myself = function() {
|
||||
var element, tempState;
|
||||
element = array[index++];
|
||||
if (element instanceof Array) {
|
||||
state.push({
|
||||
array: array,
|
||||
index: index
|
||||
});
|
||||
array = element;
|
||||
index = 0;
|
||||
return myself();
|
||||
} else if (element === void 0) {
|
||||
if (state.length > 0) {
|
||||
tempState = state.pop();
|
||||
array = tempState.array;
|
||||
index = tempState.index;
|
||||
return myself();
|
||||
} else {
|
||||
return void 0;
|
||||
}
|
||||
} else {
|
||||
return element;
|
||||
}
|
||||
};
|
||||
return myself;
|
||||
}
|
||||
|
||||
function K (value) {
|
||||
return function () {
|
||||
return value;
|
||||
};
|
||||
}
|
||||
|
||||
function upRange (from, to, by) {
|
||||
return function () {
|
||||
var was;
|
||||
|
||||
if (from > to) {
|
||||
return void 0;
|
||||
}
|
||||
else {
|
||||
was = from;
|
||||
from = from + by;
|
||||
return was;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function downRange (from, to, by) {
|
||||
return function () {
|
||||
var was;
|
||||
|
||||
if (from < to) {
|
||||
return void 0;
|
||||
}
|
||||
else {
|
||||
was = from;
|
||||
from = from - by;
|
||||
return was;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function range (from, to, by) {
|
||||
if (from == null) {
|
||||
return upRange(1, Infinity, 1);
|
||||
}
|
||||
else if (to == null) {
|
||||
return upRange(from, Infinity, 1);
|
||||
}
|
||||
else if (by == null) {
|
||||
if (from <= to) {
|
||||
return upRange(from, to, 1);
|
||||
}
|
||||
else return downRange(from, to, 1);
|
||||
}
|
||||
else if (by > 0) {
|
||||
return upRange(from, to, by);
|
||||
}
|
||||
else if (by < 0) {
|
||||
return downRange(from, to, Math.abs(by));
|
||||
}
|
||||
else return k(from);
|
||||
}
|
||||
|
||||
var numbers = unary(range);
|
||||
|
||||
_.iterators = {
|
||||
accumulate: accumulate,
|
||||
accumulateWithReturn: accumulateWithReturn,
|
||||
foldl: foldl,
|
||||
reduce: foldl,
|
||||
unfold: unfold,
|
||||
unfoldWithReturn: unfoldWithReturn,
|
||||
map: map,
|
||||
mapcat: mapcat,
|
||||
select: select,
|
||||
reject: reject,
|
||||
filter: select,
|
||||
find: find,
|
||||
slice: slice,
|
||||
drop: drop,
|
||||
take: take,
|
||||
List: List,
|
||||
Tree: Tree,
|
||||
constant: K,
|
||||
K: K,
|
||||
numbers: numbers,
|
||||
range: range
|
||||
};
|
||||
|
||||
})(this, void 0);
|
||||
112
node_modules/catharsis/node_modules/underscore-contrib/underscore.function.predicates.js
generated
vendored
112
node_modules/catharsis/node_modules/underscore-contrib/underscore.function.predicates.js
generated
vendored
@ -1,112 +0,0 @@
|
||||
// Underscore-contrib (underscore.function.predicates.js 0.3.0)
|
||||
// (c) 2013 Michael Fogus, DocumentCloud and Investigative Reporters & Editors
|
||||
// Underscore-contrib may be freely distributed under the MIT license.
|
||||
|
||||
(function(root) {
|
||||
|
||||
// Baseline setup
|
||||
// --------------
|
||||
|
||||
// Establish the root object, `window` in the browser, or `global` on the server.
|
||||
var _ = root._ || require('underscore');
|
||||
|
||||
// Helpers
|
||||
// -------
|
||||
|
||||
|
||||
// Mixing in the predicate functions
|
||||
// ---------------------------------
|
||||
|
||||
_.mixin({
|
||||
// A wrapper around instanceof
|
||||
isInstanceOf: function(x, t) { return (x instanceof t); },
|
||||
|
||||
// An associative object is one where its elements are
|
||||
// accessed via a key or index. (i.e. array and object)
|
||||
isAssociative: function(x) { return _.isArray(x) || _.isObject(x) || _.isArguments(x); },
|
||||
|
||||
// An indexed object is anything that allows numerical index for
|
||||
// accessing its elements (e.g. arrays and strings). NOTE: Underscore
|
||||
// does not support cross-browser consistent use of strings as array-like
|
||||
// objects, so be wary in IE 8 when using String objects and IE<8.
|
||||
// on string literals & objects.
|
||||
isIndexed: function(x) { return _.isArray(x) || _.isString(x) || _.isArguments(x); },
|
||||
|
||||
// A seq is something considered a sequential composite type (i.e. arrays and `arguments`).
|
||||
isSequential: function(x) { return (_.isArray(x)) || (_.isArguments(x)); },
|
||||
|
||||
// Check if an object is an object literal, since _.isObject(function() {}) === _.isObject([]) === true
|
||||
isPlainObject: function(x) { return _.isObject(x) && x.constructor === root.Object; },
|
||||
|
||||
// These do what you think that they do
|
||||
isZero: function(x) { return 0 === x; },
|
||||
isEven: function(x) { return _.isFinite(x) && (x & 1) === 0; },
|
||||
isOdd: function(x) { return _.isFinite(x) && !_.isEven(x); },
|
||||
isPositive: function(x) { return x > 0; },
|
||||
isNegative: function(x) { return x < 0; },
|
||||
isValidDate: function(x) { return _.isDate(x) && !_.isNaN(x.getTime()); },
|
||||
|
||||
// A numeric is a variable that contains a numeric value, regardless its type
|
||||
// It can be a String containing a numeric value, exponential notation, or a Number object
|
||||
// See here for more discussion: http://stackoverflow.com/questions/18082/validate-numbers-in-javascript-isnumeric/1830844#1830844
|
||||
isNumeric: function(n) {
|
||||
return !isNaN(parseFloat(n)) && isFinite(n);
|
||||
},
|
||||
|
||||
// An integer contains an optional minus sign to begin and only the digits 0-9
|
||||
// Objects that can be parsed that way are also considered ints, e.g. "123"
|
||||
// Floats that are mathematically equal to integers are considered integers, e.g. 1.0
|
||||
// See here for more discussion: http://stackoverflow.com/questions/1019515/javascript-test-for-an-integer
|
||||
isInteger: function(i) {
|
||||
return _.isNumeric(i) && i % 1 === 0;
|
||||
},
|
||||
|
||||
// A float is a numbr that is not an integer.
|
||||
isFloat: function(n) {
|
||||
return _.isNumeric(n) && !_.isInteger(n);
|
||||
},
|
||||
|
||||
// checks if a string is a valid JSON
|
||||
isJSON: function(str) {
|
||||
try {
|
||||
JSON.parse(str);
|
||||
} catch (e) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
},
|
||||
|
||||
// Returns true if its arguments are monotonically
|
||||
// increaing values; false otherwise.
|
||||
isIncreasing: function() {
|
||||
var count = _.size(arguments);
|
||||
if (count === 1) return true;
|
||||
if (count === 2) return arguments[0] < arguments[1];
|
||||
|
||||
for (var i = 1; i < count; i++) {
|
||||
if (arguments[i-1] >= arguments[i]) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
},
|
||||
|
||||
// Returns true if its arguments are monotonically
|
||||
// decreaing values; false otherwise.
|
||||
isDecreasing: function() {
|
||||
var count = _.size(arguments);
|
||||
if (count === 1) return true;
|
||||
if (count === 2) return arguments[0] > arguments[1];
|
||||
|
||||
for (var i = 1; i < count; i++) {
|
||||
if (arguments[i-1] <= arguments[i]) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
})(this);
|
||||
120
node_modules/catharsis/node_modules/underscore-contrib/underscore.object.builders.js
generated
vendored
120
node_modules/catharsis/node_modules/underscore-contrib/underscore.object.builders.js
generated
vendored
@ -1,120 +0,0 @@
|
||||
// Underscore-contrib (underscore.object.builders.js 0.3.0)
|
||||
// (c) 2013 Michael Fogus, DocumentCloud and Investigative Reporters & Editors
|
||||
// Underscore-contrib may be freely distributed under the MIT license.
|
||||
|
||||
(function(root) {
|
||||
|
||||
// Baseline setup
|
||||
// --------------
|
||||
|
||||
// Establish the root object, `window` in the browser, or `global` on the server.
|
||||
var _ = root._ || require('underscore');
|
||||
|
||||
// Helpers
|
||||
// -------
|
||||
|
||||
// Create quick reference variables for speed access to core prototypes.
|
||||
var slice = Array.prototype.slice,
|
||||
concat = Array.prototype.concat;
|
||||
|
||||
var existy = function(x) { return x != null; };
|
||||
var truthy = function(x) { return (x !== false) && existy(x); };
|
||||
var isAssociative = function(x) { return _.isArray(x) || _.isObject(x); };
|
||||
var curry2 = function(fun) {
|
||||
return function(last) {
|
||||
return function(first) {
|
||||
return fun(first, last);
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
// Mixing in the object builders
|
||||
// ----------------------------
|
||||
|
||||
_.mixin({
|
||||
// Merges two or more objects starting with the left-most and
|
||||
// applying the keys right-word
|
||||
// {any:any}* -> {any:any}
|
||||
merge: function(/* objs */){
|
||||
var dest = _.some(arguments) ? {} : null;
|
||||
|
||||
if (truthy(dest)) {
|
||||
_.extend.apply(null, concat.call([dest], _.toArray(arguments)));
|
||||
}
|
||||
|
||||
return dest;
|
||||
},
|
||||
|
||||
// Takes an object and another object of strings to strings where the second
|
||||
// object describes the key renaming to occur in the first object.
|
||||
renameKeys: function(obj, kobj) {
|
||||
return _.reduce(kobj, function(o, nu, old) {
|
||||
if (existy(obj[old])) {
|
||||
o[nu] = obj[old];
|
||||
return o;
|
||||
}
|
||||
else
|
||||
return o;
|
||||
},
|
||||
_.omit.apply(null, concat.call([obj], _.keys(kobj))));
|
||||
},
|
||||
|
||||
// Snapshots an object deeply. Based on the version by
|
||||
// [Keith Devens](http://keithdevens.com/weblog/archive/2007/Jun/07/javascript.clone)
|
||||
// until we can find a more efficient and robust way to do it.
|
||||
snapshot: function(obj) {
|
||||
if(obj == null || typeof(obj) != 'object') {
|
||||
return obj;
|
||||
}
|
||||
|
||||
var temp = new obj.constructor();
|
||||
|
||||
for(var key in obj) {
|
||||
if (obj.hasOwnProperty(key)) {
|
||||
temp[key] = _.snapshot(obj[key]);
|
||||
}
|
||||
}
|
||||
|
||||
return temp;
|
||||
},
|
||||
|
||||
// Updates the value at any depth in a nested object based on the
|
||||
// path described by the keys given. The function provided is supplied
|
||||
// the current value and is expected to return a value for use as the
|
||||
// new value. If no keys are provided, then the object itself is presented
|
||||
// to the given function.
|
||||
updatePath: function(obj, fun, ks, defaultValue) {
|
||||
if (!isAssociative(obj)) throw new TypeError("Attempted to update a non-associative object.");
|
||||
if (!existy(ks)) return fun(obj);
|
||||
|
||||
var deepness = _.isArray(ks);
|
||||
var keys = deepness ? ks : [ks];
|
||||
var ret = deepness ? _.snapshot(obj) : _.clone(obj);
|
||||
var lastKey = _.last(keys);
|
||||
var target = ret;
|
||||
|
||||
_.each(_.initial(keys), function(key) {
|
||||
if (defaultValue && !_.has(target, key)) {
|
||||
target[key] = _.clone(defaultValue);
|
||||
}
|
||||
target = target[key];
|
||||
});
|
||||
|
||||
target[lastKey] = fun(target[lastKey]);
|
||||
return ret;
|
||||
},
|
||||
|
||||
// Sets the value at any depth in a nested object based on the
|
||||
// path described by the keys given.
|
||||
setPath: function(obj, value, ks, defaultValue) {
|
||||
if (!existy(ks)) throw new TypeError("Attempted to set a property at a null path.");
|
||||
|
||||
return _.updatePath(obj, function() { return value; }, ks, defaultValue);
|
||||
},
|
||||
|
||||
// Returns an object where each element of an array is keyed to
|
||||
// the number of times that it occurred in said array.
|
||||
frequencies: curry2(_.countBy)(_.identity)
|
||||
});
|
||||
|
||||
})(this);
|
||||
108
node_modules/catharsis/node_modules/underscore-contrib/underscore.object.selectors.js
generated
vendored
108
node_modules/catharsis/node_modules/underscore-contrib/underscore.object.selectors.js
generated
vendored
@ -1,108 +0,0 @@
|
||||
// Underscore-contrib (underscore.object.selectors.js 0.3.0)
|
||||
// (c) 2013 Michael Fogus, DocumentCloud and Investigative Reporters & Editors
|
||||
// Underscore-contrib may be freely distributed under the MIT license.
|
||||
|
||||
(function(root) {
|
||||
|
||||
// Baseline setup
|
||||
// --------------
|
||||
|
||||
// Establish the root object, `window` in the browser, or `global` on the server.
|
||||
var _ = root._ || require('underscore');
|
||||
|
||||
// Helpers
|
||||
// -------
|
||||
|
||||
// Create quick reference variables for speed access to core prototypes.
|
||||
var concat = Array.prototype.concat;
|
||||
var ArrayProto = Array.prototype;
|
||||
var slice = ArrayProto.slice;
|
||||
|
||||
// Mixing in the object selectors
|
||||
// ------------------------------
|
||||
|
||||
_.mixin({
|
||||
// Returns a function that will attempt to look up a named field
|
||||
// in any object that it's given.
|
||||
accessor: function(field) {
|
||||
return function(obj) {
|
||||
return (obj && obj[field]);
|
||||
};
|
||||
},
|
||||
|
||||
// Given an object, returns a function that will attempt to look up a field
|
||||
// that it's given.
|
||||
dictionary: function (obj) {
|
||||
return function(field) {
|
||||
return (obj && field && obj[field]);
|
||||
};
|
||||
},
|
||||
|
||||
// Like `_.pick` except that it takes an array of keys to pick.
|
||||
selectKeys: function (obj, ks) {
|
||||
return _.pick.apply(null, concat.call([obj], ks));
|
||||
},
|
||||
|
||||
// Returns the key/value pair for a given property in an object, undefined if not found.
|
||||
kv: function(obj, key) {
|
||||
if (_.has(obj, key)) {
|
||||
return [key, obj[key]];
|
||||
}
|
||||
|
||||
return void 0;
|
||||
},
|
||||
|
||||
// Gets the value at any depth in a nested object based on the
|
||||
// path described by the keys given. Keys may be given as an array
|
||||
// or as a dot-separated string.
|
||||
getPath: function getPath (obj, ks) {
|
||||
if (typeof ks == "string") ks = ks.split(".");
|
||||
|
||||
// If we have reached an undefined property
|
||||
// then stop executing and return undefined
|
||||
if (obj === undefined) return void 0;
|
||||
|
||||
// If the path array has no more elements, we've reached
|
||||
// the intended property and return its value
|
||||
if (ks.length === 0) return obj;
|
||||
|
||||
// If we still have elements in the path array and the current
|
||||
// value is null, stop executing and return undefined
|
||||
if (obj === null) return void 0;
|
||||
|
||||
return getPath(obj[_.first(ks)], _.rest(ks));
|
||||
},
|
||||
|
||||
// Returns a boolean indicating whether there is a property
|
||||
// at the path described by the keys given
|
||||
hasPath: function hasPath (obj, ks) {
|
||||
if (typeof ks == "string") ks = ks.split(".");
|
||||
|
||||
var numKeys = ks.length;
|
||||
|
||||
if (obj == null && numKeys > 0) return false;
|
||||
|
||||
if (!(ks[0] in obj)) return false;
|
||||
|
||||
if (numKeys === 1) return true;
|
||||
|
||||
return hasPath(obj[_.first(ks)], _.rest(ks));
|
||||
},
|
||||
|
||||
pickWhen: function(obj, pred) {
|
||||
var copy = {};
|
||||
|
||||
_.each(obj, function(value, key) {
|
||||
if (pred(obj[key])) copy[key] = obj[key];
|
||||
});
|
||||
|
||||
return copy;
|
||||
},
|
||||
|
||||
omitWhen: function(obj, pred) {
|
||||
return _.pickWhen(obj, function(e) { return !pred(e); });
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
})(this);
|
||||
32
node_modules/catharsis/node_modules/underscore-contrib/underscore.util.existential.js
generated
vendored
32
node_modules/catharsis/node_modules/underscore-contrib/underscore.util.existential.js
generated
vendored
@ -1,32 +0,0 @@
|
||||
// Underscore-contrib (underscore.util.existential.js 0.3.0)
|
||||
// (c) 2013 Michael Fogus, DocumentCloud and Investigative Reporters & Editors
|
||||
// Underscore-contrib may be freely distributed under the MIT license.
|
||||
|
||||
(function(root) {
|
||||
|
||||
// Baseline setup
|
||||
// --------------
|
||||
|
||||
// Establish the root object, `window` in the browser, or `global` on the server.
|
||||
var _ = root._ || require('underscore');
|
||||
|
||||
// Helpers
|
||||
// -------
|
||||
|
||||
|
||||
// Mixing in the truthiness
|
||||
// ------------------------
|
||||
|
||||
_.mixin({
|
||||
exists: function(x) { return x != null; },
|
||||
truthy: function(x) { return (x !== false) && _.exists(x); },
|
||||
falsey: function(x) { return !_.truthy(x); },
|
||||
not: function(b) { return !b; },
|
||||
firstExisting: function() {
|
||||
for (var i = 0; i < arguments.length; i++) {
|
||||
if (arguments[i] != null) return arguments[i];
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
})(this);
|
||||
164
node_modules/catharsis/node_modules/underscore-contrib/underscore.util.operators.js
generated
vendored
164
node_modules/catharsis/node_modules/underscore-contrib/underscore.util.operators.js
generated
vendored
@ -1,164 +0,0 @@
|
||||
// Underscore-contrib (underscore.function.arity.js 0.3.0)
|
||||
// (c) 2013 Michael Fogus, DocumentCloud and Investigative Reporters & Editors
|
||||
// Underscore-contrib may be freely distributed under the MIT license.
|
||||
|
||||
(function(root) {
|
||||
|
||||
// Baseline setup
|
||||
// --------------
|
||||
|
||||
// Establish the root object, `window` in the browser, or `global` on the server.
|
||||
var _ = root._ || require('underscore');
|
||||
|
||||
// Setup for variadic operators
|
||||
// ----------------------------
|
||||
|
||||
// Turn a binary math operator into a variadic operator
|
||||
function variadicMath(operator) {
|
||||
return function() {
|
||||
return _.reduce(arguments, operator);
|
||||
};
|
||||
}
|
||||
|
||||
// Turn a binary comparator into a variadic comparator
|
||||
function variadicComparator(comparator) {
|
||||
return function() {
|
||||
var result;
|
||||
for (var i = 0; i < arguments.length - 1; i++) {
|
||||
result = comparator(arguments[i], arguments[i + 1]);
|
||||
if (result === false) return result;
|
||||
}
|
||||
return result;
|
||||
};
|
||||
}
|
||||
|
||||
// Turn a boolean-returning function into one with the opposite meaning
|
||||
function invert(fn) {
|
||||
return function() {
|
||||
return !fn.apply(this, arguments);
|
||||
};
|
||||
}
|
||||
|
||||
// Basic math operators
|
||||
function add(x, y) {
|
||||
return x + y;
|
||||
}
|
||||
|
||||
function sub(x, y) {
|
||||
return x - y;
|
||||
}
|
||||
|
||||
function mul(x, y) {
|
||||
return x * y;
|
||||
}
|
||||
|
||||
function div(x, y) {
|
||||
return x / y;
|
||||
}
|
||||
|
||||
function mod(x, y) {
|
||||
return x % y;
|
||||
}
|
||||
|
||||
function inc(x) {
|
||||
return ++x;
|
||||
}
|
||||
|
||||
function dec(x) {
|
||||
return --x;
|
||||
}
|
||||
|
||||
function neg(x) {
|
||||
return -x;
|
||||
}
|
||||
|
||||
// Bitwise operators
|
||||
function bitwiseAnd(x, y) {
|
||||
return x & y;
|
||||
}
|
||||
|
||||
function bitwiseOr(x, y) {
|
||||
return x | y;
|
||||
}
|
||||
|
||||
function bitwiseXor(x, y) {
|
||||
return x ^ y;
|
||||
}
|
||||
|
||||
function bitwiseLeft(x, y) {
|
||||
return x << y;
|
||||
}
|
||||
|
||||
function bitwiseRight(x, y) {
|
||||
return x >> y;
|
||||
}
|
||||
|
||||
function bitwiseZ(x, y) {
|
||||
return x >>> y;
|
||||
}
|
||||
|
||||
function bitwiseNot(x) {
|
||||
return ~x;
|
||||
}
|
||||
|
||||
// Basic comparators
|
||||
function eq(x, y) {
|
||||
return x == y;
|
||||
}
|
||||
|
||||
function seq(x, y) {
|
||||
return x === y;
|
||||
}
|
||||
|
||||
// Not
|
||||
function not(x) {
|
||||
return !x;
|
||||
}
|
||||
|
||||
// Relative comparators
|
||||
function gt(x, y) {
|
||||
return x > y;
|
||||
}
|
||||
|
||||
function lt(x, y) {
|
||||
return x < y;
|
||||
}
|
||||
|
||||
function gte(x, y) {
|
||||
return x >= y;
|
||||
}
|
||||
|
||||
function lte(x, y) {
|
||||
return x <= y;
|
||||
}
|
||||
|
||||
// Mixing in the operator functions
|
||||
// -----------------------------
|
||||
|
||||
_.mixin({
|
||||
add: variadicMath(add),
|
||||
sub: variadicMath(sub),
|
||||
mul: variadicMath(mul),
|
||||
div: variadicMath(div),
|
||||
mod: mod,
|
||||
inc: inc,
|
||||
dec: dec,
|
||||
neg: neg,
|
||||
eq: variadicComparator(eq),
|
||||
seq: variadicComparator(seq),
|
||||
neq: invert(variadicComparator(eq)),
|
||||
sneq: invert(variadicComparator(seq)),
|
||||
not: not,
|
||||
gt: variadicComparator(gt),
|
||||
lt: variadicComparator(lt),
|
||||
gte: variadicComparator(gte),
|
||||
lte: variadicComparator(lte),
|
||||
bitwiseAnd: variadicMath(bitwiseAnd),
|
||||
bitwiseOr: variadicMath(bitwiseOr),
|
||||
bitwiseXor: variadicMath(bitwiseXor),
|
||||
bitwiseNot: bitwiseNot,
|
||||
bitwiseLeft: variadicMath(bitwiseLeft),
|
||||
bitwiseRight: variadicMath(bitwiseRight),
|
||||
bitwiseZ: variadicMath(bitwiseZ)
|
||||
});
|
||||
})(this);
|
||||
129
node_modules/catharsis/node_modules/underscore-contrib/underscore.util.strings.js
generated
vendored
129
node_modules/catharsis/node_modules/underscore-contrib/underscore.util.strings.js
generated
vendored
@ -1,129 +0,0 @@
|
||||
// Underscore-contrib (underscore.util.strings.js 0.3.0)
|
||||
// (c) 2013 Michael Fogus, DocumentCloud and Investigative Reporters & Editors
|
||||
// Underscore-contrib may be freely distributed under the MIT license.
|
||||
|
||||
(function(root) {
|
||||
|
||||
// Baseline setup
|
||||
// --------------
|
||||
|
||||
// Establish the root object, `window` in the browser, or `global` on the server.
|
||||
var _ = root._ || require('underscore');
|
||||
|
||||
// Helpers
|
||||
// -------
|
||||
|
||||
// No reason to create regex more than once
|
||||
var plusRegex = /\+/g;
|
||||
var spaceRegex = /\%20/g;
|
||||
var bracketRegex = /(?:([^\[]+))|(?:\[(.*?)\])/g;
|
||||
|
||||
var urlDecode = function(s) {
|
||||
return decodeURIComponent(s.replace(plusRegex, '%20'));
|
||||
};
|
||||
var urlEncode = function(s) {
|
||||
return encodeURIComponent(s).replace(spaceRegex, '+');
|
||||
};
|
||||
|
||||
var buildParams = function(prefix, val, top) {
|
||||
if (_.isUndefined(top)) top = true;
|
||||
if (_.isArray(val)) {
|
||||
return _.map(val, function(value, key) {
|
||||
return buildParams(top ? key : prefix + '[]', value, false);
|
||||
}).join('&');
|
||||
} else if (_.isObject(val)) {
|
||||
return _.map(val, function(value, key) {
|
||||
return buildParams(top ? key : prefix + '[' + key + ']', value, false);
|
||||
}).join('&');
|
||||
} else {
|
||||
return urlEncode(prefix) + '=' + urlEncode(val);
|
||||
}
|
||||
};
|
||||
|
||||
// Mixing in the string utils
|
||||
// ----------------------------
|
||||
|
||||
_.mixin({
|
||||
// Explodes a string into an array of chars
|
||||
explode: function(s) {
|
||||
return s.split('');
|
||||
},
|
||||
|
||||
// Parses a query string into a hash
|
||||
fromQuery: function(str) {
|
||||
var parameters = str.split('&'),
|
||||
obj = {},
|
||||
parameter,
|
||||
key,
|
||||
match,
|
||||
lastKey,
|
||||
subKey,
|
||||
depth;
|
||||
|
||||
// Iterate over key/value pairs
|
||||
_.each(parameters, function(parameter) {
|
||||
parameter = parameter.split('=');
|
||||
key = urlDecode(parameter[0]);
|
||||
lastKey = key;
|
||||
depth = obj;
|
||||
|
||||
// Reset so we don't have issues when matching the same string
|
||||
bracketRegex.lastIndex = 0;
|
||||
|
||||
// Attempt to extract nested values
|
||||
while ((match = bracketRegex.exec(key)) !== null) {
|
||||
if (!_.isUndefined(match[1])) {
|
||||
|
||||
// If we're at the top nested level, no new object needed
|
||||
subKey = match[1];
|
||||
|
||||
} else {
|
||||
|
||||
// If we're at a lower nested level, we need to step down, and make
|
||||
// sure that there is an object to place the value into
|
||||
subKey = match[2];
|
||||
depth[lastKey] = depth[lastKey] || (subKey ? {} : []);
|
||||
depth = depth[lastKey];
|
||||
}
|
||||
|
||||
// Save the correct key as a hash or an array
|
||||
lastKey = subKey || _.size(depth);
|
||||
}
|
||||
|
||||
// Assign value to nested object
|
||||
depth[lastKey] = urlDecode(parameter[1]);
|
||||
});
|
||||
|
||||
return obj;
|
||||
},
|
||||
|
||||
// Implodes and array of chars into a string
|
||||
implode: function(a) {
|
||||
return a.join('');
|
||||
},
|
||||
|
||||
// Converts a string to camel case
|
||||
camelCase : function( string ){
|
||||
return string.replace(/-([a-z])/g, function (g) { return g[1].toUpperCase(); });
|
||||
},
|
||||
|
||||
// Converts camel case to dashed (opposite of _.camelCase)
|
||||
toDash : function( string ){
|
||||
string = string.replace(/([A-Z])/g, function($1){return "-"+$1.toLowerCase();});
|
||||
// remove first dash
|
||||
return ( string.charAt( 0 ) == '-' ) ? string.substr(1) : string;
|
||||
},
|
||||
|
||||
// Creates a query string from a hash
|
||||
toQuery: function(obj) {
|
||||
return buildParams('', obj);
|
||||
},
|
||||
|
||||
// Reports whether a string contains a search string.
|
||||
strContains: function(str, search) {
|
||||
if (typeof str != 'string') throw new TypeError;
|
||||
return (str.indexOf(search) != -1);
|
||||
}
|
||||
|
||||
});
|
||||
})(this);
|
||||
39
node_modules/catharsis/node_modules/underscore-contrib/underscore.util.trampolines.js
generated
vendored
39
node_modules/catharsis/node_modules/underscore-contrib/underscore.util.trampolines.js
generated
vendored
@ -1,39 +0,0 @@
|
||||
// Underscore-contrib (underscore.util.trampolines.js 0.3.0)
|
||||
// (c) 2013 Michael Fogus, DocumentCloud and Investigative Reporters & Editors
|
||||
// Underscore-contrib may be freely distributed under the MIT license.
|
||||
|
||||
(function(root) {
|
||||
|
||||
// Baseline setup
|
||||
// --------------
|
||||
|
||||
// Establish the root object, `window` in the browser, or `global` on the server.
|
||||
var _ = root._ || require('underscore');
|
||||
|
||||
// Helpers
|
||||
// -------
|
||||
|
||||
|
||||
// Mixing in the truthiness
|
||||
// ------------------------
|
||||
|
||||
_.mixin({
|
||||
done: function(value) {
|
||||
var ret = _(value);
|
||||
ret.stopTrampoline = true;
|
||||
return ret;
|
||||
},
|
||||
|
||||
trampoline: function(fun /*, args */) {
|
||||
var result = fun.apply(fun, _.rest(arguments));
|
||||
|
||||
while (_.isFunction(result)) {
|
||||
result = result();
|
||||
if ((result instanceof _) && (result.stopTrampoline)) break;
|
||||
}
|
||||
|
||||
return result.value();
|
||||
}
|
||||
});
|
||||
|
||||
})(this);
|
||||
41
node_modules/catharsis/package.json
generated
vendored
41
node_modules/catharsis/package.json
generated
vendored
File diff suppressed because one or more lines are too long
91
node_modules/catharsis/res/en.json
generated
vendored
91
node_modules/catharsis/res/en.json
generated
vendored
@ -1,91 +0,0 @@
|
||||
{
|
||||
"all": "any type",
|
||||
"application": {
|
||||
"array": "<%= prefix %> <%= codeTagOpen %>Array<%= codeTagClose %> of <%= application %> <%= suffix %>",
|
||||
"object": "<%= prefix %> <%= codeTagOpen %>Object<%= codeTagClose %> with <%= application %> properties <%= suffix %>",
|
||||
"objectNonString": "<%= prefix %> <%= codeTagOpen %>Object<%= codeTagClose %> with <%= keyApplication %> keys and <%= application %> properties <%= suffix %>"
|
||||
},
|
||||
"function": {
|
||||
"extended": {
|
||||
"new": "Returns <%= functionNew %> when called with <%= codeTagOpen %>new<%= codeTagClose %>.",
|
||||
"returns": "Returns <%= type %>.",
|
||||
"signature": "function(<%= functionParams %>)",
|
||||
"this": "Within the function, <%= codeTagOpen %>this<%= codeTagClose %> refers to <%= functionThis %>."
|
||||
},
|
||||
"simple": {
|
||||
"new": "constructs <%= functionNew %>",
|
||||
"returns": "returns <%= type %>",
|
||||
"signature": "<%= prefix %> function(<%= functionParams %>) <%= functionReturns %>",
|
||||
"this": "<%= codeTagOpen %>this<%= codeTagClose %> = <%= functionThis %>"
|
||||
}
|
||||
},
|
||||
"modifiers": {
|
||||
"extended": {
|
||||
"nonNullable": "Must not be null.",
|
||||
"nullable": "May be null.",
|
||||
"optional": "Optional.",
|
||||
"prefix": "",
|
||||
"repeatable": "May be provided more than once.",
|
||||
"suffix": ""
|
||||
},
|
||||
"simple": {
|
||||
"nonNullable": "non-null",
|
||||
"nullable": "nullable",
|
||||
"optional": "optional",
|
||||
"prefix": "<%= optional %> <%= nullable %> <%= repeatable %>",
|
||||
"repeatable": "repeatable",
|
||||
"suffix": ""
|
||||
}
|
||||
},
|
||||
"name": "<%= codeTagOpen %>{{ name }}<%= codeTagClose %> <%= suffix %>",
|
||||
"null": "null",
|
||||
"params": {
|
||||
"first": {
|
||||
"one": "<%= param %>",
|
||||
"two": "<%= param %>, ",
|
||||
"many": "<%= param %>, "
|
||||
},
|
||||
"middle": {
|
||||
"many": "<%= param %>, "
|
||||
},
|
||||
"last": {
|
||||
"two": "<%= param %>",
|
||||
"many": "<%= param %>"
|
||||
}
|
||||
},
|
||||
"record": {
|
||||
"first": {
|
||||
"one": "<%= prefix %> {<%= field %>} <%= suffix %>",
|
||||
"two": "<%= prefix %> {<%= field %>, ",
|
||||
"many": "<%= prefix %> {<%= field %>, "
|
||||
},
|
||||
"middle": {
|
||||
"many": "<%= field %>, "
|
||||
},
|
||||
"last": {
|
||||
"two": "<%= field %>} <%= suffix %>",
|
||||
"many": "<%= field %>} <%= suffix %>"
|
||||
}
|
||||
},
|
||||
"field": {
|
||||
"typed": "<%= name %>: <%= type %>",
|
||||
"untyped": "<%= name %>"
|
||||
},
|
||||
"type": "<%= prefix %> <%= codeTagOpen %><%= type %><%= codeTagClose %> <%= suffix %>",
|
||||
"undefined": "undefined",
|
||||
"union": {
|
||||
"first": {
|
||||
"one": "<%= prefix %> <%= element %> <%= suffix %>",
|
||||
"two": "<%= prefix %> (<%= element %> ",
|
||||
"many": "<%= prefix %> (<%= element %>, "
|
||||
},
|
||||
"middle": {
|
||||
"many": "<%= element %>, "
|
||||
},
|
||||
"last": {
|
||||
"two": "or <%= element %>) <%= suffix %>",
|
||||
"many": "or <%= element %>) <%= suffix %>"
|
||||
}
|
||||
},
|
||||
"unknown": "unknown"
|
||||
}
|
||||
68
node_modules/crypto-browserify/index.js
generated
vendored
68
node_modules/crypto-browserify/index.js
generated
vendored
@ -1,68 +0,0 @@
|
||||
var sha = require('./sha')
|
||||
var rng = require('./rng')
|
||||
|
||||
var algorithms = {
|
||||
sha1: {
|
||||
hex: sha.hex_sha1,
|
||||
binary: sha.b64_sha1,
|
||||
ascii: sha.str_sha1
|
||||
}
|
||||
}
|
||||
|
||||
function error () {
|
||||
var m = [].slice.call(arguments).join(' ')
|
||||
throw new Error([
|
||||
m,
|
||||
'we accept pull requests',
|
||||
'http://github.com/dominictarr/crypto-browserify'
|
||||
].join('\n'))
|
||||
}
|
||||
|
||||
exports.createHash = function (alg) {
|
||||
alg = alg || 'sha1'
|
||||
if(!algorithms[alg])
|
||||
error('algorithm:', alg, 'is not yet supported')
|
||||
var s = ''
|
||||
var _alg = algorithms[alg]
|
||||
return {
|
||||
update: function (data) {
|
||||
s += data
|
||||
return this
|
||||
},
|
||||
digest: function (enc) {
|
||||
enc = enc || 'binary'
|
||||
var fn
|
||||
if(!(fn = _alg[enc]))
|
||||
error('encoding:', enc , 'is not yet supported for algorithm', alg)
|
||||
var r = fn(s)
|
||||
s = null //not meant to use the hash after you've called digest.
|
||||
return r
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
exports.randomBytes = function(size, callback) {
|
||||
if (callback && callback.call) {
|
||||
try {
|
||||
callback.call(this, undefined, rng(size));
|
||||
} catch (err) { callback(err); }
|
||||
} else {
|
||||
return rng(size);
|
||||
}
|
||||
}
|
||||
|
||||
// the least I can do is make error messages for the rest of the node.js/crypto api.
|
||||
;['createCredentials'
|
||||
, 'createHmac'
|
||||
, 'createCypher'
|
||||
, 'createCypheriv'
|
||||
, 'createDecipher'
|
||||
, 'createDecipheriv'
|
||||
, 'createSign'
|
||||
, 'createVerify'
|
||||
, 'createDeffieHellman'
|
||||
, 'pbkdf2'].forEach(function (name) {
|
||||
exports[name] = function () {
|
||||
error('sorry,', name, 'is not implemented yet')
|
||||
}
|
||||
})
|
||||
29
node_modules/crypto-browserify/package.json
generated
vendored
29
node_modules/crypto-browserify/package.json
generated
vendored
@ -1,29 +0,0 @@
|
||||
{
|
||||
"author": {
|
||||
"name": "Dominic Tarr",
|
||||
"email": "dominic.tarr@gmail.com",
|
||||
"url": "dominictarr.com"
|
||||
},
|
||||
"name": "crypto-browserify",
|
||||
"description": "partial implementation of crypto for the browser",
|
||||
"version": "0.1.1",
|
||||
"homepage": "https://github.com/dominictarr/crypto-browserify",
|
||||
"repository": {
|
||||
"url": ""
|
||||
},
|
||||
"scripts": {
|
||||
"test": "node test/simple.js"
|
||||
},
|
||||
"engines": {
|
||||
"node": "*"
|
||||
},
|
||||
"dependencies": {},
|
||||
"devDependencies": {},
|
||||
"optionalDependencies": {},
|
||||
"readme": "# crypto-browserify\n\nA (partial) port of `crypto` to the browser.\n\nBasically, I found some crypto implemented in JS lieing on the internet somewhere\nand wrapped it in the part of the `crypto` api that I am currently using.\n\nIn a way that will be compatible with [browserify](https://github.com/substack/node-browserify/).\n\nI will extend this if I need more features, or if anyone else wants to extend this,\nI will add you as a maintainer.\n\nProvided that you agree that it should replicate the [node.js/crypto](http://nodejs.org/api/crypto.html) api exactly, of course.\n\n",
|
||||
"_id": "crypto-browserify@0.1.1",
|
||||
"dist": {
|
||||
"shasum": "251b240c6bd0e95db0654fbc8b178b855cbef45e"
|
||||
},
|
||||
"_from": "crypto-browserify@git://github.com/dominictarr/crypto-browserify.git#95c5d505"
|
||||
}
|
||||
37
node_modules/crypto-browserify/rng.js
generated
vendored
37
node_modules/crypto-browserify/rng.js
generated
vendored
@ -1,37 +0,0 @@
|
||||
// Original code adapted from Robert Kieffer.
|
||||
// details at https://github.com/broofa/node-uuid
|
||||
(function() {
|
||||
var _global = this;
|
||||
|
||||
var mathRNG, whatwgRNG;
|
||||
|
||||
// NOTE: Math.random() does not guarantee "cryptographic quality"
|
||||
mathRNG = function(size) {
|
||||
var bytes = new Array(size);
|
||||
var r;
|
||||
|
||||
for (var i = 0, r; i < size; i++) {
|
||||
if ((i & 0x03) == 0) r = Math.random() * 0x100000000;
|
||||
bytes[i] = r >>> ((i & 0x03) << 3) & 0xff;
|
||||
}
|
||||
|
||||
return bytes;
|
||||
}
|
||||
|
||||
// currently only available in webkit-based browsers.
|
||||
if (_global.crypto && crypto.getRandomValues) {
|
||||
var _rnds = new Uint32Array(4);
|
||||
whatwgRNG = function(size) {
|
||||
var bytes = new Array(size);
|
||||
crypto.getRandomValues(_rnds);
|
||||
|
||||
for (var c = 0 ; c < size; c++) {
|
||||
bytes[c] = _rnds[c >> 2] >>> ((c & 0x03) * 8) & 0xff;
|
||||
}
|
||||
return bytes;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = whatwgRNG || mathRNG;
|
||||
|
||||
}())
|
||||
210
node_modules/crypto-browserify/sha.js
generated
vendored
210
node_modules/crypto-browserify/sha.js
generated
vendored
@ -1,210 +0,0 @@
|
||||
/*
|
||||
* A JavaScript implementation of the Secure Hash Algorithm, SHA-1, as defined
|
||||
* in FIPS PUB 180-1
|
||||
* Version 2.1a Copyright Paul Johnston 2000 - 2002.
|
||||
* Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
|
||||
* Distributed under the BSD License
|
||||
* See http://pajhome.org.uk/crypt/md5 for details.
|
||||
*/
|
||||
|
||||
exports.hex_sha1 = hex_sha1;
|
||||
exports.b64_sha1 = b64_sha1;
|
||||
exports.str_sha1 = str_sha1;
|
||||
exports.hex_hmac_sha1 = hex_hmac_sha1;
|
||||
exports.b64_hmac_sha1 = b64_hmac_sha1;
|
||||
exports.str_hmac_sha1 = str_hmac_sha1;
|
||||
|
||||
/*
|
||||
* Configurable variables. You may need to tweak these to be compatible with
|
||||
* the server-side, but the defaults work in most cases.
|
||||
*/
|
||||
var hexcase = 0; /* hex output format. 0 - lowercase; 1 - uppercase */
|
||||
var b64pad = ""; /* base-64 pad character. "=" for strict RFC compliance */
|
||||
var chrsz = 8; /* bits per input character. 8 - ASCII; 16 - Unicode */
|
||||
|
||||
/*
|
||||
* These are the functions you'll usually want to call
|
||||
* They take string arguments and return either hex or base-64 encoded strings
|
||||
*/
|
||||
function hex_sha1(s){return binb2hex(core_sha1(str2binb(s),s.length * chrsz));}
|
||||
function b64_sha1(s){return binb2b64(core_sha1(str2binb(s),s.length * chrsz));}
|
||||
function str_sha1(s){return binb2str(core_sha1(str2binb(s),s.length * chrsz));}
|
||||
function hex_hmac_sha1(key, data){ return binb2hex(core_hmac_sha1(key, data));}
|
||||
function b64_hmac_sha1(key, data){ return binb2b64(core_hmac_sha1(key, data));}
|
||||
function str_hmac_sha1(key, data){ return binb2str(core_hmac_sha1(key, data));}
|
||||
|
||||
/*
|
||||
* Perform a simple self-test to see if the VM is working
|
||||
*/
|
||||
function sha1_vm_test()
|
||||
{
|
||||
return hex_sha1("abc") == "a9993e364706816aba3e25717850c26c9cd0d89d";
|
||||
}
|
||||
|
||||
/*
|
||||
* Calculate the SHA-1 of an array of big-endian words, and a bit length
|
||||
*/
|
||||
function core_sha1(x, len)
|
||||
{
|
||||
/* append padding */
|
||||
x[len >> 5] |= 0x80 << (24 - len % 32);
|
||||
x[((len + 64 >> 9) << 4) + 15] = len;
|
||||
|
||||
var w = Array(80);
|
||||
var a = 1732584193;
|
||||
var b = -271733879;
|
||||
var c = -1732584194;
|
||||
var d = 271733878;
|
||||
var e = -1009589776;
|
||||
|
||||
for(var i = 0; i < x.length; i += 16)
|
||||
{
|
||||
var olda = a;
|
||||
var oldb = b;
|
||||
var oldc = c;
|
||||
var oldd = d;
|
||||
var olde = e;
|
||||
|
||||
for(var j = 0; j < 80; j++)
|
||||
{
|
||||
if(j < 16) w[j] = x[i + j];
|
||||
else w[j] = rol(w[j-3] ^ w[j-8] ^ w[j-14] ^ w[j-16], 1);
|
||||
var t = safe_add(safe_add(rol(a, 5), sha1_ft(j, b, c, d)),
|
||||
safe_add(safe_add(e, w[j]), sha1_kt(j)));
|
||||
e = d;
|
||||
d = c;
|
||||
c = rol(b, 30);
|
||||
b = a;
|
||||
a = t;
|
||||
}
|
||||
|
||||
a = safe_add(a, olda);
|
||||
b = safe_add(b, oldb);
|
||||
c = safe_add(c, oldc);
|
||||
d = safe_add(d, oldd);
|
||||
e = safe_add(e, olde);
|
||||
}
|
||||
return Array(a, b, c, d, e);
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* Perform the appropriate triplet combination function for the current
|
||||
* iteration
|
||||
*/
|
||||
function sha1_ft(t, b, c, d)
|
||||
{
|
||||
if(t < 20) return (b & c) | ((~b) & d);
|
||||
if(t < 40) return b ^ c ^ d;
|
||||
if(t < 60) return (b & c) | (b & d) | (c & d);
|
||||
return b ^ c ^ d;
|
||||
}
|
||||
|
||||
/*
|
||||
* Determine the appropriate additive constant for the current iteration
|
||||
*/
|
||||
function sha1_kt(t)
|
||||
{
|
||||
return (t < 20) ? 1518500249 : (t < 40) ? 1859775393 :
|
||||
(t < 60) ? -1894007588 : -899497514;
|
||||
}
|
||||
|
||||
/*
|
||||
* Calculate the HMAC-SHA1 of a key and some data
|
||||
*/
|
||||
function core_hmac_sha1(key, data)
|
||||
{
|
||||
var bkey = str2binb(key);
|
||||
if(bkey.length > 16) bkey = core_sha1(bkey, key.length * chrsz);
|
||||
|
||||
var ipad = Array(16), opad = Array(16);
|
||||
for(var i = 0; i < 16; i++)
|
||||
{
|
||||
ipad[i] = bkey[i] ^ 0x36363636;
|
||||
opad[i] = bkey[i] ^ 0x5C5C5C5C;
|
||||
}
|
||||
|
||||
var hash = core_sha1(ipad.concat(str2binb(data)), 512 + data.length * chrsz);
|
||||
return core_sha1(opad.concat(hash), 512 + 160);
|
||||
}
|
||||
|
||||
/*
|
||||
* Add integers, wrapping at 2^32. This uses 16-bit operations internally
|
||||
* to work around bugs in some JS interpreters.
|
||||
*/
|
||||
function safe_add(x, y)
|
||||
{
|
||||
var lsw = (x & 0xFFFF) + (y & 0xFFFF);
|
||||
var msw = (x >> 16) + (y >> 16) + (lsw >> 16);
|
||||
return (msw << 16) | (lsw & 0xFFFF);
|
||||
}
|
||||
|
||||
/*
|
||||
* Bitwise rotate a 32-bit number to the left.
|
||||
*/
|
||||
function rol(num, cnt)
|
||||
{
|
||||
return (num << cnt) | (num >>> (32 - cnt));
|
||||
}
|
||||
|
||||
/*
|
||||
* Convert an 8-bit or 16-bit string to an array of big-endian words
|
||||
* In 8-bit function, characters >255 have their hi-byte silently ignored.
|
||||
*/
|
||||
function str2binb(str)
|
||||
{
|
||||
var bin = Array();
|
||||
var mask = (1 << chrsz) - 1;
|
||||
for(var i = 0; i < str.length * chrsz; i += chrsz)
|
||||
bin[i>>5] |= (str.charCodeAt(i / chrsz) & mask) << (32 - chrsz - i%32);
|
||||
return bin;
|
||||
}
|
||||
|
||||
/*
|
||||
* Convert an array of big-endian words to a string
|
||||
*/
|
||||
function binb2str(bin)
|
||||
{
|
||||
var str = "";
|
||||
var mask = (1 << chrsz) - 1;
|
||||
for(var i = 0; i < bin.length * 32; i += chrsz)
|
||||
str += String.fromCharCode((bin[i>>5] >>> (32 - chrsz - i%32)) & mask);
|
||||
return str;
|
||||
}
|
||||
|
||||
/*
|
||||
* Convert an array of big-endian words to a hex string.
|
||||
*/
|
||||
function binb2hex(binarray)
|
||||
{
|
||||
var hex_tab = hexcase ? "0123456789ABCDEF" : "0123456789abcdef";
|
||||
var str = "";
|
||||
for(var i = 0; i < binarray.length * 4; i++)
|
||||
{
|
||||
str += hex_tab.charAt((binarray[i>>2] >> ((3 - i%4)*8+4)) & 0xF) +
|
||||
hex_tab.charAt((binarray[i>>2] >> ((3 - i%4)*8 )) & 0xF);
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
/*
|
||||
* Convert an array of big-endian words to a base-64 string
|
||||
*/
|
||||
function binb2b64(binarray)
|
||||
{
|
||||
var tab = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
||||
var str = "";
|
||||
for(var i = 0; i < binarray.length * 4; i += 3)
|
||||
{
|
||||
var triplet = (((binarray[i >> 2] >> 8 * (3 - i %4)) & 0xFF) << 16)
|
||||
| (((binarray[i+1 >> 2] >> 8 * (3 - (i+1)%4)) & 0xFF) << 8 )
|
||||
| ((binarray[i+2 >> 2] >> 8 * (3 - (i+2)%4)) & 0xFF);
|
||||
for(var j = 0; j < 4; j++)
|
||||
{
|
||||
if(i * 8 + j * 6 > binarray.length * 32) str += b64pad;
|
||||
else str += tab.charAt((triplet >> 6*(3-j)) & 0x3F);
|
||||
}
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
11
node_modules/escape-string-regexp/index.js
generated
vendored
11
node_modules/escape-string-regexp/index.js
generated
vendored
@ -1,11 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
var matchOperatorsRe = /[|\\{}()[\]^$+*?.]/g;
|
||||
|
||||
module.exports = function (str) {
|
||||
if (typeof str !== 'string') {
|
||||
throw new TypeError('Expected a string');
|
||||
}
|
||||
|
||||
return str.replace(matchOperatorsRe, '\\$&');
|
||||
};
|
||||
70
node_modules/escape-string-regexp/package.json
generated
vendored
70
node_modules/escape-string-regexp/package.json
generated
vendored
@ -1,70 +0,0 @@
|
||||
{
|
||||
"name": "escape-string-regexp",
|
||||
"version": "1.0.3",
|
||||
"description": "Escape RegExp special characters",
|
||||
"license": "MIT",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/sindresorhus/escape-string-regexp.git"
|
||||
},
|
||||
"author": {
|
||||
"name": "Sindre Sorhus",
|
||||
"email": "sindresorhus@gmail.com",
|
||||
"url": "http://sindresorhus.com"
|
||||
},
|
||||
"maintainers": [
|
||||
{
|
||||
"name": "sindresorhus",
|
||||
"email": "sindresorhus@gmail.com"
|
||||
},
|
||||
{
|
||||
"name": "jbnicolai",
|
||||
"email": "jappelman@xebia.com"
|
||||
}
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=0.8.0"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "mocha"
|
||||
},
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"keywords": [
|
||||
"regex",
|
||||
"regexp",
|
||||
"re",
|
||||
"regular",
|
||||
"expression",
|
||||
"escape",
|
||||
"string",
|
||||
"str",
|
||||
"special",
|
||||
"characters"
|
||||
],
|
||||
"devDependencies": {
|
||||
"mocha": "*"
|
||||
},
|
||||
"gitHead": "1e446e6b4449b5f1f8868cd31bf8fd25ee37fb4b",
|
||||
"bugs": {
|
||||
"url": "https://github.com/sindresorhus/escape-string-regexp/issues"
|
||||
},
|
||||
"homepage": "https://github.com/sindresorhus/escape-string-regexp",
|
||||
"_id": "escape-string-regexp@1.0.3",
|
||||
"_shasum": "9e2d8b25bc2555c3336723750e03f099c2735bb5",
|
||||
"_from": "escape-string-regexp@>=1.0.3 <1.1.0",
|
||||
"_npmVersion": "2.1.16",
|
||||
"_nodeVersion": "0.10.35",
|
||||
"_npmUser": {
|
||||
"name": "jbnicolai",
|
||||
"email": "jappelman@xebia.com"
|
||||
},
|
||||
"dist": {
|
||||
"shasum": "9e2d8b25bc2555c3336723750e03f099c2735bb5",
|
||||
"tarball": "http://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.3.tgz"
|
||||
},
|
||||
"directories": {},
|
||||
"_resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.3.tgz",
|
||||
"readme": "ERROR: No README data found!"
|
||||
}
|
||||
27
node_modules/escape-string-regexp/readme.md
generated
vendored
27
node_modules/escape-string-regexp/readme.md
generated
vendored
@ -1,27 +0,0 @@
|
||||
# escape-string-regexp [](https://travis-ci.org/sindresorhus/escape-string-regexp)
|
||||
|
||||
> Escape RegExp special characters
|
||||
|
||||
|
||||
## Install
|
||||
|
||||
```sh
|
||||
$ npm install --save escape-string-regexp
|
||||
```
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
var escapeStringRegexp = require('escape-string-regexp');
|
||||
|
||||
var escapedString = escapeStringRegexp('how much $ for a unicorn?');
|
||||
//=> how much \$ for a unicorn\?
|
||||
|
||||
new RegExp(escapedString);
|
||||
```
|
||||
|
||||
|
||||
## License
|
||||
|
||||
MIT © [Sindre Sorhus](http://sindresorhus.com)
|
||||
5522
node_modules/espree/espree.js
generated
vendored
5522
node_modules/espree/espree.js
generated
vendored
File diff suppressed because it is too large
Load Diff
964
node_modules/espree/lib/ast-node-factory.js
generated
vendored
964
node_modules/espree/lib/ast-node-factory.js
generated
vendored
@ -1,964 +0,0 @@
|
||||
/**
|
||||
* @fileoverview A factory for creating AST nodes
|
||||
* @author Fred K. Schott
|
||||
* @copyright 2014 Fred K. Schott. All rights reserved.
|
||||
* @copyright 2011-2013 Ariya Hidayat <ariya.hidayat@gmail.com>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Requirements
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
var astNodeTypes = require("./ast-node-types");
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Public
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
module.exports = {
|
||||
|
||||
/**
|
||||
* Create an Array Expression ASTNode out of an array of elements
|
||||
* @param {ASTNode[]} elements An array of ASTNode elements
|
||||
* @returns {ASTNode} An ASTNode representing the entire array expression
|
||||
*/
|
||||
createArrayExpression: function(elements) {
|
||||
return {
|
||||
type: astNodeTypes.ArrayExpression,
|
||||
elements: elements
|
||||
};
|
||||
},
|
||||
|
||||
/**
|
||||
* Create an Arrow Function Expression ASTNode
|
||||
* @param {ASTNode} params The function arguments
|
||||
* @param {ASTNode} body The function body
|
||||
* @param {boolean} expression True if the arrow function is created via an expression.
|
||||
* Always false for declarations, but kept here to be in sync with
|
||||
* FunctionExpression objects.
|
||||
* @returns {ASTNode} An ASTNode representing the entire arrow function expression
|
||||
*/
|
||||
createArrowFunctionExpression: function (params, body, expression) {
|
||||
return {
|
||||
type: astNodeTypes.ArrowFunctionExpression,
|
||||
id: null,
|
||||
params: params,
|
||||
body: body,
|
||||
generator: false,
|
||||
expression: expression
|
||||
};
|
||||
},
|
||||
|
||||
/**
|
||||
* Create an ASTNode representation of an assignment expression
|
||||
* @param {ASTNode} operator The assignment operator
|
||||
* @param {ASTNode} left The left operand
|
||||
* @param {ASTNode} right The right operand
|
||||
* @returns {ASTNode} An ASTNode representing the entire assignment expression
|
||||
*/
|
||||
createAssignmentExpression: function(operator, left, right) {
|
||||
return {
|
||||
type: astNodeTypes.AssignmentExpression,
|
||||
operator: operator,
|
||||
left: left,
|
||||
right: right
|
||||
};
|
||||
},
|
||||
|
||||
/**
|
||||
* Create an ASTNode representation of an assignment pattern (default parameters)
|
||||
* @param {ASTNode} left The left operand
|
||||
* @param {ASTNode} right The right operand
|
||||
* @returns {ASTNode} An ASTNode representing the entire assignment pattern
|
||||
*/
|
||||
createAssignmentPattern: function(left, right) {
|
||||
return {
|
||||
type: astNodeTypes.AssignmentPattern,
|
||||
left: left,
|
||||
right: right
|
||||
};
|
||||
},
|
||||
|
||||
/**
|
||||
* Create an ASTNode representation of a binary expression
|
||||
* @param {ASTNode} operator The assignment operator
|
||||
* @param {ASTNode} left The left operand
|
||||
* @param {ASTNode} right The right operand
|
||||
* @returns {ASTNode} An ASTNode representing the entire binary expression
|
||||
*/
|
||||
createBinaryExpression: function(operator, left, right) {
|
||||
var type = (operator === "||" || operator === "&&") ? astNodeTypes.LogicalExpression :
|
||||
astNodeTypes.BinaryExpression;
|
||||
return {
|
||||
type: type,
|
||||
operator: operator,
|
||||
left: left,
|
||||
right: right
|
||||
};
|
||||
},
|
||||
|
||||
/**
|
||||
* Create an ASTNode representation of a block statement
|
||||
* @param {ASTNode} body The block statement body
|
||||
* @returns {ASTNode} An ASTNode representing the entire block statement
|
||||
*/
|
||||
createBlockStatement: function(body) {
|
||||
return {
|
||||
type: astNodeTypes.BlockStatement,
|
||||
body: body
|
||||
};
|
||||
},
|
||||
|
||||
/**
|
||||
* Create an ASTNode representation of a break statement
|
||||
* @param {ASTNode} label The break statement label
|
||||
* @returns {ASTNode} An ASTNode representing the break statement
|
||||
*/
|
||||
createBreakStatement: function(label) {
|
||||
return {
|
||||
type: astNodeTypes.BreakStatement,
|
||||
label: label
|
||||
};
|
||||
},
|
||||
|
||||
/**
|
||||
* Create an ASTNode representation of a call expression
|
||||
* @param {ASTNode} callee The function being called
|
||||
* @param {ASTNode[]} args An array of ASTNodes representing the function call arguments
|
||||
* @returns {ASTNode} An ASTNode representing the entire call expression
|
||||
*/
|
||||
createCallExpression: function(callee, args) {
|
||||
return {
|
||||
type: astNodeTypes.CallExpression,
|
||||
callee: callee,
|
||||
"arguments": args
|
||||
};
|
||||
},
|
||||
|
||||
/**
|
||||
* Create an ASTNode representation of a catch clause/block
|
||||
* @param {ASTNode} param Any catch clause exeption/conditional parameter information
|
||||
* @param {ASTNode} body The catch block body
|
||||
* @returns {ASTNode} An ASTNode representing the entire catch clause
|
||||
*/
|
||||
createCatchClause: function(param, body) {
|
||||
return {
|
||||
type: astNodeTypes.CatchClause,
|
||||
param: param,
|
||||
body: body
|
||||
};
|
||||
},
|
||||
|
||||
/**
|
||||
* Creates an ASTNode representation of a class body.
|
||||
* @param {ASTNode} body The node representing the body of the class.
|
||||
* @returns {ASTNode} An ASTNode representing the class body.
|
||||
*/
|
||||
createClassBody: function(body) {
|
||||
return {
|
||||
type: astNodeTypes.ClassBody,
|
||||
body: body
|
||||
};
|
||||
},
|
||||
|
||||
createClassExpression: function(id, superClass, body) {
|
||||
return {
|
||||
type: astNodeTypes.ClassExpression,
|
||||
id: id,
|
||||
superClass: superClass,
|
||||
body: body
|
||||
};
|
||||
},
|
||||
|
||||
createClassDeclaration: function(id, superClass, body) {
|
||||
return {
|
||||
type: astNodeTypes.ClassDeclaration,
|
||||
id: id,
|
||||
superClass: superClass,
|
||||
body: body
|
||||
};
|
||||
},
|
||||
|
||||
createMethodDefinition: function(propertyType, kind, key, value, computed) {
|
||||
return {
|
||||
type: astNodeTypes.MethodDefinition,
|
||||
key: key,
|
||||
value: value,
|
||||
kind: kind,
|
||||
"static": propertyType === "static",
|
||||
computed: computed
|
||||
};
|
||||
},
|
||||
|
||||
createMetaProperty: function(meta, property) {
|
||||
return {
|
||||
type: astNodeTypes.MetaProperty,
|
||||
meta: meta,
|
||||
property: property
|
||||
};
|
||||
},
|
||||
|
||||
/**
|
||||
* Create an ASTNode representation of a conditional expression
|
||||
* @param {ASTNode} test The conditional to evaluate
|
||||
* @param {ASTNode} consequent The code to be run if the test returns true
|
||||
* @param {ASTNode} alternate The code to be run if the test returns false
|
||||
* @returns {ASTNode} An ASTNode representing the entire conditional expression
|
||||
*/
|
||||
createConditionalExpression: function(test, consequent, alternate) {
|
||||
return {
|
||||
type: astNodeTypes.ConditionalExpression,
|
||||
test: test,
|
||||
consequent: consequent,
|
||||
alternate: alternate
|
||||
};
|
||||
},
|
||||
|
||||
/**
|
||||
* Create an ASTNode representation of a continue statement
|
||||
* @param {?ASTNode} label The optional continue label (null if not set)
|
||||
* @returns {ASTNode} An ASTNode representing the continue statement
|
||||
*/
|
||||
createContinueStatement: function(label) {
|
||||
return {
|
||||
type: astNodeTypes.ContinueStatement,
|
||||
label: label
|
||||
};
|
||||
},
|
||||
|
||||
/**
|
||||
* Create an ASTNode representation of a debugger statement
|
||||
* @returns {ASTNode} An ASTNode representing the debugger statement
|
||||
*/
|
||||
createDebuggerStatement: function() {
|
||||
return {
|
||||
type: astNodeTypes.DebuggerStatement
|
||||
};
|
||||
},
|
||||
|
||||
/**
|
||||
* Create an ASTNode representation of an empty statement
|
||||
* @returns {ASTNode} An ASTNode representing an empty statement
|
||||
*/
|
||||
createEmptyStatement: function() {
|
||||
return {
|
||||
type: astNodeTypes.EmptyStatement
|
||||
};
|
||||
},
|
||||
|
||||
/**
|
||||
* Create an ASTNode representation of an expression statement
|
||||
* @param {ASTNode} expression The expression
|
||||
* @returns {ASTNode} An ASTNode representing an expression statement
|
||||
*/
|
||||
createExpressionStatement: function(expression) {
|
||||
return {
|
||||
type: astNodeTypes.ExpressionStatement,
|
||||
expression: expression
|
||||
};
|
||||
},
|
||||
|
||||
/**
|
||||
* Create an ASTNode representation of a while statement
|
||||
* @param {ASTNode} test The while conditional
|
||||
* @param {ASTNode} body The while loop body
|
||||
* @returns {ASTNode} An ASTNode representing a while statement
|
||||
*/
|
||||
createWhileStatement: function(test, body) {
|
||||
return {
|
||||
type: astNodeTypes.WhileStatement,
|
||||
test: test,
|
||||
body: body
|
||||
};
|
||||
},
|
||||
|
||||
/**
|
||||
* Create an ASTNode representation of a do..while statement
|
||||
* @param {ASTNode} test The do..while conditional
|
||||
* @param {ASTNode} body The do..while loop body
|
||||
* @returns {ASTNode} An ASTNode representing a do..while statement
|
||||
*/
|
||||
createDoWhileStatement: function(test, body) {
|
||||
return {
|
||||
type: astNodeTypes.DoWhileStatement,
|
||||
body: body,
|
||||
test: test
|
||||
};
|
||||
},
|
||||
|
||||
/**
|
||||
* Create an ASTNode representation of a for statement
|
||||
* @param {ASTNode} init The initialization expression
|
||||
* @param {ASTNode} test The conditional test expression
|
||||
* @param {ASTNode} update The update expression
|
||||
* @param {ASTNode} body The statement body
|
||||
* @returns {ASTNode} An ASTNode representing a for statement
|
||||
*/
|
||||
createForStatement: function(init, test, update, body) {
|
||||
return {
|
||||
type: astNodeTypes.ForStatement,
|
||||
init: init,
|
||||
test: test,
|
||||
update: update,
|
||||
body: body
|
||||
};
|
||||
},
|
||||
|
||||
/**
|
||||
* Create an ASTNode representation of a for..in statement
|
||||
* @param {ASTNode} left The left-side variable for the property name
|
||||
* @param {ASTNode} right The right-side object
|
||||
* @param {ASTNode} body The statement body
|
||||
* @returns {ASTNode} An ASTNode representing a for..in statement
|
||||
*/
|
||||
createForInStatement: function(left, right, body) {
|
||||
return {
|
||||
type: astNodeTypes.ForInStatement,
|
||||
left: left,
|
||||
right: right,
|
||||
body: body,
|
||||
each: false
|
||||
};
|
||||
},
|
||||
|
||||
/**
|
||||
* Create an ASTNode representation of a for..of statement
|
||||
* @param {ASTNode} left The left-side variable for the property value
|
||||
* @param {ASTNode} right The right-side object
|
||||
* @param {ASTNode} body The statement body
|
||||
* @returns {ASTNode} An ASTNode representing a for..of statement
|
||||
*/
|
||||
createForOfStatement: function(left, right, body) {
|
||||
return {
|
||||
type: astNodeTypes.ForOfStatement,
|
||||
left: left,
|
||||
right: right,
|
||||
body: body
|
||||
};
|
||||
},
|
||||
|
||||
/**
|
||||
* Create an ASTNode representation of a function declaration
|
||||
* @param {ASTNode} id The function name
|
||||
* @param {ASTNode} params The function arguments
|
||||
* @param {ASTNode} body The function body
|
||||
* @param {boolean} generator True if the function is a generator, false if not.
|
||||
* @param {boolean} expression True if the function is created via an expression.
|
||||
* Always false for declarations, but kept here to be in sync with
|
||||
* FunctionExpression objects.
|
||||
* @returns {ASTNode} An ASTNode representing a function declaration
|
||||
*/
|
||||
createFunctionDeclaration: function (id, params, body, generator, expression) {
|
||||
return {
|
||||
type: astNodeTypes.FunctionDeclaration,
|
||||
id: id,
|
||||
params: params || [],
|
||||
body: body,
|
||||
generator: !!generator,
|
||||
expression: !!expression
|
||||
};
|
||||
},
|
||||
|
||||
/**
|
||||
* Create an ASTNode representation of a function expression
|
||||
* @param {ASTNode} id The function name
|
||||
* @param {ASTNode} params The function arguments
|
||||
* @param {ASTNode} body The function body
|
||||
* @param {boolean} generator True if the function is a generator, false if not.
|
||||
* @param {boolean} expression True if the function is created via an expression.
|
||||
* @returns {ASTNode} An ASTNode representing a function declaration
|
||||
*/
|
||||
createFunctionExpression: function (id, params, body, generator, expression) {
|
||||
return {
|
||||
type: astNodeTypes.FunctionExpression,
|
||||
id: id,
|
||||
params: params || [],
|
||||
body: body,
|
||||
generator: !!generator,
|
||||
expression: !!expression
|
||||
};
|
||||
},
|
||||
|
||||
/**
|
||||
* Create an ASTNode representation of an identifier
|
||||
* @param {ASTNode} name The identifier name
|
||||
* @returns {ASTNode} An ASTNode representing an identifier
|
||||
*/
|
||||
createIdentifier: function(name) {
|
||||
return {
|
||||
type: astNodeTypes.Identifier,
|
||||
name: name
|
||||
};
|
||||
},
|
||||
|
||||
/**
|
||||
* Create an ASTNode representation of an if statement
|
||||
* @param {ASTNode} test The if conditional expression
|
||||
* @param {ASTNode} consequent The consequent if statement to run
|
||||
* @param {ASTNode} alternate the "else" alternate statement
|
||||
* @returns {ASTNode} An ASTNode representing an if statement
|
||||
*/
|
||||
createIfStatement: function(test, consequent, alternate) {
|
||||
return {
|
||||
type: astNodeTypes.IfStatement,
|
||||
test: test,
|
||||
consequent: consequent,
|
||||
alternate: alternate
|
||||
};
|
||||
},
|
||||
|
||||
/**
|
||||
* Create an ASTNode representation of a labeled statement
|
||||
* @param {ASTNode} label The statement label
|
||||
* @param {ASTNode} body The labeled statement body
|
||||
* @returns {ASTNode} An ASTNode representing a labeled statement
|
||||
*/
|
||||
createLabeledStatement: function(label, body) {
|
||||
return {
|
||||
type: astNodeTypes.LabeledStatement,
|
||||
label: label,
|
||||
body: body
|
||||
};
|
||||
},
|
||||
|
||||
/**
|
||||
* Create an ASTNode literal from the source code
|
||||
* @param {ASTNode} token The ASTNode token
|
||||
* @param {string} source The source code to get the literal from
|
||||
* @returns {ASTNode} An ASTNode representing the new literal
|
||||
*/
|
||||
createLiteralFromSource: function(token, source) {
|
||||
var node = {
|
||||
type: astNodeTypes.Literal,
|
||||
value: token.value,
|
||||
raw: source.slice(token.range[0], token.range[1])
|
||||
};
|
||||
|
||||
// regular expressions have regex properties
|
||||
if (token.regex) {
|
||||
node.regex = token.regex;
|
||||
}
|
||||
|
||||
return node;
|
||||
},
|
||||
|
||||
/**
|
||||
* Create an ASTNode template element
|
||||
* @param {Object} value Data on the element value
|
||||
* @param {string} value.raw The raw template string
|
||||
* @param {string} value.cooked The processed template string
|
||||
* @param {boolean} tail True if this is the final element in a template string
|
||||
* @returns {ASTNode} An ASTNode representing the template string element
|
||||
*/
|
||||
createTemplateElement: function(value, tail) {
|
||||
return {
|
||||
type: astNodeTypes.TemplateElement,
|
||||
value: value,
|
||||
tail: tail
|
||||
};
|
||||
},
|
||||
|
||||
/**
|
||||
* Create an ASTNode template literal
|
||||
* @param {ASTNode[]} quasis An array of the template string elements
|
||||
* @param {ASTNode[]} expressions An array of the template string expressions
|
||||
* @returns {ASTNode} An ASTNode representing the template string
|
||||
*/
|
||||
createTemplateLiteral: function(quasis, expressions) {
|
||||
return {
|
||||
type: astNodeTypes.TemplateLiteral,
|
||||
quasis: quasis,
|
||||
expressions: expressions
|
||||
};
|
||||
},
|
||||
|
||||
/**
|
||||
* Create an ASTNode representation of a spread element
|
||||
* @param {ASTNode} argument The array being spread
|
||||
* @returns {ASTNode} An ASTNode representing a spread element
|
||||
*/
|
||||
createSpreadElement: function(argument) {
|
||||
return {
|
||||
type: astNodeTypes.SpreadElement,
|
||||
argument: argument
|
||||
};
|
||||
},
|
||||
|
||||
/**
|
||||
* Create an ASTNode representation of an experimental rest property
|
||||
* @param {ASTNode} argument The identifier being rested
|
||||
* @returns {ASTNode} An ASTNode representing a rest element
|
||||
*/
|
||||
createExperimentalRestProperty: function(argument) {
|
||||
return {
|
||||
type: astNodeTypes.ExperimentalRestProperty,
|
||||
argument: argument
|
||||
};
|
||||
},
|
||||
|
||||
/**
|
||||
* Create an ASTNode representation of an experimental spread property
|
||||
* @param {ASTNode} argument The identifier being spread
|
||||
* @returns {ASTNode} An ASTNode representing a spread element
|
||||
*/
|
||||
createExperimentalSpreadProperty: function(argument) {
|
||||
return {
|
||||
type: astNodeTypes.ExperimentalSpreadProperty,
|
||||
argument: argument
|
||||
};
|
||||
},
|
||||
|
||||
/**
|
||||
* Create an ASTNode tagged template expression
|
||||
* @param {ASTNode} tag The tag expression
|
||||
* @param {ASTNode} quasi A TemplateLiteral ASTNode representing
|
||||
* the template string itself.
|
||||
* @returns {ASTNode} An ASTNode representing the tagged template
|
||||
*/
|
||||
createTaggedTemplateExpression: function(tag, quasi) {
|
||||
return {
|
||||
type: astNodeTypes.TaggedTemplateExpression,
|
||||
tag: tag,
|
||||
quasi: quasi
|
||||
};
|
||||
},
|
||||
|
||||
/**
|
||||
* Create an ASTNode representation of a member expression
|
||||
* @param {string} accessor The member access method (bracket or period)
|
||||
* @param {ASTNode} object The object being referenced
|
||||
* @param {ASTNode} property The object-property being referenced
|
||||
* @returns {ASTNode} An ASTNode representing a member expression
|
||||
*/
|
||||
createMemberExpression: function(accessor, object, property) {
|
||||
return {
|
||||
type: astNodeTypes.MemberExpression,
|
||||
computed: accessor === "[",
|
||||
object: object,
|
||||
property: property
|
||||
};
|
||||
},
|
||||
|
||||
/**
|
||||
* Create an ASTNode representation of a new expression
|
||||
* @param {ASTNode} callee The constructor for the new object type
|
||||
* @param {ASTNode} args The arguments passed to the constructor
|
||||
* @returns {ASTNode} An ASTNode representing a new expression
|
||||
*/
|
||||
createNewExpression: function(callee, args) {
|
||||
return {
|
||||
type: astNodeTypes.NewExpression,
|
||||
callee: callee,
|
||||
"arguments": args
|
||||
};
|
||||
},
|
||||
|
||||
/**
|
||||
* Create an ASTNode representation of a new object expression
|
||||
* @param {ASTNode[]} properties An array of ASTNodes that represent all object
|
||||
* properties and associated values
|
||||
* @returns {ASTNode} An ASTNode representing a new object expression
|
||||
*/
|
||||
createObjectExpression: function(properties) {
|
||||
return {
|
||||
type: astNodeTypes.ObjectExpression,
|
||||
properties: properties
|
||||
};
|
||||
},
|
||||
|
||||
/**
|
||||
* Create an ASTNode representation of a postfix expression
|
||||
* @param {string} operator The postfix operator ("++", "--", etc.)
|
||||
* @param {ASTNode} argument The operator argument
|
||||
* @returns {ASTNode} An ASTNode representing a postfix expression
|
||||
*/
|
||||
createPostfixExpression: function(operator, argument) {
|
||||
return {
|
||||
type: astNodeTypes.UpdateExpression,
|
||||
operator: operator,
|
||||
argument: argument,
|
||||
prefix: false
|
||||
};
|
||||
},
|
||||
|
||||
/**
|
||||
* Create an ASTNode representation of an entire program
|
||||
* @param {ASTNode} body The program body
|
||||
* @param {string} sourceType Either "module" or "script".
|
||||
* @returns {ASTNode} An ASTNode representing an entire program
|
||||
*/
|
||||
createProgram: function(body, sourceType) {
|
||||
return {
|
||||
type: astNodeTypes.Program,
|
||||
body: body,
|
||||
sourceType: sourceType
|
||||
};
|
||||
},
|
||||
|
||||
/**
|
||||
* Create an ASTNode representation of an object property
|
||||
* @param {string} kind The type of property represented ("get", "set", etc.)
|
||||
* @param {ASTNode} key The property key
|
||||
* @param {ASTNode} value The new property value
|
||||
* @param {boolean} method True if the property is also a method (value is a function)
|
||||
* @param {boolean} shorthand True if the property is shorthand
|
||||
* @param {boolean} computed True if the property value has been computed
|
||||
* @returns {ASTNode} An ASTNode representing an object property
|
||||
*/
|
||||
createProperty: function(kind, key, value, method, shorthand, computed) {
|
||||
return {
|
||||
type: astNodeTypes.Property,
|
||||
key: key,
|
||||
value: value,
|
||||
kind: kind,
|
||||
method: method,
|
||||
shorthand: shorthand,
|
||||
computed: computed
|
||||
};
|
||||
},
|
||||
|
||||
/**
|
||||
* Create an ASTNode representation of a rest element
|
||||
* @param {ASTNode} argument The rest argument
|
||||
* @returns {ASTNode} An ASTNode representing a rest element
|
||||
*/
|
||||
createRestElement: function (argument) {
|
||||
return {
|
||||
type: astNodeTypes.RestElement,
|
||||
argument: argument
|
||||
};
|
||||
},
|
||||
|
||||
/**
|
||||
* Create an ASTNode representation of a return statement
|
||||
* @param {?ASTNode} argument The return argument, null if no argument is provided
|
||||
* @returns {ASTNode} An ASTNode representing a return statement
|
||||
*/
|
||||
createReturnStatement: function(argument) {
|
||||
return {
|
||||
type: astNodeTypes.ReturnStatement,
|
||||
argument: argument
|
||||
};
|
||||
},
|
||||
|
||||
/**
|
||||
* Create an ASTNode representation of a sequence of expressions
|
||||
* @param {ASTNode[]} expressions An array containing each expression, in order
|
||||
* @returns {ASTNode} An ASTNode representing a sequence of expressions
|
||||
*/
|
||||
createSequenceExpression: function(expressions) {
|
||||
return {
|
||||
type: astNodeTypes.SequenceExpression,
|
||||
expressions: expressions
|
||||
};
|
||||
},
|
||||
|
||||
/**
|
||||
* Create an ASTNode representation of super
|
||||
* @returns {ASTNode} An ASTNode representing super
|
||||
*/
|
||||
createSuper: function() {
|
||||
return {
|
||||
type: astNodeTypes.Super
|
||||
};
|
||||
},
|
||||
|
||||
/**
|
||||
* Create an ASTNode representation of a switch case statement
|
||||
* @param {ASTNode} test The case value to test against the switch value
|
||||
* @param {ASTNode} consequent The consequent case statement
|
||||
* @returns {ASTNode} An ASTNode representing a switch case
|
||||
*/
|
||||
createSwitchCase: function(test, consequent) {
|
||||
return {
|
||||
type: astNodeTypes.SwitchCase,
|
||||
test: test,
|
||||
consequent: consequent
|
||||
};
|
||||
},
|
||||
|
||||
/**
|
||||
* Create an ASTNode representation of a switch statement
|
||||
* @param {ASTNode} discriminant An expression to test against each case value
|
||||
* @param {ASTNode[]} cases An array of switch case statements
|
||||
* @returns {ASTNode} An ASTNode representing a switch statement
|
||||
*/
|
||||
createSwitchStatement: function(discriminant, cases) {
|
||||
return {
|
||||
type: astNodeTypes.SwitchStatement,
|
||||
discriminant: discriminant,
|
||||
cases: cases
|
||||
};
|
||||
},
|
||||
|
||||
/**
|
||||
* Create an ASTNode representation of a this statement
|
||||
* @returns {ASTNode} An ASTNode representing a this statement
|
||||
*/
|
||||
createThisExpression: function() {
|
||||
return {
|
||||
type: astNodeTypes.ThisExpression
|
||||
};
|
||||
},
|
||||
|
||||
/**
|
||||
* Create an ASTNode representation of a throw statement
|
||||
* @param {ASTNode} argument The argument to throw
|
||||
* @returns {ASTNode} An ASTNode representing a throw statement
|
||||
*/
|
||||
createThrowStatement: function(argument) {
|
||||
return {
|
||||
type: astNodeTypes.ThrowStatement,
|
||||
argument: argument
|
||||
};
|
||||
},
|
||||
|
||||
/**
|
||||
* Create an ASTNode representation of a try statement
|
||||
* @param {ASTNode} block The try block
|
||||
* @param {ASTNode} handler A catch handler
|
||||
* @param {?ASTNode} finalizer The final code block to run after the try/catch has run
|
||||
* @returns {ASTNode} An ASTNode representing a try statement
|
||||
*/
|
||||
createTryStatement: function(block, handler, finalizer) {
|
||||
return {
|
||||
type: astNodeTypes.TryStatement,
|
||||
block: block,
|
||||
handler: handler,
|
||||
finalizer: finalizer
|
||||
};
|
||||
},
|
||||
|
||||
/**
|
||||
* Create an ASTNode representation of a unary expression
|
||||
* @param {string} operator The unary operator
|
||||
* @param {ASTNode} argument The unary operand
|
||||
* @returns {ASTNode} An ASTNode representing a unary expression
|
||||
*/
|
||||
createUnaryExpression: function(operator, argument) {
|
||||
if (operator === "++" || operator === "--") {
|
||||
return {
|
||||
type: astNodeTypes.UpdateExpression,
|
||||
operator: operator,
|
||||
argument: argument,
|
||||
prefix: true
|
||||
};
|
||||
}
|
||||
return {
|
||||
type: astNodeTypes.UnaryExpression,
|
||||
operator: operator,
|
||||
argument: argument,
|
||||
prefix: true
|
||||
};
|
||||
},
|
||||
|
||||
/**
|
||||
* Create an ASTNode representation of a variable declaration
|
||||
* @param {ASTNode[]} declarations An array of variable declarations
|
||||
* @param {string} kind The kind of variable created ("var", "let", etc.)
|
||||
* @returns {ASTNode} An ASTNode representing a variable declaration
|
||||
*/
|
||||
createVariableDeclaration: function(declarations, kind) {
|
||||
return {
|
||||
type: astNodeTypes.VariableDeclaration,
|
||||
declarations: declarations,
|
||||
kind: kind
|
||||
};
|
||||
},
|
||||
|
||||
/**
|
||||
* Create an ASTNode representation of a variable declarator
|
||||
* @param {ASTNode} id The variable ID
|
||||
* @param {ASTNode} init The variable's initial value
|
||||
* @returns {ASTNode} An ASTNode representing a variable declarator
|
||||
*/
|
||||
createVariableDeclarator: function(id, init) {
|
||||
return {
|
||||
type: astNodeTypes.VariableDeclarator,
|
||||
id: id,
|
||||
init: init
|
||||
};
|
||||
},
|
||||
|
||||
/**
|
||||
* Create an ASTNode representation of a with statement
|
||||
* @param {ASTNode} object The with statement object expression
|
||||
* @param {ASTNode} body The with statement body
|
||||
* @returns {ASTNode} An ASTNode representing a with statement
|
||||
*/
|
||||
createWithStatement: function(object, body) {
|
||||
return {
|
||||
type: astNodeTypes.WithStatement,
|
||||
object: object,
|
||||
body: body
|
||||
};
|
||||
},
|
||||
|
||||
createYieldExpression: function(argument, delegate) {
|
||||
return {
|
||||
type: astNodeTypes.YieldExpression,
|
||||
argument: argument || null,
|
||||
delegate: delegate
|
||||
};
|
||||
},
|
||||
|
||||
createJSXAttribute: function(name, value) {
|
||||
return {
|
||||
type: astNodeTypes.JSXAttribute,
|
||||
name: name,
|
||||
value: value || null
|
||||
};
|
||||
},
|
||||
|
||||
createJSXSpreadAttribute: function(argument) {
|
||||
return {
|
||||
type: astNodeTypes.JSXSpreadAttribute,
|
||||
argument: argument
|
||||
};
|
||||
},
|
||||
|
||||
createJSXIdentifier: function(name) {
|
||||
return {
|
||||
type: astNodeTypes.JSXIdentifier,
|
||||
name: name
|
||||
};
|
||||
},
|
||||
|
||||
createJSXNamespacedName: function(namespace, name) {
|
||||
return {
|
||||
type: astNodeTypes.JSXNamespacedName,
|
||||
namespace: namespace,
|
||||
name: name
|
||||
};
|
||||
},
|
||||
|
||||
createJSXMemberExpression: function(object, property) {
|
||||
return {
|
||||
type: astNodeTypes.JSXMemberExpression,
|
||||
object: object,
|
||||
property: property
|
||||
};
|
||||
},
|
||||
|
||||
createJSXElement: function(openingElement, closingElement, children) {
|
||||
return {
|
||||
type: astNodeTypes.JSXElement,
|
||||
openingElement: openingElement,
|
||||
closingElement: closingElement,
|
||||
children: children
|
||||
};
|
||||
},
|
||||
|
||||
createJSXEmptyExpression: function() {
|
||||
return {
|
||||
type: astNodeTypes.JSXEmptyExpression
|
||||
};
|
||||
},
|
||||
|
||||
createJSXExpressionContainer: function(expression) {
|
||||
return {
|
||||
type: astNodeTypes.JSXExpressionContainer,
|
||||
expression: expression
|
||||
};
|
||||
},
|
||||
|
||||
createJSXOpeningElement: function(name, attributes, selfClosing) {
|
||||
return {
|
||||
type: astNodeTypes.JSXOpeningElement,
|
||||
name: name,
|
||||
selfClosing: selfClosing,
|
||||
attributes: attributes
|
||||
};
|
||||
},
|
||||
|
||||
createJSXClosingElement: function(name) {
|
||||
return {
|
||||
type: astNodeTypes.JSXClosingElement,
|
||||
name: name
|
||||
};
|
||||
},
|
||||
|
||||
createExportSpecifier: function(local, exported) {
|
||||
return {
|
||||
type: astNodeTypes.ExportSpecifier,
|
||||
exported: exported || local,
|
||||
local: local
|
||||
};
|
||||
},
|
||||
|
||||
createImportDefaultSpecifier: function(local) {
|
||||
return {
|
||||
type: astNodeTypes.ImportDefaultSpecifier,
|
||||
local: local
|
||||
};
|
||||
},
|
||||
|
||||
createImportNamespaceSpecifier: function(local) {
|
||||
return {
|
||||
type: astNodeTypes.ImportNamespaceSpecifier,
|
||||
local: local
|
||||
};
|
||||
},
|
||||
|
||||
createExportNamedDeclaration: function(declaration, specifiers, source) {
|
||||
return {
|
||||
type: astNodeTypes.ExportNamedDeclaration,
|
||||
declaration: declaration,
|
||||
specifiers: specifiers,
|
||||
source: source
|
||||
};
|
||||
},
|
||||
|
||||
createExportDefaultDeclaration: function(declaration) {
|
||||
return {
|
||||
type: astNodeTypes.ExportDefaultDeclaration,
|
||||
declaration: declaration
|
||||
};
|
||||
},
|
||||
|
||||
createExportAllDeclaration: function(source) {
|
||||
return {
|
||||
type: astNodeTypes.ExportAllDeclaration,
|
||||
source: source
|
||||
};
|
||||
},
|
||||
|
||||
createImportSpecifier: function(local, imported) {
|
||||
return {
|
||||
type: astNodeTypes.ImportSpecifier,
|
||||
local: local || imported,
|
||||
imported: imported
|
||||
};
|
||||
},
|
||||
|
||||
createImportDeclaration: function(specifiers, source) {
|
||||
return {
|
||||
type: astNodeTypes.ImportDeclaration,
|
||||
specifiers: specifiers,
|
||||
source: source
|
||||
};
|
||||
}
|
||||
|
||||
};
|
||||
119
node_modules/espree/lib/ast-node-types.js
generated
vendored
119
node_modules/espree/lib/ast-node-types.js
generated
vendored
@ -1,119 +0,0 @@
|
||||
/**
|
||||
* @fileoverview The AST node types produced by the parser.
|
||||
* @author Nicholas C. Zakas
|
||||
* @copyright 2014 Nicholas C. Zakas. All rights reserved.
|
||||
* @copyright 2011-2013 Ariya Hidayat <ariya.hidayat@gmail.com>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Requirements
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
// None!
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Public
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
module.exports = {
|
||||
AssignmentExpression: "AssignmentExpression",
|
||||
AssignmentPattern: "AssignmentPattern",
|
||||
ArrayExpression: "ArrayExpression",
|
||||
ArrayPattern: "ArrayPattern",
|
||||
ArrowFunctionExpression: "ArrowFunctionExpression",
|
||||
BlockStatement: "BlockStatement",
|
||||
BinaryExpression: "BinaryExpression",
|
||||
BreakStatement: "BreakStatement",
|
||||
CallExpression: "CallExpression",
|
||||
CatchClause: "CatchClause",
|
||||
ClassBody: "ClassBody",
|
||||
ClassDeclaration: "ClassDeclaration",
|
||||
ClassExpression: "ClassExpression",
|
||||
ConditionalExpression: "ConditionalExpression",
|
||||
ContinueStatement: "ContinueStatement",
|
||||
DoWhileStatement: "DoWhileStatement",
|
||||
DebuggerStatement: "DebuggerStatement",
|
||||
EmptyStatement: "EmptyStatement",
|
||||
ExperimentalRestProperty: "ExperimentalRestProperty",
|
||||
ExperimentalSpreadProperty: "ExperimentalSpreadProperty",
|
||||
ExpressionStatement: "ExpressionStatement",
|
||||
ForStatement: "ForStatement",
|
||||
ForInStatement: "ForInStatement",
|
||||
ForOfStatement: "ForOfStatement",
|
||||
FunctionDeclaration: "FunctionDeclaration",
|
||||
FunctionExpression: "FunctionExpression",
|
||||
Identifier: "Identifier",
|
||||
IfStatement: "IfStatement",
|
||||
Literal: "Literal",
|
||||
LabeledStatement: "LabeledStatement",
|
||||
LogicalExpression: "LogicalExpression",
|
||||
MemberExpression: "MemberExpression",
|
||||
MetaProperty: "MetaProperty",
|
||||
MethodDefinition: "MethodDefinition",
|
||||
NewExpression: "NewExpression",
|
||||
ObjectExpression: "ObjectExpression",
|
||||
ObjectPattern: "ObjectPattern",
|
||||
Program: "Program",
|
||||
Property: "Property",
|
||||
RestElement: "RestElement",
|
||||
ReturnStatement: "ReturnStatement",
|
||||
SequenceExpression: "SequenceExpression",
|
||||
SpreadElement: "SpreadElement",
|
||||
Super: "Super",
|
||||
SwitchCase: "SwitchCase",
|
||||
SwitchStatement: "SwitchStatement",
|
||||
TaggedTemplateExpression: "TaggedTemplateExpression",
|
||||
TemplateElement: "TemplateElement",
|
||||
TemplateLiteral: "TemplateLiteral",
|
||||
ThisExpression: "ThisExpression",
|
||||
ThrowStatement: "ThrowStatement",
|
||||
TryStatement: "TryStatement",
|
||||
UnaryExpression: "UnaryExpression",
|
||||
UpdateExpression: "UpdateExpression",
|
||||
VariableDeclaration: "VariableDeclaration",
|
||||
VariableDeclarator: "VariableDeclarator",
|
||||
WhileStatement: "WhileStatement",
|
||||
WithStatement: "WithStatement",
|
||||
YieldExpression: "YieldExpression",
|
||||
JSXIdentifier: "JSXIdentifier",
|
||||
JSXNamespacedName: "JSXNamespacedName",
|
||||
JSXMemberExpression: "JSXMemberExpression",
|
||||
JSXEmptyExpression: "JSXEmptyExpression",
|
||||
JSXExpressionContainer: "JSXExpressionContainer",
|
||||
JSXElement: "JSXElement",
|
||||
JSXClosingElement: "JSXClosingElement",
|
||||
JSXOpeningElement: "JSXOpeningElement",
|
||||
JSXAttribute: "JSXAttribute",
|
||||
JSXSpreadAttribute: "JSXSpreadAttribute",
|
||||
JSXText: "JSXText",
|
||||
ExportDefaultDeclaration: "ExportDefaultDeclaration",
|
||||
ExportNamedDeclaration: "ExportNamedDeclaration",
|
||||
ExportAllDeclaration: "ExportAllDeclaration",
|
||||
ExportSpecifier: "ExportSpecifier",
|
||||
ImportDeclaration: "ImportDeclaration",
|
||||
ImportSpecifier: "ImportSpecifier",
|
||||
ImportDefaultSpecifier: "ImportDefaultSpecifier",
|
||||
ImportNamespaceSpecifier: "ImportNamespaceSpecifier"
|
||||
};
|
||||
183
node_modules/espree/lib/comment-attachment.js
generated
vendored
183
node_modules/espree/lib/comment-attachment.js
generated
vendored
@ -1,183 +0,0 @@
|
||||
/**
|
||||
* @fileoverview Attaches comments to the AST.
|
||||
* @author Nicholas C. Zakas
|
||||
* @copyright 2015 Nicholas C. Zakas. All rights reserved.
|
||||
* @copyright 2011-2013 Ariya Hidayat <ariya.hidayat@gmail.com>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Requirements
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
var astNodeTypes = require("./ast-node-types");
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Private
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
var extra = {
|
||||
trailingComments: [],
|
||||
leadingComments: [],
|
||||
bottomRightStack: []
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Public
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
module.exports = {
|
||||
|
||||
reset: function() {
|
||||
extra.trailingComments = [];
|
||||
extra.leadingComments = [];
|
||||
extra.bottomRightStack = [];
|
||||
},
|
||||
|
||||
addComment: function(comment) {
|
||||
extra.trailingComments.push(comment);
|
||||
extra.leadingComments.push(comment);
|
||||
},
|
||||
|
||||
processComment: function(node) {
|
||||
var lastChild,
|
||||
trailingComments,
|
||||
i;
|
||||
|
||||
if (node.type === astNodeTypes.Program) {
|
||||
if (node.body.length > 0) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (extra.trailingComments.length > 0) {
|
||||
|
||||
/*
|
||||
* If the first comment in trailingComments comes after the
|
||||
* current node, then we're good - all comments in the array will
|
||||
* come after the node and so it's safe to add then as official
|
||||
* trailingComments.
|
||||
*/
|
||||
if (extra.trailingComments[0].range[0] >= node.range[1]) {
|
||||
trailingComments = extra.trailingComments;
|
||||
extra.trailingComments = [];
|
||||
} else {
|
||||
|
||||
/*
|
||||
* Otherwise, if the first comment doesn't come after the
|
||||
* current node, that means we have a mix of leading and trailing
|
||||
* comments in the array and that leadingComments contains the
|
||||
* same items as trailingComments. Reset trailingComments to
|
||||
* zero items and we'll handle this by evaluating leadingComments
|
||||
* later.
|
||||
*/
|
||||
extra.trailingComments.length = 0;
|
||||
}
|
||||
} else {
|
||||
if (extra.bottomRightStack.length > 0 &&
|
||||
extra.bottomRightStack[extra.bottomRightStack.length - 1].trailingComments &&
|
||||
extra.bottomRightStack[extra.bottomRightStack.length - 1].trailingComments[0].range[0] >= node.range[1]) {
|
||||
trailingComments = extra.bottomRightStack[extra.bottomRightStack.length - 1].trailingComments;
|
||||
delete extra.bottomRightStack[extra.bottomRightStack.length - 1].trailingComments;
|
||||
}
|
||||
}
|
||||
|
||||
// Eating the stack.
|
||||
while (extra.bottomRightStack.length > 0 && extra.bottomRightStack[extra.bottomRightStack.length - 1].range[0] >= node.range[0]) {
|
||||
lastChild = extra.bottomRightStack.pop();
|
||||
}
|
||||
|
||||
if (lastChild) {
|
||||
if (lastChild.leadingComments) {
|
||||
if (lastChild.leadingComments[lastChild.leadingComments.length - 1].range[1] <= node.range[0]) {
|
||||
node.leadingComments = lastChild.leadingComments;
|
||||
delete lastChild.leadingComments;
|
||||
} else {
|
||||
// A leading comment for an anonymous class had been stolen by its first MethodDefinition,
|
||||
// so this takes back the leading comment.
|
||||
// See Also: https://github.com/eslint/espree/issues/158
|
||||
for (i = lastChild.leadingComments.length - 2; i >= 0; --i) {
|
||||
if (lastChild.leadingComments[i].range[1] <= node.range[0]) {
|
||||
node.leadingComments = lastChild.leadingComments.splice(0, i + 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (extra.leadingComments.length > 0) {
|
||||
|
||||
if (extra.leadingComments[extra.leadingComments.length - 1].range[1] <= node.range[0]) {
|
||||
node.leadingComments = extra.leadingComments;
|
||||
extra.leadingComments = [];
|
||||
} else {
|
||||
|
||||
// https://github.com/eslint/espree/issues/2
|
||||
|
||||
/*
|
||||
* In special cases, such as return (without a value) and
|
||||
* debugger, all comments will end up as leadingComments and
|
||||
* will otherwise be eliminated. This extra step runs when the
|
||||
* bottomRightStack is empty and there are comments left
|
||||
* in leadingComments.
|
||||
*
|
||||
* This loop figures out the stopping point between the actual
|
||||
* leading and trailing comments by finding the location of the
|
||||
* first comment that comes after the given node.
|
||||
*/
|
||||
for (i = 0; i < extra.leadingComments.length; i++) {
|
||||
if (extra.leadingComments[i].range[1] > node.range[0]) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Split the array based on the location of the first comment
|
||||
* that comes after the node. Keep in mind that this could
|
||||
* result in an empty array, and if so, the array must be
|
||||
* deleted.
|
||||
*/
|
||||
node.leadingComments = extra.leadingComments.slice(0, i);
|
||||
if (node.leadingComments.length === 0) {
|
||||
delete node.leadingComments;
|
||||
}
|
||||
|
||||
/*
|
||||
* Similarly, trailing comments are attached later. The variable
|
||||
* must be reset to null if there are no trailing comments.
|
||||
*/
|
||||
trailingComments = extra.leadingComments.slice(i);
|
||||
if (trailingComments.length === 0) {
|
||||
trailingComments = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (trailingComments) {
|
||||
node.trailingComments = trailingComments;
|
||||
}
|
||||
|
||||
extra.bottomRightStack.push(node);
|
||||
}
|
||||
|
||||
};
|
||||
117
node_modules/espree/lib/features.js
generated
vendored
117
node_modules/espree/lib/features.js
generated
vendored
@ -1,117 +0,0 @@
|
||||
/**
|
||||
* @fileoverview The list of feature flags supported by the parser and their default
|
||||
* settings.
|
||||
* @author Nicholas C. Zakas
|
||||
* @copyright 2015 Fred K. Schott. All rights reserved.
|
||||
* @copyright 2014 Nicholas C. Zakas. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Requirements
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
// None!
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Public
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
module.exports = {
|
||||
|
||||
// enable parsing of arrow functions
|
||||
arrowFunctions: false,
|
||||
|
||||
// enable parsing of let and const
|
||||
blockBindings: true,
|
||||
|
||||
// enable parsing of destructured arrays and objects
|
||||
destructuring: false,
|
||||
|
||||
// enable parsing of regex u flag
|
||||
regexUFlag: false,
|
||||
|
||||
// enable parsing of regex y flag
|
||||
regexYFlag: false,
|
||||
|
||||
// enable parsing of template strings
|
||||
templateStrings: false,
|
||||
|
||||
// enable parsing binary literals
|
||||
binaryLiterals: false,
|
||||
|
||||
// enable parsing ES6 octal literals
|
||||
octalLiterals: false,
|
||||
|
||||
// enable parsing unicode code point escape sequences
|
||||
unicodeCodePointEscapes: true,
|
||||
|
||||
// enable parsing of default parameters
|
||||
defaultParams: false,
|
||||
|
||||
// enable parsing of rest parameters
|
||||
restParams: false,
|
||||
|
||||
// enable parsing of for-of statements
|
||||
forOf: false,
|
||||
|
||||
// enable parsing computed object literal properties
|
||||
objectLiteralComputedProperties: false,
|
||||
|
||||
// enable parsing of shorthand object literal methods
|
||||
objectLiteralShorthandMethods: false,
|
||||
|
||||
// enable parsing of shorthand object literal properties
|
||||
objectLiteralShorthandProperties: false,
|
||||
|
||||
// Allow duplicate object literal properties (except '__proto__')
|
||||
objectLiteralDuplicateProperties: false,
|
||||
|
||||
// enable parsing of generators/yield
|
||||
generators: false,
|
||||
|
||||
// support the spread operator
|
||||
spread: false,
|
||||
|
||||
// enable super in functions
|
||||
superInFunctions: false,
|
||||
|
||||
// enable parsing of classes
|
||||
classes: false,
|
||||
|
||||
// enable parsing of new.target
|
||||
newTarget: false,
|
||||
|
||||
// enable parsing of modules
|
||||
modules: false,
|
||||
|
||||
// React JSX parsing
|
||||
jsx: false,
|
||||
|
||||
// allow return statement in global scope
|
||||
globalReturn: false,
|
||||
|
||||
// allow experimental object rest/spread
|
||||
experimentalObjectRestSpread: false
|
||||
};
|
||||
99
node_modules/espree/lib/messages.js
generated
vendored
99
node_modules/espree/lib/messages.js
generated
vendored
@ -1,99 +0,0 @@
|
||||
/**
|
||||
* @fileoverview Error messages returned by the parser.
|
||||
* @author Nicholas C. Zakas
|
||||
* @copyright 2014 Nicholas C. Zakas. All rights reserved.
|
||||
* @copyright 2011-2013 Ariya Hidayat <ariya.hidayat@gmail.com>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Requirements
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
// None!
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Public
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
// error messages should be identical to V8 where possible
|
||||
module.exports = {
|
||||
UnexpectedToken: "Unexpected token %0",
|
||||
UnexpectedNumber: "Unexpected number",
|
||||
UnexpectedString: "Unexpected string",
|
||||
UnexpectedIdentifier: "Unexpected identifier",
|
||||
UnexpectedReserved: "Unexpected reserved word",
|
||||
UnexpectedTemplate: "Unexpected quasi %0",
|
||||
UnexpectedEOS: "Unexpected end of input",
|
||||
NewlineAfterThrow: "Illegal newline after throw",
|
||||
InvalidRegExp: "Invalid regular expression",
|
||||
InvalidRegExpFlag: "Invalid regular expression flag",
|
||||
UnterminatedRegExp: "Invalid regular expression: missing /",
|
||||
InvalidLHSInAssignment: "Invalid left-hand side in assignment",
|
||||
InvalidLHSInFormalsList: "Invalid left-hand side in formals list",
|
||||
InvalidLHSInForIn: "Invalid left-hand side in for-in",
|
||||
MultipleDefaultsInSwitch: "More than one default clause in switch statement",
|
||||
NoCatchOrFinally: "Missing catch or finally after try",
|
||||
NoUnintializedConst: "Const must be initialized",
|
||||
UnknownLabel: "Undefined label '%0'",
|
||||
Redeclaration: "%0 '%1' has already been declared",
|
||||
IllegalContinue: "Illegal continue statement",
|
||||
IllegalBreak: "Illegal break statement",
|
||||
IllegalReturn: "Illegal return statement",
|
||||
IllegalYield: "Illegal yield expression",
|
||||
IllegalSpread: "Illegal spread element",
|
||||
StrictModeWith: "Strict mode code may not include a with statement",
|
||||
StrictCatchVariable: "Catch variable may not be eval or arguments in strict mode",
|
||||
StrictVarName: "Variable name may not be eval or arguments in strict mode",
|
||||
StrictParamName: "Parameter name eval or arguments is not allowed in strict mode",
|
||||
StrictParamDupe: "Strict mode function may not have duplicate parameter names",
|
||||
TemplateOctalLiteral: "Octal literals are not allowed in template strings.",
|
||||
ParameterAfterRestParameter: "Rest parameter must be last formal parameter",
|
||||
DefaultRestParameter: "Rest parameter can not have a default value",
|
||||
ElementAfterSpreadElement: "Spread must be the final element of an element list",
|
||||
ObjectPatternAsRestParameter: "Invalid rest parameter",
|
||||
ObjectPatternAsSpread: "Invalid spread argument",
|
||||
StrictFunctionName: "Function name may not be eval or arguments in strict mode",
|
||||
StrictOctalLiteral: "Octal literals are not allowed in strict mode.",
|
||||
StrictDelete: "Delete of an unqualified identifier in strict mode.",
|
||||
StrictDuplicateProperty: "Duplicate data property in object literal not allowed in strict mode",
|
||||
DuplicatePrototypeProperty: "Duplicate '__proto__' property in object literal are not allowed",
|
||||
ConstructorSpecialMethod: "Class constructor may not be an accessor",
|
||||
DuplicateConstructor: "A class may only have one constructor",
|
||||
StaticPrototype: "Classes may not have static property named prototype",
|
||||
AccessorDataProperty: "Object literal may not have data and accessor property with the same name",
|
||||
AccessorGetSet: "Object literal may not have multiple get/set accessors with the same name",
|
||||
StrictLHSAssignment: "Assignment to eval or arguments is not allowed in strict mode",
|
||||
StrictLHSPostfix: "Postfix increment/decrement may not have eval or arguments operand in strict mode",
|
||||
StrictLHSPrefix: "Prefix increment/decrement may not have eval or arguments operand in strict mode",
|
||||
StrictReservedWord: "Use of future reserved word in strict mode",
|
||||
InvalidJSXAttributeValue: "JSX value should be either an expression or a quoted JSX text",
|
||||
ExpectedJSXClosingTag: "Expected corresponding JSX closing tag for %0",
|
||||
AdjacentJSXElements: "Adjacent JSX elements must be wrapped in an enclosing tag",
|
||||
MissingFromClause: "Missing from clause",
|
||||
NoAsAfterImportNamespace: "Missing as after import *",
|
||||
InvalidModuleSpecifier: "Invalid module specifier",
|
||||
IllegalImportDeclaration: "Illegal import declaration",
|
||||
IllegalExportDeclaration: "Illegal export declaration"
|
||||
};
|
||||
55
node_modules/espree/lib/string-map.js
generated
vendored
55
node_modules/espree/lib/string-map.js
generated
vendored
@ -1,55 +0,0 @@
|
||||
/**
|
||||
* @fileoverview A simple map that helps avoid collisions on the Object prototype.
|
||||
* @author Jamund Ferguson
|
||||
* @copyright 2015 Jamund Ferguson. All rights reserved.
|
||||
* @copyright 2011-2013 Ariya Hidayat <ariya.hidayat@gmail.com>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
function StringMap() {
|
||||
this.$data = {};
|
||||
}
|
||||
|
||||
StringMap.prototype.get = function (key) {
|
||||
key = "$" + key;
|
||||
return this.$data[key];
|
||||
};
|
||||
|
||||
StringMap.prototype.set = function (key, value) {
|
||||
key = "$" + key;
|
||||
this.$data[key] = value;
|
||||
return this;
|
||||
};
|
||||
|
||||
StringMap.prototype.has = function (key) {
|
||||
key = "$" + key;
|
||||
return Object.prototype.hasOwnProperty.call(this.$data, key);
|
||||
};
|
||||
|
||||
StringMap.prototype.delete = function (key) {
|
||||
key = "$" + key;
|
||||
return delete this.$data[key];
|
||||
};
|
||||
|
||||
module.exports = StringMap;
|
||||
189
node_modules/espree/lib/syntax.js
generated
vendored
189
node_modules/espree/lib/syntax.js
generated
vendored
File diff suppressed because one or more lines are too long
90
node_modules/espree/lib/token-info.js
generated
vendored
90
node_modules/espree/lib/token-info.js
generated
vendored
@ -1,90 +0,0 @@
|
||||
/**
|
||||
* @fileoverview Contains token information.
|
||||
* @author Nicholas C. Zakas
|
||||
* @copyright 2014 Nicholas C. Zakas. All rights reserved.
|
||||
* @copyright 2013 Thaddee Tyl <thaddee.tyl@gmail.com>
|
||||
* @copyright 2011-2013 Ariya Hidayat <ariya.hidayat@gmail.com>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Requirements
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
// None!
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Private
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
var Token = {
|
||||
BooleanLiteral: 1,
|
||||
EOF: 2,
|
||||
Identifier: 3,
|
||||
Keyword: 4,
|
||||
NullLiteral: 5,
|
||||
NumericLiteral: 6,
|
||||
Punctuator: 7,
|
||||
StringLiteral: 8,
|
||||
RegularExpression: 9,
|
||||
Template: 10,
|
||||
JSXIdentifier: 11,
|
||||
JSXText: 12
|
||||
};
|
||||
|
||||
var TokenName = {};
|
||||
TokenName[Token.BooleanLiteral] = "Boolean";
|
||||
TokenName[Token.EOF] = "<end>";
|
||||
TokenName[Token.Identifier] = "Identifier";
|
||||
TokenName[Token.Keyword] = "Keyword";
|
||||
TokenName[Token.NullLiteral] = "Null";
|
||||
TokenName[Token.NumericLiteral] = "Numeric";
|
||||
TokenName[Token.Punctuator] = "Punctuator";
|
||||
TokenName[Token.StringLiteral] = "String";
|
||||
TokenName[Token.RegularExpression] = "RegularExpression";
|
||||
TokenName[Token.Template] = "Template";
|
||||
TokenName[Token.JSXIdentifier] = "JSXIdentifier";
|
||||
TokenName[Token.JSXText] = "JSXText";
|
||||
|
||||
// A function following one of those tokens is an expression.
|
||||
var FnExprTokens = ["(", "{", "[", "in", "typeof", "instanceof", "new",
|
||||
"return", "case", "delete", "throw", "void",
|
||||
// assignment operators
|
||||
"=", "+=", "-=", "*=", "/=", "%=", "<<=", ">>=", ">>>=",
|
||||
"&=", "|=", "^=", ",",
|
||||
// binary/unary operators
|
||||
"+", "-", "*", "/", "%", "++", "--", "<<", ">>", ">>>", "&",
|
||||
"|", "^", "!", "~", "&&", "||", "?", ":", "===", "==", ">=",
|
||||
"<=", "<", ">", "!=", "!=="];
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Public
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
module.exports = {
|
||||
Token: Token,
|
||||
TokenName: TokenName,
|
||||
FnExprTokens: FnExprTokens
|
||||
};
|
||||
293
node_modules/espree/lib/xhtml-entities.js
generated
vendored
293
node_modules/espree/lib/xhtml-entities.js
generated
vendored
@ -1,293 +0,0 @@
|
||||
/**
|
||||
* @fileoverview The list of XHTML entities that are valid in JSX.
|
||||
* @author Nicholas C. Zakas
|
||||
* @copyright 2014 Nicholas C. Zakas. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Requirements
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
// None!
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Public
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
module.exports = {
|
||||
quot: "\u0022",
|
||||
amp: "&",
|
||||
apos: "\u0027",
|
||||
lt: "<",
|
||||
gt: ">",
|
||||
nbsp: "\u00A0",
|
||||
iexcl: "\u00A1",
|
||||
cent: "\u00A2",
|
||||
pound: "\u00A3",
|
||||
curren: "\u00A4",
|
||||
yen: "\u00A5",
|
||||
brvbar: "\u00A6",
|
||||
sect: "\u00A7",
|
||||
uml: "\u00A8",
|
||||
copy: "\u00A9",
|
||||
ordf: "\u00AA",
|
||||
laquo: "\u00AB",
|
||||
not: "\u00AC",
|
||||
shy: "\u00AD",
|
||||
reg: "\u00AE",
|
||||
macr: "\u00AF",
|
||||
deg: "\u00B0",
|
||||
plusmn: "\u00B1",
|
||||
sup2: "\u00B2",
|
||||
sup3: "\u00B3",
|
||||
acute: "\u00B4",
|
||||
micro: "\u00B5",
|
||||
para: "\u00B6",
|
||||
middot: "\u00B7",
|
||||
cedil: "\u00B8",
|
||||
sup1: "\u00B9",
|
||||
ordm: "\u00BA",
|
||||
raquo: "\u00BB",
|
||||
frac14: "\u00BC",
|
||||
frac12: "\u00BD",
|
||||
frac34: "\u00BE",
|
||||
iquest: "\u00BF",
|
||||
Agrave: "\u00C0",
|
||||
Aacute: "\u00C1",
|
||||
Acirc: "\u00C2",
|
||||
Atilde: "\u00C3",
|
||||
Auml: "\u00C4",
|
||||
Aring: "\u00C5",
|
||||
AElig: "\u00C6",
|
||||
Ccedil: "\u00C7",
|
||||
Egrave: "\u00C8",
|
||||
Eacute: "\u00C9",
|
||||
Ecirc: "\u00CA",
|
||||
Euml: "\u00CB",
|
||||
Igrave: "\u00CC",
|
||||
Iacute: "\u00CD",
|
||||
Icirc: "\u00CE",
|
||||
Iuml: "\u00CF",
|
||||
ETH: "\u00D0",
|
||||
Ntilde: "\u00D1",
|
||||
Ograve: "\u00D2",
|
||||
Oacute: "\u00D3",
|
||||
Ocirc: "\u00D4",
|
||||
Otilde: "\u00D5",
|
||||
Ouml: "\u00D6",
|
||||
times: "\u00D7",
|
||||
Oslash: "\u00D8",
|
||||
Ugrave: "\u00D9",
|
||||
Uacute: "\u00DA",
|
||||
Ucirc: "\u00DB",
|
||||
Uuml: "\u00DC",
|
||||
Yacute: "\u00DD",
|
||||
THORN: "\u00DE",
|
||||
szlig: "\u00DF",
|
||||
agrave: "\u00E0",
|
||||
aacute: "\u00E1",
|
||||
acirc: "\u00E2",
|
||||
atilde: "\u00E3",
|
||||
auml: "\u00E4",
|
||||
aring: "\u00E5",
|
||||
aelig: "\u00E6",
|
||||
ccedil: "\u00E7",
|
||||
egrave: "\u00E8",
|
||||
eacute: "\u00E9",
|
||||
ecirc: "\u00EA",
|
||||
euml: "\u00EB",
|
||||
igrave: "\u00EC",
|
||||
iacute: "\u00ED",
|
||||
icirc: "\u00EE",
|
||||
iuml: "\u00EF",
|
||||
eth: "\u00F0",
|
||||
ntilde: "\u00F1",
|
||||
ograve: "\u00F2",
|
||||
oacute: "\u00F3",
|
||||
ocirc: "\u00F4",
|
||||
otilde: "\u00F5",
|
||||
ouml: "\u00F6",
|
||||
divide: "\u00F7",
|
||||
oslash: "\u00F8",
|
||||
ugrave: "\u00F9",
|
||||
uacute: "\u00FA",
|
||||
ucirc: "\u00FB",
|
||||
uuml: "\u00FC",
|
||||
yacute: "\u00FD",
|
||||
thorn: "\u00FE",
|
||||
yuml: "\u00FF",
|
||||
OElig: "\u0152",
|
||||
oelig: "\u0153",
|
||||
Scaron: "\u0160",
|
||||
scaron: "\u0161",
|
||||
Yuml: "\u0178",
|
||||
fnof: "\u0192",
|
||||
circ: "\u02C6",
|
||||
tilde: "\u02DC",
|
||||
Alpha: "\u0391",
|
||||
Beta: "\u0392",
|
||||
Gamma: "\u0393",
|
||||
Delta: "\u0394",
|
||||
Epsilon: "\u0395",
|
||||
Zeta: "\u0396",
|
||||
Eta: "\u0397",
|
||||
Theta: "\u0398",
|
||||
Iota: "\u0399",
|
||||
Kappa: "\u039A",
|
||||
Lambda: "\u039B",
|
||||
Mu: "\u039C",
|
||||
Nu: "\u039D",
|
||||
Xi: "\u039E",
|
||||
Omicron: "\u039F",
|
||||
Pi: "\u03A0",
|
||||
Rho: "\u03A1",
|
||||
Sigma: "\u03A3",
|
||||
Tau: "\u03A4",
|
||||
Upsilon: "\u03A5",
|
||||
Phi: "\u03A6",
|
||||
Chi: "\u03A7",
|
||||
Psi: "\u03A8",
|
||||
Omega: "\u03A9",
|
||||
alpha: "\u03B1",
|
||||
beta: "\u03B2",
|
||||
gamma: "\u03B3",
|
||||
delta: "\u03B4",
|
||||
epsilon: "\u03B5",
|
||||
zeta: "\u03B6",
|
||||
eta: "\u03B7",
|
||||
theta: "\u03B8",
|
||||
iota: "\u03B9",
|
||||
kappa: "\u03BA",
|
||||
lambda: "\u03BB",
|
||||
mu: "\u03BC",
|
||||
nu: "\u03BD",
|
||||
xi: "\u03BE",
|
||||
omicron: "\u03BF",
|
||||
pi: "\u03C0",
|
||||
rho: "\u03C1",
|
||||
sigmaf: "\u03C2",
|
||||
sigma: "\u03C3",
|
||||
tau: "\u03C4",
|
||||
upsilon: "\u03C5",
|
||||
phi: "\u03C6",
|
||||
chi: "\u03C7",
|
||||
psi: "\u03C8",
|
||||
omega: "\u03C9",
|
||||
thetasym: "\u03D1",
|
||||
upsih: "\u03D2",
|
||||
piv: "\u03D6",
|
||||
ensp: "\u2002",
|
||||
emsp: "\u2003",
|
||||
thinsp: "\u2009",
|
||||
zwnj: "\u200C",
|
||||
zwj: "\u200D",
|
||||
lrm: "\u200E",
|
||||
rlm: "\u200F",
|
||||
ndash: "\u2013",
|
||||
mdash: "\u2014",
|
||||
lsquo: "\u2018",
|
||||
rsquo: "\u2019",
|
||||
sbquo: "\u201A",
|
||||
ldquo: "\u201C",
|
||||
rdquo: "\u201D",
|
||||
bdquo: "\u201E",
|
||||
dagger: "\u2020",
|
||||
Dagger: "\u2021",
|
||||
bull: "\u2022",
|
||||
hellip: "\u2026",
|
||||
permil: "\u2030",
|
||||
prime: "\u2032",
|
||||
Prime: "\u2033",
|
||||
lsaquo: "\u2039",
|
||||
rsaquo: "\u203A",
|
||||
oline: "\u203E",
|
||||
frasl: "\u2044",
|
||||
euro: "\u20AC",
|
||||
image: "\u2111",
|
||||
weierp: "\u2118",
|
||||
real: "\u211C",
|
||||
trade: "\u2122",
|
||||
alefsym: "\u2135",
|
||||
larr: "\u2190",
|
||||
uarr: "\u2191",
|
||||
rarr: "\u2192",
|
||||
darr: "\u2193",
|
||||
harr: "\u2194",
|
||||
crarr: "\u21B5",
|
||||
lArr: "\u21D0",
|
||||
uArr: "\u21D1",
|
||||
rArr: "\u21D2",
|
||||
dArr: "\u21D3",
|
||||
hArr: "\u21D4",
|
||||
forall: "\u2200",
|
||||
part: "\u2202",
|
||||
exist: "\u2203",
|
||||
empty: "\u2205",
|
||||
nabla: "\u2207",
|
||||
isin: "\u2208",
|
||||
notin: "\u2209",
|
||||
ni: "\u220B",
|
||||
prod: "\u220F",
|
||||
sum: "\u2211",
|
||||
minus: "\u2212",
|
||||
lowast: "\u2217",
|
||||
radic: "\u221A",
|
||||
prop: "\u221D",
|
||||
infin: "\u221E",
|
||||
ang: "\u2220",
|
||||
and: "\u2227",
|
||||
or: "\u2228",
|
||||
cap: "\u2229",
|
||||
cup: "\u222A",
|
||||
"int": "\u222B",
|
||||
there4: "\u2234",
|
||||
sim: "\u223C",
|
||||
cong: "\u2245",
|
||||
asymp: "\u2248",
|
||||
ne: "\u2260",
|
||||
equiv: "\u2261",
|
||||
le: "\u2264",
|
||||
ge: "\u2265",
|
||||
sub: "\u2282",
|
||||
sup: "\u2283",
|
||||
nsub: "\u2284",
|
||||
sube: "\u2286",
|
||||
supe: "\u2287",
|
||||
oplus: "\u2295",
|
||||
otimes: "\u2297",
|
||||
perp: "\u22A5",
|
||||
sdot: "\u22C5",
|
||||
lceil: "\u2308",
|
||||
rceil: "\u2309",
|
||||
lfloor: "\u230A",
|
||||
rfloor: "\u230B",
|
||||
lang: "\u2329",
|
||||
rang: "\u232A",
|
||||
loz: "\u25CA",
|
||||
spades: "\u2660",
|
||||
clubs: "\u2663",
|
||||
hearts: "\u2665",
|
||||
diams: "\u2666"
|
||||
};
|
||||
107
node_modules/espree/package.json
generated
vendored
107
node_modules/espree/package.json
generated
vendored
@ -1,107 +0,0 @@
|
||||
{
|
||||
"name": "espree",
|
||||
"description": "An actively-maintained fork of Esprima, the ECMAScript parsing infrastructure for multipurpose analysis",
|
||||
"author": {
|
||||
"name": "Nicholas C. Zakas",
|
||||
"email": "nicholas+npm@nczconsulting.com"
|
||||
},
|
||||
"homepage": "https://github.com/eslint/espree",
|
||||
"main": "espree.js",
|
||||
"bin": {
|
||||
"esparse": "./bin/esparse.js",
|
||||
"esvalidate": "./bin/esvalidate.js"
|
||||
},
|
||||
"version": "2.2.3",
|
||||
"files": [
|
||||
"bin",
|
||||
"lib",
|
||||
"test/run.js",
|
||||
"test/runner.js",
|
||||
"test/test.js",
|
||||
"test/compat.js",
|
||||
"test/reflect.js",
|
||||
"espree.js"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "http://github.com/eslint/espree.git"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "http://github.com/eslint/espree.git"
|
||||
},
|
||||
"licenses": [
|
||||
{
|
||||
"type": "BSD",
|
||||
"url": "http://github.com/nzakas/espree/raw/master/LICENSE"
|
||||
}
|
||||
],
|
||||
"devDependencies": {
|
||||
"browserify": "^7.0.0",
|
||||
"chai": "^1.10.0",
|
||||
"complexity-report": "~0.6.1",
|
||||
"dateformat": "^1.0.11",
|
||||
"eslint": "^0.9.2",
|
||||
"esprima": "git://github.com/jquery/esprima",
|
||||
"esprima-fb": "^8001.2001.0-dev-harmony-fb",
|
||||
"istanbul": "~0.2.6",
|
||||
"json-diff": "~0.3.1",
|
||||
"leche": "^1.0.1",
|
||||
"mocha": "^2.0.1",
|
||||
"npm-license": "^0.2.3",
|
||||
"optimist": "~0.6.0",
|
||||
"regenerate": "~0.5.4",
|
||||
"semver": "^4.1.1",
|
||||
"shelljs": "^0.3.0",
|
||||
"shelljs-nodecli": "^0.1.1",
|
||||
"unicode-6.3.0": "~0.1.0"
|
||||
},
|
||||
"keywords": [
|
||||
"ast",
|
||||
"ecmascript",
|
||||
"javascript",
|
||||
"parser",
|
||||
"syntax"
|
||||
],
|
||||
"scripts": {
|
||||
"generate-regex": "node tools/generate-identifier-regex.js",
|
||||
"test": "npm run-script lint && node Makefile.js test && node test/run.js",
|
||||
"lint": "node Makefile.js lint",
|
||||
"patch": "node Makefile.js patch",
|
||||
"minor": "node Makefile.js minor",
|
||||
"major": "node Makefile.js major",
|
||||
"browserify": "node Makefile.js browserify",
|
||||
"coverage": "npm run-script analyze-coverage && npm run-script check-coverage",
|
||||
"analyze-coverage": "node node_modules/istanbul/lib/cli.js cover test/runner.js",
|
||||
"check-coverage": "node node_modules/istanbul/lib/cli.js check-coverage --statement 99 --branch 99 --function 99",
|
||||
"complexity": "npm run-script analyze-complexity && npm run-script check-complexity",
|
||||
"analyze-complexity": "node tools/list-complexity.js",
|
||||
"check-complexity": "node node_modules/complexity-report/src/cli.js --maxcc 14 --silent -l -w espree.js",
|
||||
"benchmark": "node test/benchmarks.js",
|
||||
"benchmark-quick": "node test/benchmarks.js quick"
|
||||
},
|
||||
"dependencies": {},
|
||||
"gitHead": "4e72bb00332dbbced9a77d7c281962a46a6759cc",
|
||||
"_id": "espree@2.2.3",
|
||||
"_shasum": "158cfc10f6e57c6bbc5a7438eb8bc40f267f9b54",
|
||||
"_from": "espree@>=2.2.3 <2.3.0",
|
||||
"_npmVersion": "1.4.28",
|
||||
"_npmUser": {
|
||||
"name": "nzakas",
|
||||
"email": "nicholas@nczconsulting.com"
|
||||
},
|
||||
"maintainers": [
|
||||
{
|
||||
"name": "nzakas",
|
||||
"email": "nicholas@nczconsulting.com"
|
||||
}
|
||||
],
|
||||
"dist": {
|
||||
"shasum": "158cfc10f6e57c6bbc5a7438eb8bc40f267f9b54",
|
||||
"tarball": "http://registry.npmjs.org/espree/-/espree-2.2.3.tgz"
|
||||
},
|
||||
"directories": {},
|
||||
"_resolved": "https://registry.npmjs.org/espree/-/espree-2.2.3.tgz"
|
||||
}
|
||||
194
node_modules/js2xmlparser/LICENSE.md
generated
vendored
194
node_modules/js2xmlparser/LICENSE.md
generated
vendored
@ -1,194 +0,0 @@
|
||||
Apache License
|
||||
==============
|
||||
|
||||
_Version 2.0, January 2004_
|
||||
_<<http://www.apache.org/licenses/>>_
|
||||
|
||||
### Terms and Conditions for use, reproduction, and distribution
|
||||
|
||||
#### 1. Definitions
|
||||
|
||||
“License” shall mean the terms and conditions for use, reproduction, and
|
||||
distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
“Licensor” shall mean the copyright owner or entity authorized by the copyright
|
||||
owner that is granting the License.
|
||||
|
||||
“Legal Entity” shall mean the union of the acting entity and all other entities
|
||||
that control, are controlled by, or are under common control with that entity.
|
||||
For the purposes of this definition, “control” means **(i)** the power, direct or
|
||||
indirect, to cause the direction or management of such entity, whether by
|
||||
contract or otherwise, or **(ii)** ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or **(iii)** beneficial ownership of such entity.
|
||||
|
||||
“You” (or “Your”) shall mean an individual or Legal Entity exercising
|
||||
permissions granted by this License.
|
||||
|
||||
“Source” form shall mean the preferred form for making modifications, including
|
||||
but not limited to software source code, documentation source, and configuration
|
||||
files.
|
||||
|
||||
“Object” form shall mean any form resulting from mechanical transformation or
|
||||
translation of a Source form, including but not limited to compiled object code,
|
||||
generated documentation, and conversions to other media types.
|
||||
|
||||
“Work” shall mean the work of authorship, whether in Source or Object form, made
|
||||
available under the License, as indicated by a copyright notice that is included
|
||||
in or attached to the work (an example is provided in the Appendix below).
|
||||
|
||||
“Derivative Works” shall mean any work, whether in Source or Object form, that
|
||||
is based on (or derived from) the Work and for which the editorial revisions,
|
||||
annotations, elaborations, or other modifications represent, as a whole, an
|
||||
original work of authorship. For the purposes of this License, Derivative Works
|
||||
shall not include works that remain separable from, or merely link (or bind by
|
||||
name) to the interfaces of, the Work and Derivative Works thereof.
|
||||
|
||||
“Contribution” shall mean any work of authorship, including the original version
|
||||
of the Work and any modifications or additions to that Work or Derivative Works
|
||||
thereof, that is intentionally submitted to Licensor for inclusion in the Work
|
||||
by the copyright owner or by an individual or Legal Entity authorized to submit
|
||||
on behalf of the copyright owner. For the purposes of this definition,
|
||||
“submitted” means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems, and
|
||||
issue tracking systems that are managed by, or on behalf of, the Licensor for
|
||||
the purpose of discussing and improving the Work, but excluding communication
|
||||
that is conspicuously marked or otherwise designated in writing by the copyright
|
||||
owner as “Not a Contribution.”
|
||||
|
||||
“Contributor” shall mean Licensor and any individual or Legal Entity on behalf
|
||||
of whom a Contribution has been received by Licensor and subsequently
|
||||
incorporated within the Work.
|
||||
|
||||
#### 2. Grant of Copyright License
|
||||
|
||||
Subject to the terms and conditions of this License, each Contributor hereby
|
||||
grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free,
|
||||
irrevocable copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the Work and such
|
||||
Derivative Works in Source or Object form.
|
||||
|
||||
#### 3. Grant of Patent License
|
||||
|
||||
Subject to the terms and conditions of this License, each Contributor hereby
|
||||
grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free,
|
||||
irrevocable (except as stated in this section) patent license to make, have
|
||||
made, use, offer to sell, sell, import, and otherwise transfer the Work, where
|
||||
such license applies only to those patent claims licensable by such Contributor
|
||||
that are necessarily infringed by their Contribution(s) alone or by combination
|
||||
of their Contribution(s) with the Work to which such Contribution(s) was
|
||||
submitted. If You institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work or a
|
||||
Contribution incorporated within the Work constitutes direct or contributory
|
||||
patent infringement, then any patent licenses granted to You under this License
|
||||
for that Work shall terminate as of the date such litigation is filed.
|
||||
|
||||
#### 4. Redistribution
|
||||
|
||||
You may reproduce and distribute copies of the Work or Derivative Works thereof
|
||||
in any medium, with or without modifications, and in Source or Object form,
|
||||
provided that You meet the following conditions:
|
||||
|
||||
* **(a)** You must give any other recipients of the Work or Derivative Works a copy of
|
||||
this License; and
|
||||
* **(b)** You must cause any modified files to carry prominent notices stating that You
|
||||
changed the files; and
|
||||
* **(c)** You must retain, in the Source form of any Derivative Works that You distribute,
|
||||
all copyright, patent, trademark, and attribution notices from the Source form
|
||||
of the Work, excluding those notices that do not pertain to any part of the
|
||||
Derivative Works; and
|
||||
* **(d)** If the Work includes a “NOTICE” text file as part of its distribution, then any
|
||||
Derivative Works that You distribute must include a readable copy of the
|
||||
attribution notices contained within such NOTICE file, excluding those notices
|
||||
that do not pertain to any part of the Derivative Works, in at least one of the
|
||||
following places: within a NOTICE text file distributed as part of the
|
||||
Derivative Works; within the Source form or documentation, if provided along
|
||||
with the Derivative Works; or, within a display generated by the Derivative
|
||||
Works, if and wherever such third-party notices normally appear. The contents of
|
||||
the NOTICE file are for informational purposes only and do not modify the
|
||||
License. You may add Your own attribution notices within Derivative Works that
|
||||
You distribute, alongside or as an addendum to the NOTICE text from the Work,
|
||||
provided that such additional attribution notices cannot be construed as
|
||||
modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and may provide
|
||||
additional or different license terms and conditions for use, reproduction, or
|
||||
distribution of Your modifications, or for any such Derivative Works as a whole,
|
||||
provided Your use, reproduction, and distribution of the Work otherwise complies
|
||||
with the conditions stated in this License.
|
||||
|
||||
#### 5. Submission of Contributions
|
||||
|
||||
Unless You explicitly state otherwise, any Contribution intentionally submitted
|
||||
for inclusion in the Work by You to the Licensor shall be under the terms and
|
||||
conditions of this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify the terms of
|
||||
any separate license agreement you may have executed with Licensor regarding
|
||||
such Contributions.
|
||||
|
||||
#### 6. Trademarks
|
||||
|
||||
This License does not grant permission to use the trade names, trademarks,
|
||||
service marks, or product names of the Licensor, except as required for
|
||||
reasonable and customary use in describing the origin of the Work and
|
||||
reproducing the content of the NOTICE file.
|
||||
|
||||
#### 7. Disclaimer of Warranty
|
||||
|
||||
Unless required by applicable law or agreed to in writing, Licensor provides the
|
||||
Work (and each Contributor provides its Contributions) on an “AS IS” BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied,
|
||||
including, without limitation, any warranties or conditions of TITLE,
|
||||
NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are
|
||||
solely responsible for determining the appropriateness of using or
|
||||
redistributing the Work and assume any risks associated with Your exercise of
|
||||
permissions under this License.
|
||||
|
||||
#### 8. Limitation of Liability
|
||||
|
||||
In no event and under no legal theory, whether in tort (including negligence),
|
||||
contract, or otherwise, unless required by applicable law (such as deliberate
|
||||
and grossly negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special, incidental,
|
||||
or consequential damages of any character arising as a result of this License or
|
||||
out of the use or inability to use the Work (including but not limited to
|
||||
damages for loss of goodwill, work stoppage, computer failure or malfunction, or
|
||||
any and all other commercial damages or losses), even if such Contributor has
|
||||
been advised of the possibility of such damages.
|
||||
|
||||
#### 9. Accepting Warranty or Additional Liability
|
||||
|
||||
While redistributing the Work or Derivative Works thereof, You may choose to
|
||||
offer, and charge a fee for, acceptance of support, warranty, indemnity, or
|
||||
other liability obligations and/or rights consistent with this License. However,
|
||||
in accepting such obligations, You may act only on Your own behalf and on Your
|
||||
sole responsibility, not on behalf of any other Contributor, and only if You
|
||||
agree to indemnify, defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason of your
|
||||
accepting any such warranty or additional liability.
|
||||
|
||||
_END OF TERMS AND CONDITIONS_
|
||||
|
||||
### APPENDIX: How to apply the Apache License to your work
|
||||
|
||||
To apply the Apache License to your work, attach the following boilerplate
|
||||
notice, with the fields enclosed by brackets `[]` replaced with your own
|
||||
identifying information. (Don't include the brackets!) The text should be
|
||||
enclosed in the appropriate comment syntax for the file format. We also
|
||||
recommend that a file or class name and description of purpose be included on
|
||||
the same “printed page” as the copyright notice for easier identification within
|
||||
third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
382
node_modules/js2xmlparser/lib/js2xmlparser.js
generated
vendored
382
node_modules/js2xmlparser/lib/js2xmlparser.js
generated
vendored
@ -1,382 +0,0 @@
|
||||
/* jshint node:true */
|
||||
|
||||
/**
|
||||
* js2xmlparser
|
||||
* Copyright © 2012 Michael Kourlas and other 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 () {
|
||||
"use strict";
|
||||
|
||||
var xmlDeclaration = true;
|
||||
var xmlVersion = "1.0";
|
||||
var xmlEncoding = "UTF-8";
|
||||
var attributeString = "@";
|
||||
var aliasString = "=";
|
||||
var valueString = "#";
|
||||
var prettyPrinting = true;
|
||||
var indentString = "\t";
|
||||
var convertMap = {};
|
||||
var arrayMap = {};
|
||||
var useCDATA = false;
|
||||
|
||||
module.exports = function (root, data, options) {
|
||||
return toXML(init(root, data, options));
|
||||
};
|
||||
|
||||
// Initialization
|
||||
var init = function (root, data, options) {
|
||||
// Set option defaults
|
||||
setOptionDefaults();
|
||||
|
||||
// Error checking for root element
|
||||
if (typeof root !== "string") {
|
||||
throw new Error("root element must be a string");
|
||||
}
|
||||
else if (root === "") {
|
||||
throw new Error("root element cannot be empty");
|
||||
}
|
||||
|
||||
// Error checking and variable initialization for options
|
||||
if (typeof options === "object" && options !== null) {
|
||||
if ("declaration" in options) {
|
||||
if ("include" in options.declaration) {
|
||||
if (typeof options.declaration.include === "boolean") {
|
||||
xmlDeclaration = options.declaration.include;
|
||||
}
|
||||
else {
|
||||
throw new Error("declaration.include option must be a boolean");
|
||||
}
|
||||
}
|
||||
|
||||
if ("encoding" in options.declaration) {
|
||||
if (typeof options.declaration.encoding === "string" || options.declaration.encoding === null) {
|
||||
xmlEncoding = options.declaration.encoding;
|
||||
}
|
||||
else {
|
||||
throw new Error("declaration.encoding option must be a string or null");
|
||||
}
|
||||
}
|
||||
}
|
||||
if ("attributeString" in options) {
|
||||
if (typeof options.attributeString === "string") {
|
||||
attributeString = options.attributeString;
|
||||
}
|
||||
else {
|
||||
throw new Error("attributeString option must be a string");
|
||||
}
|
||||
}
|
||||
if ("valueString" in options) {
|
||||
if (typeof options.valueString === "string") {
|
||||
valueString = options.valueString;
|
||||
}
|
||||
else {
|
||||
throw new Error("valueString option must be a string");
|
||||
}
|
||||
}
|
||||
if ("aliasString" in options) {
|
||||
if (typeof options.aliasString === "string") {
|
||||
aliasString = options.aliasString;
|
||||
}
|
||||
else {
|
||||
throw new Error("aliasString option must be a string");
|
||||
}
|
||||
}
|
||||
if ("prettyPrinting" in options) {
|
||||
if ("enabled" in options.prettyPrinting) {
|
||||
if (typeof options.prettyPrinting.enabled === "boolean") {
|
||||
prettyPrinting = options.prettyPrinting.enabled;
|
||||
}
|
||||
else {
|
||||
throw new Error("prettyPrinting.enabled option must be a boolean");
|
||||
}
|
||||
}
|
||||
|
||||
if ("indentString" in options.prettyPrinting) {
|
||||
if (typeof options.prettyPrinting.indentString === "string") {
|
||||
indentString = options.prettyPrinting.indentString;
|
||||
}
|
||||
else {
|
||||
throw new Error("prettyPrinting.indentString option must be a string");
|
||||
}
|
||||
}
|
||||
}
|
||||
if ("convertMap" in options) {
|
||||
if (Object.prototype.toString.call(options.convertMap) === "[object Object]") {
|
||||
convertMap = options.convertMap;
|
||||
}
|
||||
else {
|
||||
throw new Error("convertMap option must be an object");
|
||||
}
|
||||
}
|
||||
if ("arrayMap" in options) {
|
||||
if (Object.prototype.toString.call(options.arrayMap) === "[object Object]") {
|
||||
arrayMap = options.arrayMap;
|
||||
}
|
||||
else {
|
||||
throw new Error("arrayMap option must be an object");
|
||||
}
|
||||
}
|
||||
if ("useCDATA" in options) {
|
||||
if (typeof options.useCDATA === "boolean") {
|
||||
useCDATA = options.useCDATA;
|
||||
}
|
||||
else {
|
||||
throw new Error("useCDATA option must be a boolean");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Error checking and variable initialization for data
|
||||
if (typeof data !== "string" && typeof data !== "object" && typeof data !== "number" &&
|
||||
typeof data !== "boolean" && data !== null) {
|
||||
throw new Error("data must be an object (excluding arrays) or a JSON string");
|
||||
}
|
||||
|
||||
if (data === null) {
|
||||
throw new Error("data must be an object (excluding arrays) or a JSON string");
|
||||
}
|
||||
|
||||
if (Object.prototype.toString.call(data) === "[object Array]" && !(arrayMap && arrayMap[root])) {
|
||||
throw new Error("data must be an object (excluding arrays) or a JSON string, unless an arrayMap option exists for root");
|
||||
}
|
||||
|
||||
if (typeof data === "string") {
|
||||
data = JSON.parse(data);
|
||||
}
|
||||
|
||||
var tempData = {};
|
||||
tempData[root] = data; // Add root element to object
|
||||
|
||||
return tempData;
|
||||
};
|
||||
|
||||
// Convert object to XML
|
||||
var toXML = function (object) {
|
||||
// Initialize arguments, if necessary
|
||||
var xml = arguments[1] || "";
|
||||
var level = arguments[2] || 0;
|
||||
|
||||
var i = null;
|
||||
var tempObject = {};
|
||||
|
||||
for (var property in object) {
|
||||
if (object.hasOwnProperty(property)) {
|
||||
// Element name cannot start with a number
|
||||
var elementName = property;
|
||||
if (/^\d/.test(property)) {
|
||||
elementName = "_" + property;
|
||||
}
|
||||
|
||||
// Skip alias string property
|
||||
if (elementName === aliasString) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// When alias string property is present, use as alias for element name
|
||||
if (Object.prototype.toString.call(object[property]) === "[object Object]" &&
|
||||
aliasString in object[property]) {
|
||||
elementName = object[property][aliasString];
|
||||
}
|
||||
|
||||
// Arrays
|
||||
if (Object.prototype.toString.call(object[property]) === "[object Array]") {
|
||||
// Wrap array with outer tag if arrayMap is used
|
||||
if (arrayMap[property]) {
|
||||
xml += addIndent("<" + elementName, level);
|
||||
xml += addBreak(">");
|
||||
}
|
||||
|
||||
// Create separate XML elements for each array element
|
||||
for (i = 0; i < object[property].length; i++) {
|
||||
tempObject = {};
|
||||
var newLevel = level;
|
||||
|
||||
// When arrayMap is used, use the arrayMap tag instead and increment level
|
||||
if (arrayMap[property]) {
|
||||
tempObject[arrayMap[property]] = object[property][i];
|
||||
newLevel = level + 1;
|
||||
} else {
|
||||
tempObject[property] = object[property][i];
|
||||
}
|
||||
|
||||
xml = toXML(tempObject, xml, newLevel);
|
||||
}
|
||||
|
||||
// Wrap array with outer tag if arrayMap is used
|
||||
if (arrayMap[property]) {
|
||||
xml += addBreak(addIndent("</" + elementName + ">", level));
|
||||
}
|
||||
}
|
||||
// JSON-type objects with properties
|
||||
else if (Object.prototype.toString.call(object[property]) === "[object Object]") {
|
||||
xml += addIndent("<" + elementName, level);
|
||||
|
||||
// Add attributes
|
||||
var lengthExcludingAttributes = Object.keys(object[property]).length;
|
||||
if (Object.prototype.toString.call(object[property][attributeString]) === "[object Object]") {
|
||||
lengthExcludingAttributes -= 1;
|
||||
for (var attribute in object[property][attributeString]) {
|
||||
if (object[property][attributeString].hasOwnProperty(attribute)) {
|
||||
xml += " " + attribute + "=\"" +
|
||||
toString(object[property][attributeString][attribute], true) + "\"";
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (typeof object[property][attributeString] !== "undefined") {
|
||||
// Fix for the case where an object contains a single property with the attribute string as its
|
||||
// name, but this property contains no attributes; in that case, lengthExcludingAttributes
|
||||
// should be set to zero to ensure that the object is considered an empty object for the
|
||||
// purposes of the following if statement.
|
||||
lengthExcludingAttributes -= 1;
|
||||
}
|
||||
|
||||
if (lengthExcludingAttributes === 0) { // Empty object
|
||||
xml += addBreak("/>");
|
||||
}
|
||||
else if ((lengthExcludingAttributes === 1 ||
|
||||
(lengthExcludingAttributes === 2 && aliasString in object[property])) &&
|
||||
valueString in object[property]) { // Value string only
|
||||
xml += addBreak(">" + toString(object[property][valueString], false) + "</" + elementName +
|
||||
">");
|
||||
}
|
||||
else { // Object with properties
|
||||
xml += addBreak(">");
|
||||
|
||||
// Create separate object for each property and pass to this function
|
||||
for (var subProperty in object[property]) {
|
||||
if (object[property].hasOwnProperty(subProperty) && subProperty !== attributeString &&
|
||||
subProperty !== valueString) {
|
||||
tempObject = {};
|
||||
tempObject[subProperty] = object[property][subProperty];
|
||||
|
||||
xml = toXML(tempObject, xml, level + 1);
|
||||
}
|
||||
}
|
||||
|
||||
xml += addBreak(addIndent("</" + elementName + ">", level));
|
||||
}
|
||||
}
|
||||
// Everything else
|
||||
else {
|
||||
xml += addBreak(addIndent("<" + elementName + ">" + toString(object[property], false) + "</" +
|
||||
elementName + ">", level));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Finalize XML at end of process
|
||||
if (level === 0) {
|
||||
// Strip trailing whitespace
|
||||
xml = xml.replace(/\s+$/g, "");
|
||||
|
||||
// Add XML declaration
|
||||
if (xmlDeclaration) {
|
||||
if (xmlEncoding === null) {
|
||||
xml = addBreak("<?xml version=\"" + xmlVersion + "\"?>") + xml;
|
||||
}
|
||||
else {
|
||||
xml = addBreak("<?xml version=\"" + xmlVersion + "\" encoding=\"" + xmlEncoding + "\"?>") + xml;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return xml;
|
||||
};
|
||||
|
||||
// Add indenting to data for pretty printing
|
||||
var addIndent = function (data, level) {
|
||||
if (prettyPrinting) {
|
||||
|
||||
var indent = "";
|
||||
for (var i = 0; i < level; i++) {
|
||||
indent += indentString;
|
||||
}
|
||||
data = indent + data;
|
||||
}
|
||||
|
||||
return data;
|
||||
};
|
||||
|
||||
// Add line break to data for pretty printing
|
||||
var addBreak = function (data) {
|
||||
return prettyPrinting ? data + "\n" : data;
|
||||
};
|
||||
|
||||
// Convert anything into a valid XML string representation
|
||||
var toString = function (data, isAttribute) {
|
||||
// Recursive function used to handle nested functions
|
||||
var functionHelper = function (data) {
|
||||
if (Object.prototype.toString.call(data) === "[object Function]") {
|
||||
return functionHelper(data());
|
||||
}
|
||||
else {
|
||||
return data;
|
||||
}
|
||||
};
|
||||
|
||||
// Convert map
|
||||
if (Object.prototype.toString.call(data) in convertMap) {
|
||||
data = convertMap[Object.prototype.toString.call(data)](data);
|
||||
}
|
||||
else if ("*" in convertMap) {
|
||||
data = convertMap["*"](data);
|
||||
}
|
||||
// Functions
|
||||
else if (Object.prototype.toString.call(data) === "[object Function]") {
|
||||
data = functionHelper(data());
|
||||
}
|
||||
// Empty objects
|
||||
else if (Object.prototype.toString.call(data) === "[object Object]" && Object.keys(data).length === 0) {
|
||||
data = "";
|
||||
}
|
||||
|
||||
// Cast data to string
|
||||
if (typeof data !== "string") {
|
||||
data = (data === null || typeof data === "undefined") ? "" : data.toString();
|
||||
}
|
||||
|
||||
// Output as CDATA instead of escaping if option set (and only if not an attribute value)
|
||||
if (useCDATA && !isAttribute) {
|
||||
data = "<![CDATA[" + data.replace(/]]>/gm, "]]]]><![CDATA[>") + "]]>";
|
||||
}
|
||||
else {
|
||||
// Escape illegal XML characters
|
||||
data = data.replace(/&/gm, "&")
|
||||
.replace(/</gm, "<")
|
||||
.replace(/>/gm, ">")
|
||||
.replace(/"/gm, """)
|
||||
.replace(/'/gm, "'");
|
||||
}
|
||||
|
||||
return data;
|
||||
};
|
||||
|
||||
// Revert options back to their default settings
|
||||
var setOptionDefaults = function () {
|
||||
useCDATA = false;
|
||||
convertMap = {};
|
||||
arrayMap = {};
|
||||
xmlDeclaration = true;
|
||||
xmlVersion = "1.0";
|
||||
xmlEncoding = "UTF-8";
|
||||
attributeString = "@";
|
||||
aliasString = "=";
|
||||
valueString = "#";
|
||||
prettyPrinting = true;
|
||||
indentString = "\t";
|
||||
};
|
||||
})();
|
||||
57
node_modules/js2xmlparser/package.json
generated
vendored
57
node_modules/js2xmlparser/package.json
generated
vendored
@ -1,57 +0,0 @@
|
||||
{
|
||||
"name": "js2xmlparser",
|
||||
"description": "Parses JavaScript objects into XML",
|
||||
"keywords": [
|
||||
"convert",
|
||||
"converter",
|
||||
"js",
|
||||
"json",
|
||||
"object",
|
||||
"objects",
|
||||
"parse",
|
||||
"parser",
|
||||
"xml"
|
||||
],
|
||||
"homepage": "http://www.kourlas.net",
|
||||
"version": "1.0.0",
|
||||
"author": {
|
||||
"name": "Michael Kourlas",
|
||||
"email": "michael@kourlas.net"
|
||||
},
|
||||
"main": "./lib/js2xmlparser.js",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/michaelkourlas/node-js2xmlparser.git"
|
||||
},
|
||||
"devDependencies": {
|
||||
"mocha": "*",
|
||||
"should": "*"
|
||||
},
|
||||
"license": "Apache-2.0",
|
||||
"gitHead": "f6b92bf15695e6436d4bf52393ba104ac46dab56",
|
||||
"bugs": {
|
||||
"url": "https://github.com/michaelkourlas/node-js2xmlparser/issues"
|
||||
},
|
||||
"_id": "js2xmlparser@1.0.0",
|
||||
"scripts": {},
|
||||
"_shasum": "5a170f2e8d6476ce45405e04823242513782fe30",
|
||||
"_from": "js2xmlparser@>=1.0.0 <1.1.0",
|
||||
"_npmVersion": "2.7.4",
|
||||
"_nodeVersion": "0.12.2",
|
||||
"_npmUser": {
|
||||
"name": "michaelkourlas",
|
||||
"email": "michael@kourlas.net"
|
||||
},
|
||||
"maintainers": [
|
||||
{
|
||||
"name": "michaelkourlas",
|
||||
"email": "michaelkourlas@gmail.com"
|
||||
}
|
||||
],
|
||||
"dist": {
|
||||
"shasum": "5a170f2e8d6476ce45405e04823242513782fe30",
|
||||
"tarball": "http://registry.npmjs.org/js2xmlparser/-/js2xmlparser-1.0.0.tgz"
|
||||
},
|
||||
"directories": {},
|
||||
"_resolved": "https://registry.npmjs.org/js2xmlparser/-/js2xmlparser-1.0.0.tgz"
|
||||
}
|
||||
19
node_modules/marked/LICENSE
generated
vendored
19
node_modules/marked/LICENSE
generated
vendored
@ -1,19 +0,0 @@
|
||||
Copyright (c) 2011-2014, Christopher Jeffrey (https://github.com/chjj/)
|
||||
|
||||
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.
|
||||
1
node_modules/marked/index.js
generated
vendored
1
node_modules/marked/index.js
generated
vendored
@ -1 +0,0 @@
|
||||
module.exports = require('./lib/marked');
|
||||
1285
node_modules/marked/lib/marked.js
generated
vendored
1285
node_modules/marked/lib/marked.js
generated
vendored
File diff suppressed because it is too large
Load Diff
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user