X7ROOT File Manager
Current Path:
/lib/node_modules/npm/node_modules/bluebird/js/release
lib
/
node_modules
/
npm
/
node_modules
/
bluebird
/
js
/
release
/
??
..
??
any.js
(421 B)
??
assert.js
(1.61 KB)
??
async.js
(4.05 KB)
??
bind.js
(1.92 KB)
??
bluebird.js
(291 B)
??
call_get.js
(4.25 KB)
??
cancel.js
(3.62 KB)
??
catch_filter.js
(1.39 KB)
??
context.js
(2.33 KB)
??
debuggability.js
(29.63 KB)
??
direct_resolve.js
(1.36 KB)
??
each.js
(789 B)
??
errors.js
(3.63 KB)
??
es5.js
(1.93 KB)
??
filter.js
(314 B)
??
finally.js
(4.5 KB)
??
generators.js
(7.58 KB)
??
join.js
(8.03 KB)
??
map.js
(5.25 KB)
??
method.js
(1.73 KB)
??
nodeback.js
(1.52 KB)
??
nodeify.js
(1.61 KB)
??
promise.js
(25.59 KB)
??
promise_array.js
(5.08 KB)
??
promisify.js
(11.9 KB)
??
props.js
(3.04 KB)
??
queue.js
(1.83 KB)
??
race.js
(1.22 KB)
??
reduce.js
(5.01 KB)
??
schedule.js
(2.1 KB)
??
settle.js
(1.23 KB)
??
some.js
(3.87 KB)
??
synchronous_inspection.js
(2.75 KB)
??
thenables.js
(2.08 KB)
??
timers.js
(2.34 KB)
??
using.js
(7.35 KB)
??
util.js
(10.28 KB)
Editing: map.js
"use strict"; module.exports = function(Promise, PromiseArray, apiRejection, tryConvertToPromise, INTERNAL, debug) { var getDomain = Promise._getDomain; var util = require("./util"); var tryCatch = util.tryCatch; var errorObj = util.errorObj; var async = Promise._async; function MappingPromiseArray(promises, fn, limit, _filter) { this.constructor$(promises); this._promise._captureStackTrace(); var domain = getDomain(); this._callback = domain === null ? fn : util.domainBind(domain, fn); this._preservedValues = _filter === INTERNAL ? new Array(this.length()) : null; this._limit = limit; this._inFlight = 0; this._queue = []; async.invoke(this._asyncInit, this, undefined); } util.inherits(MappingPromiseArray, PromiseArray); MappingPromiseArray.prototype._asyncInit = function() { 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 (index < 0) { index = (index * -1) - 1; values[index] = value; if (limit >= 1) { this._inFlight--; this._drainQueue(); if (this._isResolved()) return true; } } else { if (limit >= 1 && this._inFlight >= limit) { values[index] = value; this._queue.push(index); return false; } if (preservedValues !== null) preservedValues[index] = value; var promise = this._promise; var callback = this._callback; var receiver = promise._boundValue(); promise._pushContext(); var ret = tryCatch(callback).call(receiver, value, index, length); var promiseCreated = promise._popContext(); debug.checkForgottenReturns( ret, promiseCreated, preservedValues !== null ? "Promise.filter" : "Promise.map", promise ); if (ret === errorObj) { this._reject(ret.e); return true; } var maybePromise = tryConvertToPromise(ret, this._promise); if (maybePromise instanceof Promise) { maybePromise = maybePromise._target(); var bitField = maybePromise._bitField; ; if (((bitField & 50397184) === 0)) { if (limit >= 1) this._inFlight++; values[index] = maybePromise; maybePromise._proxy(this, (index + 1) * -1); return false; } else if (((bitField & 33554432) !== 0)) { ret = maybePromise._value(); } else if (((bitField & 16777216) !== 0)) { this._reject(maybePromise._reason()); return true; } else { this._cancel(); return true; } } values[index] = ret; } var totalResolved = ++this._totalResolved; if (totalResolved >= length) { if (preservedValues !== null) { this._filter(values, preservedValues); } else { this._resolve(values); } return true; } return false; }; 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) { if (typeof fn !== "function") { return apiRejection("expecting a function but got " + util.classString(fn)); } var limit = 0; if (options !== undefined) { if (typeof options === "object" && options !== null) { if (typeof options.concurrency !== "number") { return Promise.reject( new TypeError("'concurrency' must be a number but it is " + util.classString(options.concurrency))); } limit = options.concurrency; } else { return Promise.reject(new TypeError( "options argument must be an object but it is " + util.classString(options))); } } limit = typeof limit === "number" && isFinite(limit) && limit >= 1 ? limit : 0; return new MappingPromiseArray(promises, fn, limit, _filter).promise(); } Promise.prototype.map = function (fn, options) { return map(this, fn, options, null); }; Promise.map = function (promises, fn, options, _filter) { return map(promises, fn, options, _filter); }; };
Upload File
Create Folder