1 line
10 KiB
JSON
1 line
10 KiB
JSON
|
{"ast":null,"code":"'use strict'; //This file contains the ES6 extensions to the core Promises/A+ API\n\nvar Promise = require('./core.js');\n\nmodule.exports = Promise;\n/* Static Functions */\n\nvar TRUE = valuePromise(true);\nvar FALSE = valuePromise(false);\nvar NULL = valuePromise(null);\nvar UNDEFINED = valuePromise(undefined);\nvar ZERO = valuePromise(0);\nvar EMPTYSTRING = valuePromise('');\n\nfunction valuePromise(value) {\n var p = new Promise(Promise._0);\n p._V = 1;\n p._W = value;\n return p;\n}\n\nPromise.resolve = function (value) {\n if (value instanceof Promise) return value;\n if (value === null) return NULL;\n if (value === undefined) return UNDEFINED;\n if (value === true) return TRUE;\n if (value === false) return FALSE;\n if (value === 0) return ZERO;\n if (value === '') return EMPTYSTRING;\n\n if (typeof value === 'object' || typeof value === 'function') {\n try {\n var then = value.then;\n\n if (typeof then === 'function') {\n return new Promise(then.bind(value));\n }\n } catch (ex) {\n return new Promise(function (resolve, reject) {\n reject(ex);\n });\n }\n }\n\n return valuePromise(value);\n};\n\nvar _iterableToArray = function iterableToArray(iterable) {\n if (typeof Array.from === 'function') {\n // ES2015+, iterables exist\n _iterableToArray = Array.from;\n return Array.from(iterable);\n } // ES5, only arrays and array-likes exist\n\n\n _iterableToArray = function iterableToArray(x) {\n return Array.prototype.slice.call(x);\n };\n\n return Array.prototype.slice.call(iterable);\n};\n\nPromise.all = function (arr) {\n var args = _iterableToArray(arr);\n\n return new Promise(function (resolve, reject) {\n if (args.length === 0) return resolve([]);\n var remaining = args.length;\n\n function res(i, val) {\n if (val && (typeof val === 'object' || typeof val === 'function')) {\n if (val instanceof Promise && val.then === Promise.prototype.then) {\n while (val._V === 3) {\n val = val._W;\n }\n\n if (val._V === 1) return res(i, val._W);\n if (val._V === 2) reject(val._W);\n val.then(function (val) {\n res(i, val);\n }, reject);\n return;\n } else {\n var then = val.then;\n\n if (typeof then === 'function') {\n var p = new Promise(then.bind(val));\n p.then(function (val) {\n res(i, val);\n }, reject);\n return;\n }\n }\n }\n\n args[i] = val;\n\n if (--remaining === 0) {\n resolve(args);\n }\n }\n\n for (var i = 0; i < args.length; i++) {\n res(i, args[i]);\n }\n });\n};\n\nPromise.reject = function (value) {\n return new Promise(function (resolve, reject) {\n reject(value);\n });\n};\n\nPromise.race = function (values) {\n return new Promise(function (resolve, reject) {\n _iterableToArray(values).forEach(function (value) {\n Promise.resolve(value).then(resolve, reject);\n });\n });\n};\n/* Prototype Methods */\n\n\nPromise.prototype['catch'] = function (onRejected) {\n return this.then(null, onRejected);\n};","map":{"version":3,"names":["Promise","require","module","exports","TRUE","valuePromise","FALSE","NULL","UNDEFINED","undefined","ZERO","EMPTYSTRING","value","p","_0","_V","_W","resolve","then","bind","ex","reject","iterableToArray","iterable","Array","from","x","prototype","slice","call","all","arr","args","length","remaining","res","i","val","race","values","forEach","onRejected"],"sources":["/Users/paolasanchez/Desktop/Pry4/Katoikia/katoikia-app/web-ui/sakai-react/node_modules/promise/lib/es6-extensions.js"],"sourcesContent":["'use strict';\n\n//This file contains the ES6 extensions to the core Promises/A+ API\n\nvar Promise = require('./core.js');\n\nmodule.exports = Promise;\n\n/* Static Functions */\n\nvar TRUE = valuePromise(true);\nvar FALSE = valuePromise(false);\nvar NULL = valuePromise(null);\nvar UNDEFINED = valuePromise(undefined);\nvar ZERO =
|