Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jamiebuilds/tickedoff
Tiny library (<200B gzip) for deferring something by a "tick"
https://github.com/jamiebuilds/tickedoff
async defer javascript nexttick polyfill ponyfill promise setimmediate settimeout sleep wait
Last synced: 13 days ago
JSON representation
Tiny library (<200B gzip) for deferring something by a "tick"
- Host: GitHub
- URL: https://github.com/jamiebuilds/tickedoff
- Owner: jamiebuilds
- License: mit
- Created: 2018-03-26T17:53:50.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2023-06-13T09:55:04.000Z (over 1 year ago)
- Last Synced: 2024-08-09T03:18:10.135Z (3 months ago)
- Topics: async, defer, javascript, nexttick, polyfill, ponyfill, promise, setimmediate, settimeout, sleep, wait
- Language: JavaScript
- Size: 31.3 KB
- Stars: 218
- Watchers: 6
- Forks: 15
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-list - tickedoff
- awesome-ponyfills - tickedoff - [`setImmediate`](https://nodejs.org/api/timers.html#timers_setimmediate_callback_args) (Node.js Features)
README
# tickedoff
> Tiny library (<200B gzip) for deferring something by a "tick"
- Using `setTimeout` is actually a bit slow because its clamped to 4ms
- `setImmediate` is not available in most places (and probably never will be)
- `process.nextTick` is only in Node
- `Promise#then` needs polyfills in places
- `tickedoff` uses whatever the best available option is
- There are more robust libraries/polyfills but they are larger in size
- This is all especially good for libraries to use## Install
```sh
yarn add tickedoff
```## Usage
```js
const defer = require('tickedoff');console.log(1);
defer(() => console.log(3));
console.log(2);
// 1
// 2
// 3
```## Perf
```sh
$ node perf.js
process.nextTick x 10000 = 24ms
Promise#then x 10000 = 29ms
setImmediate x 10000 = 68ms
setTimeout x 10000 = 13506ms
```