tickedoff

小小的库(<200B gzip),用于将某些东西推迟到一个 "tick"。「Tiny library (<200B gzip) for deferring something by a "tick"」

Github stars Tracking Chart

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

yarn add tickedoff

Usage

const defer = require('tickedoff');

console.log(1);
defer(() => console.log(3));
console.log(2);
// 1
// 2
// 3

Perf

$ node perf.js
process.nextTick x 10000 = 24ms
Promise#then x 10000 = 29ms
setImmediate x 10000 = 68ms
setTimeout x 10000 = 13506ms

Main metrics

Overview
Name With Ownerjamiebuilds/tickedoff
Primary LanguageJavaScript
Program languageJavaScript (Language Count: 1)
PlatformLinux, Mac, Web browsers, Windows
License:MIT License
所有者活动
Created At2018-03-26 17:53:50
Pushed At2023-06-13 09:55:04
Last Commit At2018-04-20 12:31:48
Release Count3
Last Release Namev1.0.2 (Posted on 2018-04-20 12:31:48)
First Release Namev1.0.0 (Posted on 2018-03-26 10:54:03)
用户参与
Stargazers Count218
Watchers Count5
Fork Count15
Commits Count7
Has Issues Enabled
Issues Count0
Issue Open Count0
Pull Requests Count1
Pull Requests Open Count2
Pull Requests Close Count2
项目设置
Has Wiki Enabled
Is Archived
Is Fork
Is Locked
Is Mirror
Is Private