Lie-TS
The smallest, quickest TypeScript promise library available.
Forked from the orginal Lie JS promise lib and includes it's own setImmediate polyfill, significantly reducing the effective size compared to the original library.
- Entire lib is self contained and only 1.5 kb gzipped.
- Runs easily in NodeJS and any modern browser, including IE9+.
- Autodetects best
setImediate
method and uses it. Checks in this order for these methods:
- Built in
setImediate
method attached to window or global object. - If
window.postMessage
is possible, uses an ultra fast messaging method to polyfill setImediate. - Finally falls back to
setTimeout
if everything else fails.
Also includes a new special tricK:
new Promise.then
Install
npm install lie-ts
You can also grab the compressed, minified file fom the /dist
folder of this repository.
Usage
// Common JS/nodevar Promise = Promise; // ES6/ Typescript; // Take over global/window Promise object *if it doesn't exist already*.Promise;
You can also just drop the minified lib from the /dist
folder directly into a <script>
tag or load it in with an AMD loader.
API
Implements the standard ES6 api:
{ ;}; Promiseall //array of promises or values
A Little Bonus
The isomorphic setImmediate polyfill described at the top is exposed as setFast
.
; setFast, "args", "to", "pass";
Unhandled Rejections
In Node.js, lie emits an unhandledRejection
event when a rejected promise isn't caught, in line with how io.js does it. This allows it to act as a promise shim in both Node.js and the browser.