# lie-ts

> The Smallest & Fastest TS Promise lib.

Latest version **4.2.0** (published 2018-07-23) · MIT license · 0 weekly downloads

## Install

```sh
npm install lie-ts
pnpm add lie-ts
yarn add lie-ts
bun add lie-ts
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 4.2.0 |
| Published | 2018-07-23 |
| First published | 2017-03-18 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 31.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Maintainers | clicksimply |
| Keywords | lie, promise, async, aplus, typescript, performance, promises-a, promises-aplus, deferred, deferreds, future, flow control, dsl, fluent interface, setImmediate, setTimeout |

## Links

- npm: https://www.npmjs.com/package/lie-ts
- Repository: https://github.com/ClickSimply/lie-ts
- Homepage: https://github.com/ClickSimply/lie-ts#readme
- Issues: https://github.com/ClickSimply/lie-ts/issues
- npm.io page: https://npm.io/package/lie-ts

## Alternatives

- [@commercetools/sync-actions](https://npm.io/package/@commercetools/sync-actions.md) — 25.1K weekly downloads
- [cwait](https://npm.io/package/cwait.md) — 21.4K weekly downloads
- [@ledgerhq/hw-app-cosmos](https://npm.io/package/@ledgerhq/hw-app-cosmos.md) — 4.2K weekly downloads
- [@financial-times/o-loading](https://npm.io/package/@financial-times/o-loading.md) — 2.8K weekly downloads
- [fa](https://npm.io/package/fa.md) — 185 weekly downloads

## Recent versions

- 4.2.0 (latest) — 2018-07-23
- 4.1.0 — 2018-07-23
- 4.0.0 — 2018-05-20
- 3.9.0 — 2018-05-19
- 3.8.0 — 2018-04-07
- 3.7.0 — 2017-12-23
- 3.6.0 — 2017-12-04
- 3.5.0 — 2017-12-01
- 3.4.0 — 2017-12-01
- 3.3.0 — 2017-06-14
- 3.2.6 — 2017-05-27
- 3.2.5 — 2017-05-19
- 3.2.4 — 2017-05-19
- 3.2.3 — 2017-04-13
- 3.2.2 — 2017-04-13
- … 8 more at https://npm.io/package/lie-ts/versions

## README

# 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:
1. Built in `setImediate` method attached to window or global object.
2. If `window.postMessage` is possible, uses an ultra fast messaging method to polyfill setImediate.
3. Finally falls back to `setTimeout` if everything else fails.

Also includes a new special tricK:
```ts
new Promise(function(res, rej) {
    res(1,2,3);
}).then(function(v1,v2,v3) {
    console.log(v1,v2,v3) // <= 1, 2, 3
})
```

## Install

```bash
npm install lie-ts
```

You can also grab the compressed, minified file fom the `/dist` folder of this repository.

## Usage

```javascript
// Common JS/node
var Promise = require('lie-ts').Promise;

// ES6/ Typescript
import { Promise } from "lie-ts";

// Take over global/window Promise object *if it doesn't exist already*.
Promise.doPolyfill();
```

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:

```js
new Promise(function(resolve, reject){
    doSomething(function(err, result) {
        if (err) {
            reject(err);
        } else {
            resolve(result);
        }
    });
}).then(function (value) {
    //on success
}, function (reason) {
    //on error
}).catch(function (reason) {
    //shortcut for error handling
});

Promise.all([
    //array of promises or values
]).then(function ([/* array of results */]));

Promise.race([
    //array of promises or values
]);
// either resolves or rejects depending on the first value to do so
```

## A Little Bonus

The isomorphic setImmediate polyfill described at the top is exposed as `setFast`.

```ts
import { setFast } from "lie-ts";

setFast((a, b, c) => {
    console.log(a, b, c) // <= "args", "to", "pass"
    console.log("This will happen very quickly!")
}, "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](https://iojs.org/api/process.html#process_event_unhandledrejection). This allows it to act as a promise shim in both Node.js and the browser.

---
_Source: https://npm.io/package/lie-ts · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
