{"id":26506278,"url":"https://github.com/anonyco/spromisemespeedjs","last_synced_at":"2025-08-01T17:38:45.138Z","repository":{"id":43171126,"uuid":"119903687","full_name":"anonyco/SPromiseMeSpeedJS","owner":"anonyco","description":"The JavaScript library that promises you the fastest ES6 promises","archived":false,"fork":false,"pushed_at":"2020-06-19T17:39:17.000Z","size":247,"stargazers_count":12,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-07-01T05:47:15.222Z","etag":null,"topics":["bluebird","bluebird-promise","easy-to-use","es6-promise","javascript","javascript-library","js","polyfill","promise","promise-api","promise-chain","promise-library","promise-queue","promiserejectionevent","promises","promises-aplus","promisify","vanilla-javascript","vanilla-js","vanillajs"],"latest_commit_sha":null,"homepage":"https://anonyco.github.io/SPromiseMeSpeedJS/SPromiseMeSpeed.test.html","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"cc0-1.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/anonyco.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-02-01T22:54:46.000Z","updated_at":"2023-04-23T15:36:46.000Z","dependencies_parsed_at":"2022-08-30T11:11:46.223Z","dependency_job_id":null,"html_url":"https://github.com/anonyco/SPromiseMeSpeedJS","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/anonyco/SPromiseMeSpeedJS","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anonyco%2FSPromiseMeSpeedJS","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anonyco%2FSPromiseMeSpeedJS/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anonyco%2FSPromiseMeSpeedJS/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anonyco%2FSPromiseMeSpeedJS/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/anonyco","download_url":"https://codeload.github.com/anonyco/SPromiseMeSpeedJS/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anonyco%2FSPromiseMeSpeedJS/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268269336,"owners_count":24223230,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-01T02:00:08.611Z","response_time":67,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bluebird","bluebird-promise","easy-to-use","es6-promise","javascript","javascript-library","js","polyfill","promise","promise-api","promise-chain","promise-library","promise-queue","promiserejectionevent","promises","promises-aplus","promisify","vanilla-javascript","vanilla-js","vanillajs"],"created_at":"2025-03-20T22:26:36.431Z","updated_at":"2025-08-01T17:38:45.105Z","avatar_url":"https://github.com/anonyco.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n[![npm version](http://img.shields.io/npm/v/spromisemespeed.svg?label=version)](https://npmjs.org/package/spromisemespeed \"View this project on npm\")\n[![GitHub stars](https://img.shields.io/github/stars/anonyco/SPromiseMeSpeedJS.svg?style=social)](https://github.com/anonyco/SPromiseMeSpeedJS/stargazers \"View others who have stared this repository\")\n[![GitHub file size in bytes](https://img.shields.io/github/size/anonyco/SPromiseMeSpeedJS/dist/SPromiseMeSpeed.min.js.svg?label=without%20gzip)](https://github.com/anonyco/SPromiseMeSpeedJS/blob/master/dist/SPromiseMeSpeed.min.js \"File without gzip\")\n[![GitHub file size in bytes](https://img.shields.io/github/size/anonyco/SPromiseMeSpeedJS/dist/SPromiseMeSpeed.min.js.gz.svg?label=gzip%20applied)](https://github.com/anonyco/SPromiseMeSpeedJS/blob/master/dist/SPromiseMeSpeed.min.js.gz \"Gzipped file\")\n[![npm bundle size (version)](https://img.shields.io/bundlephobia/min/spromisemespeed/latest.svg?color=maroon\u0026label=NPM%20bundle%20size)](https://npmjs.org/package/spromisemespeed \"View this project on npm\")\u003c!--[![Issues](http://img.shields.io/github/issues/anonyco/SPromiseMeSpeedJS.svg)]( https://github.com/anonyco/SPromiseMeSpeedJS/issues )--\u003e\n[![CC0 license](https://licensebuttons.net/p/zero/1.0/88x31.png)](https://creativecommons.org/share-your-work/public-domain/cc0/ \"This project's liscence\")\n[![npm downloads](https://img.shields.io/npm/dt/spromisemespeed.svg)](https://npmjs.org/package/spromisemespeed \"View this project on npm\")\n\n\n\n# SPromiseMeSpeed\nSPromiseMeSpeed is currently the fastest [ES6 Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) javascript library and polyfill, *promising* a speedy implementation that is ~1-59x faster than Chrome's native promises and ~2-548x faster than Bluebird's promises (five hundread and fourty eight is not a typo). The purpose of SPromiseMeSpeed is to provide a speedy alternative to ES6 promises until browsers implement faster native promises. If all you need is a way to defer the stack level so you don't get the dreaded \"Maximum Stack Call Exceeded\" error, then consider using my other library, [DeferStackJS](https://github.com/anonyco/DeferStackJS/), for slightly better performance.\n\n# Quick Start\n\nTo use, simply drop the following snippet of HTML code into your `\u003chead\u003e` before all of the scripts that use SPromiseMeSpeed.\n```HTML\n\u003cscript src=\"https://dl.dropboxusercontent.com/s/llt6sv7y2yurn2v/SPromiseMeSpeedDEBUG.min.js?dl=0\"\u003e\u003c/script\u003e\n```\nOr, alternatively, if you want faster page loading, add a defer to every script to let the browser know that you don't call evil `document.write` inside your script.\u003cbr /\u003e\u003cbr /\u003e\n*Before:*\n```HTML\n\u003c!doctype HTML\u003e\n\u003chtml\u003e\u003chead\u003e\n\u003cscript src=\"https://dl.dropboxusercontent.com/s/llt6sv7y2yurn2v/SPromiseMeSpeedDEBUG.min.js?dl=0\"\u003e\u003c/script\u003e\n\u003cscript src=\"/path/to/my/script.js\"\u003e\u003c/script\u003e\n\u003c/head\u003e\u003cbody\u003e\n    ...\n\u003c/body\u003e\u003c/html\u003e\n```\n*After*\n```HTML\n\u003c!doctype HTML\u003e\n\u003chtml\u003e\u003chead\u003e\n\u003cscript src=\"https://dl.dropboxusercontent.com/s/llt6sv7y2yurn2v/SPromiseMeSpeedDEBUG.min.js?dl=0\" defer=\"\"\u003e\u003c/script\u003e\n\u003cscript src=\"/path/to/my/script.js\" defer=\"\"\u003e\u003c/script\u003e\n\u003c/head\u003e\u003cbody\u003e\n    ...\n\u003c/body\u003e\u003c/html\u003e\n```\n\n## RequireJS and NodeJS Setup\n\nFor dropping into either RequireJS or NodeJS, please use [the `spromisemespeed` npm repository](https://npmjs.org/package/spromisemespeed), [this minified file](https://github.com/anonyco/SPromiseMeSpeed/blob/master/dist/SPromiseMeSpeed.min.js), or the corresponding [source code file](https://github.com/anonyco/SPromiseMeSpeed/blob/master/src/SPromiseMeSpeed.src.js). To install via npm, use the following code.\n\n```Bash\nnpm install spromisemespeed\n```\n\nAfter installing via npm, one can use `require(\"spromisemespeed\")`. Alternatively, one can drop the *SPromiseMeSpeed.min.js* file into the same directory as their NodeJS script and do `require(\"./SPromiseMeSpeed.min.js\")`. Both methods are functionally equivalent. Otherwise, if one do not know how to use the command line, save the script corresponding to one's operating system to the directory where the nodejs script will run and use the file manager to run the script (on Windows, it's a double-click).\n\n\n* fastestsmallesttextencoderdecoder\n    - Microsoft Windows batch: [install-FastestSmallestTextEncoderDecoder-windows.bat](https://raw.githubusercontent.com/anonyco/SPromiseMeSpeedJS/master/dist/install-SPromiseMeSpeed-windows.bat)\n    - Bash for Apple MacOS and Linux (e.x. Ubuntu): [install-FastestSmallestTextEncoderDecoder-unix.sh](https://raw.githubusercontent.com/anonyco/SPromiseMeSpeedJS/master/dist/install-SPromiseMeSpeed-unix.sh)\n* fastestsmallesttextencoderdecoder-encodeinto\n    - Microsoft Windows batch: [install-FastestSmallestTextEncoderDecoder-encodeInto.bat](https://raw.githubusercontent.com/anonyco/SPromiseMeSpeedJS/master/dist/dist/install-SPromiseMeSpeed-fast.bat)\n    - Bash for Apple MacOS and Linux (e.x. Ubuntu): [install-FastestSmallestTextEncoderDecoder-encodeInto.sh](https://raw.githubusercontent.com/anonyco/SPromiseMeSpeedJS/master/dist/dist/install-SPromiseMeSpeed-fast.sh)\n\n\n# API: Differences From Native Promises\nSPromiseMeSpeed gives you one and only one new global on the window object: `window.SPromise`. `window.SPromise` is the exact same as the native `window.Promise` as documented by MDN EXCEPT:\n\n1. It is called without the `new` operator.\n1. All callbacks are invoked immediately after the promise is resolved without waiting until the next tick.\n1. It has a `window.SPromise.isPromise` method you can use to determine if something is a promise.\n1. It is a lot faster than native Chromium promises, even with (surprise, surprise!) `await`.\n1. It skims and cuts corners to boost performance by reusing the same reference passed to callbacks as the source.\n\nExample code snippets:\n```HTML\n\u003c!DOCTYPE HTML\u003e\n\u003chtml\u003e\u003chead\u003e\n\u003ctitle\u003eSPromise Test Example\u003c/title\u003e\n\u003cscript src=\"https://dl.dropboxusercontent.com/s/llt6sv7y2yurn2v/SPromiseMeSpeedDEBUG.min.js?dl=0\" defer=\"\"\u003e\u003c/script\u003e\n\u003c/head\u003e\u003cbody\u003e\n\u003cscript\u003e\naddEventListener(\"load\", function(){\n  \"use strict\";\n  var SPromise = window.SPromise;\n  SPromise.race([\n    SPromise(function(accept){\n       setTimeout(function(){\n         accept(\"SPromise wins this mockup that doesn't actually have any benchmarking practicality\");\n       }, 250);\n    }),\n    new Promise(function(accept){ // you can even intermingle native promises with SPromise\n      setTimeout(function(accept){\n        accept(\"Native Promise wins this mockup that doesn't actually have any benchmarking practicality\")\n      }, 250)\n    })\n  ]).then(function(winner){\n    document.body.insertAdjacentHTML(\"beforeend\", \"\u003cdiv\u003eWinner:\" + winner + \"\u003c/div\u003e\");\n  });\n  (async function(){\n    document.body.insertAdjacentHTML(\"beforeend\", \"\u003cdiv\u003e\" + await SPromise(function(accept, reject){\n      // Don't ask me why synthetic promises are allowed to work with await. I myself am still\n      // confused, but hey: it works and SPromise even somehow shockingly makes them faster!\n      setTimeout(function(){\n        accept(\"Hello from await!\")\n      }, 750);\n    }) + \"\u003c/div\u003e\");\n  })();\n})();\n\u003c/script\u003e\n\u003c/body\u003e\u003c/html\u003e\n```\n\n\n# SPromiseMeSpeed.min.js VS SPromiseMeSpeedDEBUG.min.js\nThe main difference between the two versions is that SPromiseMeSpeedDEBUG is intended for development. It adds many extra type checks and notifies you when the wrong type of object is passed to the SPromise API. For some of the errors, it even gives a suggestion on how to fix them. However, these checks come at a cost: performance. If you have already written your code well enough to not need these checks, then use SPromiseMeSpeed.min.js for even better performance. SPromiseMeSpeed.js will run blind untill it gets done running or it hits a wall and crashes. For example, if you pass something that is not a function to `window.SPromise` from SPromiseMeSpeedDEBUG.min.js, then it will print a pretty error message saying you passed a wrong type to the function. But with SPromiseMeSpeed.min.js, the console will say something along the lines of 'cannot call null or undefined' or 'null or undefined is not a function.' To use SPromiseMeSpeed without the DEBUG, insert the following alternative code into your `\u003chead\u003e`:\n\n```HTML\n\u003cscript src=\"https://dl.dropboxusercontent.com/s/i8om2fcz5izdeoj/SPromiseMeSpeed.min.js?dl=0\"\u003e\u003c/script\u003e\n```\n\n\n## RequireJS and ES Module API Documentation\n\nFor NodeJS, calling `require(\"SPromiseMeSpeed.min.js\")` yields the function `SPromise`.\n\n```Javascript\nmodule.exports = function(handle) {/*...*/};\n```\n\nAs for example snippets, observe the way to require modules below.\n\n```Javascript\n    const SPromise = require(\"spromisemespeed\");\n```\n\nOr, one can use the new and shiny [ES6 module importation](https://developer.mozilla.org/en-US/docs/web/javascript/reference/statements/import) statements.\n\n\n```Javascript\n    // Variation 1\n    import { SPromise } from \"spromisemespeed\";\n```\n\n```Javascript\n    // Variation 2\n    import * as SPromiseModule from \"spromisemespeed\";\n    const SPromise = SPromiseModule.SPromise;\n```\n\n\n## npm Project\nThis DEBUG build of this project can be found on [npm here at this link](https://npmjs.org/package/spromisemespeed). The faster unchecked build can be found on [npm here at this other link](https://npmjs.org/package/spromisemespeed-fast).\n\n\n# Benchmarks\nIf you are a sensible guy like me, then you shouldn't take my word for the speed of SPromiseMeSpeed. Rather, take the word of these benchmarks:\n\n### Casual Promising\nBenchmark Code (executed in the console at https://cdnjs.cloudflare.com/ajax/libs/bluebird/2.11.0/bluebird.min.js)\n```Javascript\n(async function(requestIdleCallback, console, performance){\n\t\"use strict\";\n\tvar resStr = \"\";\n\tvar nativePromise = window.Promise, idleOptions = {timeout: 11};\n\tfunction test(str, f){\n\t\treturn new nativePromise(function(acc){\n            var tests=[], tmp=0, SPromise = window.SPromise;\n            var cycleCount=5, intV=requestIdleCallback(function theeFunc(){\n                \"use strict\";\n                if (--cycleCount \u003c 0) {\n                    var res = tests.reduce((a, b) =\u003e a + b) / tests.length;\n                    resStr += \"\\n\" + str + res + \"ms\";\n\t\t\t\t\tacc();\n                    return;\n                }\n                var k = performance.now(), i = 0, Len = 6;\n                (function test(v){\n                    f(function(k){\n                        k(v+(((v\u003c\u003c2)%11)|0)|0);\n                    }).then(function(v){\n\t\t\t\t\t\ti = i + 1|0;\n                        if (i \u003c Len) {\n                            test(((v|0)%7)|0);\n                        } else {\n                            tmp = tmp + (v|0)|0;\n                            tests.push((performance.now() - k)/Len);\n                        }\n                    });\n                })(Math.random()*40|0);\n                requestIdleCallback(theeFunc, idleOptions);\n            }, idleOptions);\n        });\n    }\n\n\tawait test(\"NativeR1:   \", function(x){return new nativePromise(x)});\n\tawait test(\"NativeR2:   \", function(x){return new nativePromise(x)});\n\tawait test(\"NativeR3:   \", function(x){return new nativePromise(x)});\n\tawait test(\"NativeR4:   \", function(x){return new nativePromise(x)});\n\tawait (new nativePromise(_=\u003erequestIdleCallback(_))); // to allow the CPU to take a break\n\t(new Function(document.body.innerText))();\n\tvar bbPromise = window.Promise;\n\tawait test(\"BluebirdR1: \", function(x){return new bbPromise(x)});\n\tawait test(\"BluebirdR2: \", function(x){return new bbPromise(x)});\n\tawait test(\"BluebirdR3: \", function(x){return new bbPromise(x)});\n\tawait test(\"BluebirdR4: \", function(x){return new bbPromise(x)});\n\tawait (new nativePromise(_=\u003erequestIdleCallback(_))); // to allow the CPU to take a break\n\twindow.Promise = nativePromise;\n\tvar SPromise = window.SPromise;\n\tawait test(\"SPromiseR1: \", function(x){return SPromise(x)});\n\tawait test(\"SPromiseR2: \", function(x){return SPromise(x)});\n\tawait test(\"SPromiseR3: \", function(x){return SPromise(x)});\n\tawait test(\"SPromiseR4: \", function(x){return SPromise(x)});\n\tconsole.log(resStr);\n})(requestIdleCallback, console, performance);\n```\nConsole output (lower numbers = lower promise delay = better):\n```\nNativeR1:   0.04416666730927924ms\nNativeR2:   0.018666667165234685ms\nNativeR3:   0.026166668006529413ms\nNativeR4:   0.024499996410061918ms\nBluebirdR1: 0.27599999836335576ms\nBluebirdR2: 0.22883333343391615ms\nBluebirdR3: 0.22850000144292912ms\nBluebirdR4: 0.2271666657179594ms\nSPromiseR1: 0.006999998974303404ms\nSPromiseR2: 0.006166667056580384ms\nSPromiseR3: 0.005999997180576125ms\nSPromiseR4: 0.006833329098299146ms\n```\n\n### Synchronous Hellhole of Death Promising\nBenchmark code (executed in the console at https://cdnjs.cloudflare.com/ajax/libs/bluebird/2.11.0/bluebird.min.js):\n```Javascirpt\n(async function(requestIdleCallback, console, performance){\n\t\"use strict\";\n\tvar resStr = \"\";\n\tvar nativePromise = window.Promise, idleOptions = {timeout: 11};\n\tfunction test(str, f){\n\t\treturn new nativePromise(function(acc){\n            var tests=[], tmp=0, SPromise = window.SPromise;\n            var cycleCount=5, intV=requestIdleCallback(function theeFunc(){\n                \"use strict\";\n                if (--cycleCount \u003c 0) {\n                    var res = tests.reduce((a, b) =\u003e a + b) / tests.length;\n                    resStr += \"\\n\" + str + res + \"ms\";\n\t\t\t\t\tacc();\n                    return;\n                }\n                var i = 0, k = performance.now();\n                (function test(v){\n                    f(function(k){\n                        k(v+(((v\u003c\u003c5)%11)|0)|0);\n                    }).then(function(v){\n\t\t\t\t\t\ti = i + 1|0;\n                        if (i \u003c 131072) {\n                            test(v%7|0);\n                        } else {\n\t\t\t\t\t\t\ttests.push((performance.now() - k)/131072);\n                            tmp = tmp + v|0;\n\t\t\t\t\t\t\tclearInterval(intervalID);\n\t\t\t\t\t\t\trequestIdleCallback(theeFunc);\n                        }\n                    });\n                })(Math.random()*40|0);\n                var last = 0;\n                var intervalID = setInterval(function(){\n\t\t\t\t\tif (last !== i) {last = i; return}\n\t\t\t\t\ti = 131072;\n\t\t\t\t\tclearInterval(intervalID);\n\t\t\t\t\ttests.push((performance.now() - k)/i);\n\t\t\t\t\trequestIdleCallback(theeFunc);\n                }, 10);\n            }, idleOptions);\n        });\n    }\n\n\tawait test(\"NativeR1:   \", function(x){return new nativePromise(x)});\n\tawait test(\"NativeR2:   \", function(x){return new nativePromise(x)});\n\tawait test(\"NativeR3:   \", function(x){return new nativePromise(x)});\n\tawait test(\"NativeR4:   \", function(x){return new nativePromise(x)});\n\tawait (new nativePromise(_=\u003erequestIdleCallback(_))); // to allow the CPU to take a break\n\t(new Function(document.body.innerText))();\n\tvar bbPromise = window.Promise;\n\tawait test(\"BluebirdR1: \", function(x){return new bbPromise(x)});\n\tawait test(\"BluebirdR2: \", function(x){return new bbPromise(x)});\n\tawait test(\"BluebirdR3: \", function(x){return new bbPromise(x)});\n\tawait test(\"BluebirdR4: \", function(x){return new bbPromise(x)});\n\tawait (new nativePromise(_=\u003erequestIdleCallback(_))); // to allow the CPU to take a break\n\twindow.Promise = nativePromise;\n\tvar SPromise = window.SPromise;\n\tawait test(\"SPromiseR1: \", function(x){return SPromise(x)});\n\tawait test(\"SPromiseR2: \", function(x){return SPromise(x)});\n\tawait test(\"SPromiseR3: \", function(x){return SPromise(x)});\n\tawait test(\"SPromiseR4: \", function(x){return SPromise(x)});\n\tconsole.log(resStr);\n})(requestIdleCallback, console, performance);\n```\nConsole output (lower numbers = lower promise delay = better):\n```\nNativeR1:   0.005961311340207942ms\nNativeR2:   0.005754425048820622ms\nNativeR3:   0.005737731933574963ms\nNativeR4:   0.005725685119539747ms\nBluebirdR1: 0.0004817428588488326ms\nBluebirdR2: 0.0003913345338446561ms\nBluebirdR3: 0.0003724441526742339ms\nBluebirdR4: 0.00038145446783488524ms\nSPromiseR1: 0.0002370834351062001ms\nSPromiseR2: 0.00017644500722724388ms\nSPromiseR3: 0.00017766571041022416ms\nSPromiseR4: 0.00017798614484476616ms\n```\n\n### Await Promising\nBenchmark Code (executed in the console at https://cdnjs.cloudflare.com/ajax/libs/bluebird/2.11.0/bluebird.min.js):\n```Javascript\n(async function(performance, console){\n\t\"use strict\";\n\tvar resStr=\"\";\n\tvar nativePromise = window.Promise, idleOptions = {timeout: 10};\n\tfunction acceptor(acc){acc();}\n\tfunction test(str, f){\n\t\treturn new nativePromise(function(acc){\n            var tests=[], SPromise = window.SPromise;\n            var cycleCount=6, intV=requestIdleCallback(function theeFunc(){\n                \"use strict\";\n                if (--cycleCount \u003c 0) {\n                    var res = tests.reduce((a, b) =\u003e a + b) / tests.length;\n                    resStr += \"\\n\" + str + res + \"ms\";\n\t\t\t\t\tacc();\n                    return;\n                }\n                var k = performance.now(), i = 0;\n                (async function test(){\n                    await f(acceptor);\n                    if (i \u003c 384) {\n\t\t\t\t\t\ti = i+1|0;\n                        test();\n                    } else {\n                        tests.push((performance.now() - k)/384);\n                \t\trequestIdleCallback(theeFunc, idleOptions);\n                    }\n                })(Math.random()*40|0);\n            }, idleOptions);\n        });\n    }\n\n\tawait test(\"NativeR1:   \", function(x){return new nativePromise(x)});\n\tawait test(\"NativeR2:   \", function(x){return new nativePromise(x)});\n\tawait test(\"NativeR3:   \", function(x){return new nativePromise(x)});\n\tawait (new nativePromise(_=\u003erequestIdleCallback(_))); // to allow the CPU to take a break\n\t(new Function(document.body.innerText))();\n\tvar bbPromise = window.Promise;\n\tawait test(\"BluebirdR1: \", function(x){return new bbPromise(x)});\n\tawait test(\"BluebirdR2: \", function(x){return new bbPromise(x)});\n\tawait test(\"BluebirdR3: \", function(x){return new bbPromise(x)});\n\tawait (new nativePromise(_=\u003erequestIdleCallback(_))); // to allow the CPU to take a break\n\twindow.Promise = nativePromise;\n\tvar SPromise = window.SPromise;\n\tawait test(\"SPromiseR1: \", function(x){return SPromise(x)});\n\tawait test(\"SPromiseR2: \", function(x){return SPromise(x)});\n\tawait test(\"SPromiseR3: \", function(x){return SPromise(x)});\n\tconsole.log(resStr);\n})(performance, console);\n```\nConsole output (lower numbers = lower promise delay = better):\n```\nNativeR1:   0.008009982618912342ms\nNativeR2:   0.010225694394547543ms\nNativeR3:   0.01835503472749325ms\nBluebirdR1: 4.231184895818134ms\nBluebirdR2: 4.206684027773615ms\nBluebirdR3: 4.192039930558167ms\nSPromiseR1: 0.016039496535490295ms\nSPromiseR2: 0.010410156290971728ms\nSPromiseR3: 0.010818142375986403ms\n```\n[Caution: Please don't read the following paragraph if you are easily disturbed by vivid images of emesis. Also, note that this paragraph has been a bit less applicable since Chrome's `await` recieved internal optimizations.] The significance of the above tests is that trying to force a native method like `await` into using a user-created function like `SPromise` is comparable to trying to swallow someone else's barf. If you are going to swallow barf (as in `await`), you would likely want to swallow your own *native* barf instead of trying to swallow the barf of someone else (like Bluebird or SPromise). Yet in spite of this, SPromise makes the barf tasty (fast and performant) enough for Chrome to swallow it with greater efficiency.\n\n## Development\n\nOn Linux, the project can be developed by cloning it with the following command line.\n\n```Bash\ngit clone https://github.com/anonyco/SPromiseMeSpeedJS.git; cd SPromiseMeSpeedJS; npm run install-dev\n```\n\nEmphasize the `npm run install-dev` which downloads `closure-compiler.jar` into the repository for minifying the files.\n\nNow that the repository is cloned, edit the files as one see fit. Now that the files have been edited, run the following in the terminal in the root folder of the repository in order to minify the NodeJS JavaScript files.\n\n```Bash\nnpm run build\n```\n\n## Continuity\n\nFeel free to reach out to me at wowzeryest@gmail.com.  I am fairly attentive to my GitHub account, but in the unlikely event that issues/pulls start piling up, I of course welcome others to step in and contribute.  I am widely open to input and collaboration from anyone on all of my projects.\n\n\n\u003c!--# SPromiseMeSpeedAdvancedEnumerations.js\n\nFor a separate project I am using SPromiseMeSpeed in, the default ECMAScript specification for promises is just simply too slow for my purposes. Thus, I have revised the whole thing to use lickety-fast enumerations. However, for this script, do not ever do `\u003cscript src=\"SPromiseMeSpeedAdvancedEnumerations.js\"\u003e\u003c/script\u003e` as that will make your code really slow. Also do not use distribute this script unminified or without the `DEBUGMODE` variable not set to `true` as that will make your code really slow too. The way to use this script is to insert it into the scope of your actual script and minify it along with the rest of your script to increase performance to the limit. Example usage of this script is as follows.\n\n```Javascript\nSPromise_all(\n    SPromise(function(accept, reject){\n        setTimeout(accept, 1000);\n    }),\n    SPromise(function(accept, reject){\n\t\tsetTimeout(accept, 500);\n    })\n)[ENUM_SPROMISE_THEN](function(){\n\tconsole.log(\"success!\")\n})[ENUM_SPROMISE_FINALLY](function(){\n\tconsole.log(\"finally!\")\n});\n```--\u003e\n\n\u003c!--# PromiseRejectionEvent\nThe current spec for Promises wants there to be a PromiseRejectionEvent. SPromise will asynchronously (via setTimeout) fire a PromiseRejectionEvent on the window object when there is a Promise that fails and has nothing to handle the failure. However, SPromise slightly deviates from this specification for the purposes of performance in so much that SPromise treats internal triggers from `Promise.all` and `Promise.race` same as ordinary handles. Thus, when a promise is rejected, but you called race/all on the promise, the promise wrongly never fires a PromiseRejectionEvent event. This is a known bug, but it will never be fixed because of the overhead involved in adding extra checks that verify whether a catch handler is internal or external. Further, any fix for this bug would only apply to SPromises: there would be no (reasonable/sane) way to patch calling native Promise.all on an array of SPromises that are about to be rejected. Observe.\n\n```Javascript\n// This demonstrates one of the many minor ways that SPromise deviates from the specification\nvar rejectThePromise;\nvar promiseToBeRejected = SPromise(function(accept, reject){rejectThePromise = reject});\n\nSPromise.all(promiseToBeRejected)\n    .catch(function(){}); // ensure that the rejection of SPromise.all is caught here\n\nrejectThePromise(); // should cause a PromiseRejectionEvent to be emitted, but no PromiseRejectionEvent ever happens\n```--\u003e\n\n\u003c!--# Think Before You Pull!\nThe purpose of SPromiseMeSpeed is to be a transitional speed-polyfill to bridge the gap between current browser promise performance and native browser promise performance. The purpose of SPromiseMeSpeed is **not** to be a full-featured Goliath standing over 100+kb in size. Do not open up any pull requests or commits suggesting new features or promise utilities. Even if they may be good ideas, I will never integrate them into this library. Rather, you should fork this library and then put all of your changes into that fork instead. Or, alternatively, you can just use BlueBird instead. In any event, it would be pointless for the creator of this library to be working on any extra promise utilies since he is currently creating something that will make every library in every language obsolete.\n--\u003e\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanonyco%2Fspromisemespeedjs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fanonyco%2Fspromisemespeedjs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanonyco%2Fspromisemespeedjs/lists"}