polyfills.Promise.meta.json Maven / Gradle / Ivy
The newest version!
{"aliases":["modernizr:promises","caniuse:promises","blissfuljs","default-3.4","default-3.5","default-3.6","default","es6"],"browsers":{"android":"* - 4.4","bb":"* - 10","chrome":"* - 31","firefox":"6 - 28","ie":"8 - 12","ie_mob":"*","ios_saf":"* - 7.1","op_mini":"*","opera":"* - 19","safari":"* - 7","firefox_mob":"6 - 28"},"dependencies":["setImmediate","Array.isArray","Event"],"notes":["In IE8, the `catch` & `finally` method cannot be invoked directly since they are reserved words. Instead, use `[\"catch\"]` and `[\"finally\"]` if intend to run your code in IE8"],"license":"MIT","docs":"https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Promise","repo":"https://github.com/ysmood/yaku","install":{"module":"yaku","paths":["dist/yaku.browser.global.min.js"]},"detectSource":"'Promise' in this","testSource":"","baseDir":"Promise","hasTests":true,"testsSource":"/* eslint-env mocha, browser*/\n/* global proclaim, it */\n\nit('has correct instance', function () {\n\tproclaim.isInstanceOf(Promise, Function);\n});\n\nit('has correct argument length', function () {\n\tproclaim.equal(Promise.length, 1);\n});\n\ndescribe('Section 2.1.2.1: When fulfilled, a promise: must not transition to any other state.', function () {\n\tvar promise, deferred;\n\n\tbeforeEach(function () {\n\t\tdeferred = {};\n\n\t\tpromise = new Promise(function () {\n\t\t\tdeferred.resolve = arguments[0];\n\t\t\tdeferred.reject = arguments[1];\n\t\t});\n\t});\n\n\tit('trying to fulfill immediately then reject immediately', function (done) {\n\t\tpromise.then(function onFulfilled() {\n\t\t\tdeferred.value = true;\n\t\t}, function onRejected() {\n\t\t\tdeferred.value = false;\n\t\t});\n\n\t\tdeferred.resolve();\n\t\tdeferred.reject();\n\n\t\tsetTimeout(function () {\n\t\t\tproclaim.equal(deferred.value, true);\n\n\t\t\tdone();\n\t\t}, 50);\n\t});\n\n\tit('trying to fulfill immediately then reject delayed', function (done) {\n\t\tpromise.then(function onFulfilled() {\n\t\t\tdeferred.value = true;\n\t\t}, function onRejected() {\n\t\t\tdeferred.value = false;\n\t\t});\n\n\t\tdeferred.resolve();\n\n\t\tsetTimeout(function () {\n\t\t\tdeferred.reject();\n\n\t\t\tsetTimeout(function () {\n\t\t\t\tproclaim.equal(deferred.value, true);\n\n\t\t\t\tdone();\n\t\t\t}, 50);\n\t\t}, 50);\n\t});\n\n\tit('trying to fulfill delayed then reject delayed', function (done) {\n\t\tpromise.then(function () {\n\t\t\tdeferred.value = true;\n\t\t}, function () {\n\t\t\tdeferred.value = false;\n\t\t});\n\n\t\tsetTimeout(function () {\n\t\t\tdeferred.resolve();\n\n\t\t\tsetTimeout(function () {\n\t\t\t\tdeferred.reject();\n\n\t\t\t\tsetTimeout(function () {\n\t\t\t\t\tproclaim.equal(deferred.value, true);\n\n\t\t\t\t\tdone();\n\t\t\t\t}, 50);\n\t\t\t});\n\t\t}, 50);\n\t});\n});\n\ndescribe('Section 2.1.3.1: When rejected, a promise: must not transition to any other state.', function () {\n\tvar promise, deferred;\n\n\tbeforeEach(function () {\n\t\tdeferred = {};\n\n\t\tpromise = new Promise(function () {\n\t\t\tdeferred.resolve = arguments[0];\n\t\t\tdeferred.reject = arguments[1];\n\t\t});\n\t});\n\n\tit('trying to reject immediately then resolve immediately', function (done) {\n\t\tpromise.then(function onFulfilled() {\n\t\t\tdeferred.value = true;\n\t\t}, function onRejected() {\n\t\t\tdeferred.value = false;\n\t\t});\n\n\t\tdeferred.reject();\n\t\tdeferred.resolve();\n\n\t\tsetTimeout(function () {\n\t\t\tproclaim.equal(deferred.value, false);\n\n\t\t\tdone();\n\t\t}, 50);\n\t});\n\n\tit('trying to reject immediately then resolve delayed', function (done) {\n\t\tpromise.then(function onFulfilled() {\n\t\t\tdeferred.value = true;\n\t\t}, function onRejected() {\n\t\t\tdeferred.value = false;\n\t\t});\n\n\t\tdeferred.reject();\n\n\t\tsetTimeout(function () {\n\t\t\tdeferred.resolve();\n\n\t\t\tsetTimeout(function () {\n\t\t\t\tproclaim.equal(deferred.value, false);\n\n\t\t\t\tdone();\n\t\t\t}, 50);\n\t\t}, 50);\n\t});\n\n\tit('trying to reject delayed then resolve delayed', function (done) {\n\t\tpromise.then(function () {\n\t\t\tdeferred.value = true;\n\t\t}, function () {\n\t\t\tdeferred.value = false;\n\t\t});\n\n\t\tsetTimeout(function () {\n\t\t\tdeferred.reject();\n\n\t\t\tsetTimeout(function () {\n\t\t\t\tdeferred.resolve();\n\n\t\t\t\tsetTimeout(function () {\n\t\t\t\t\tproclaim.equal(deferred.value, false);\n\n\t\t\t\t\tdone();\n\t\t\t\t}, 50);\n\t\t\t});\n\t\t}, 50);\n\t});\n});\n\ndescribe('2.2.1: Both `onFulfilled` and `onRejected` are optional arguments.', function () {\n\tvar promise;\n\n\tdescribe('2.2.1.1: If `onFulfilled` is not a function, it must be ignored.', function () {\n\t\tdescribe('applied to a directly-rejected promise', function () {\n\t\t\tfunction testNonFunction(nonFunction, stringRepresentation) {\n\t\t\t\tspecify('`onFulfilled` is ' + stringRepresentation, function (done) {\n\t\t\t\t\tpromise.then(nonFunction, function () {\n\t\t\t\t\t\tdone();\n\t\t\t\t\t});\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tvar resolve, reject;\n\n\t\t\tpromise = new Promise(function (oresolve, oreject) {\n\t\t\t\tresolve = oresolve;\n\t\t\t\treject = oreject;\n\t\t\t});\n\n\t\t\treject();\n\n\t\t\ttestNonFunction(undefined, '`undefined`');\n\t\t\ttestNonFunction(null, '`null`');\n\t\t\ttestNonFunction(false, '`false`');\n\t\t\ttestNonFunction(5, '`5`');\n\t\t\ttestNonFunction({}, 'an object');\n\t\t});\n\n\t\tdescribe('applied to a promise rejected and then chained off of', function () {\n\t\t\tfunction testNonFunction(nonFunction, stringRepresentation) {\n\t\t\t\tspecify('`onFulfilled` is ' + stringRepresentation, function (done) {\n\t\t\t\t\tpromise.then(function () {}, undefined).then(nonFunction, function () {\n\t\t\t\t\t\tdone();\n\t\t\t\t\t});\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tpromise = new Promise(function (resolve, reject) {\n\t\t\t\treject();\n\t\t\t});\n\n\t\t\ttestNonFunction(undefined, '`undefined`');\n\t\t\ttestNonFunction(null, '`null`');\n\t\t\ttestNonFunction(false, '`false`');\n\t\t\ttestNonFunction(5, '`5`');\n\t\t\ttestNonFunction({}, 'an object');\n\t\t});\n\t});\n});\n\nit('should resolve inside then (test case from @matthew-andrews)', function(done) {\n\tPromise.resolve().then(function() {\n\t\treturn Promise.resolve('[true]').then(JSON.parse);\n\t}).then(function(a) {\n\t\tproclaim.equal(a[0], true);\n\t\tdone();\n\t});\n})\n\nit('should resolve Promise.all when all promises resolve', function(done) {\n\tPromise.all([\n\t\tPromise.resolve(3),\n\t\tPromise.resolve(5)\n\t]).then(function(results) {\n\t\tproclaim.deepEqual(results, [3,5]);\n\t\tdone();\n\t})['catch'](function(e) {\n\t\tdone(e);\n\t});\n});"}