0.2.2 • Published 2 years ago

gear1023-at v0.2.2

Weekly downloads
-
License
ISC
Repository
-
Last release
2 years ago

(2022-10-17 01:18) Please come here :

https://www.npmjs.com/package/@gear1023/at

Enclosed & Extended setTimeout/setInterval for easy use.

Methods & props:

  • tasks: List of all tasks waiting in line
  • timeout & cancelTimeout: Almost the same function with setTimeout & clearTimeout
  • interval & cancelInterval: Almost the same function with setInterval & clearInterval
  • once & cancelonce: run the function at a specific time.
  • onceafter & cancelonceafter: run the function after a specific time.

Function Definition

Usage

  1. Installation
  2. sample

// Print "A", "B", "C" after 10 seconds at.timeout('T1', 10, (...params)=>{console.log(params)}, "A", "B", "C")

// Only the last task with the same key (T1) will be run at.timeout('T1', 10, (...params)=>{console.log(params0)}, "A", "B", "C")

// Print "A", "B", "C" at time "22:07" for just once. It will run at time "22:07" tomorrow if time just passed. at.once("A1", "22:07", (...params)=>{console.log(params)}, "A", "B", "C")

// Print "A", "B", "C" after 1 hour 3 minutes and 7 seconds at.onceafter("A2", "1:3:07", (...params)=>{console.log(params)}, "A", "B", "C")

// Print "A", "B", "C" after 3 minutes and 7 seconds at.onceafter("A3", "3:7", (...params)=>{console.log(params)}, "A", "B", "C")

// Print "A", "B", "C" after 7 seconds at.onceafter("A4", "7", (...params)=>{console.log(params)}, "A", "B", "C")

// Print "A", "B", "C" after 7 seconds at.onceafter("A5", 7, (...params)=>{console.log(params)}, "A", "B", "C")

// use await for short time call back result let ret = await at.onceafter("A5", 7, (...params)=>{return params}, "A", "B", "C") console.log(ret)

Contact

Any suggestions please:

email1: 13316098767@qq.com

email2: gear1023@gmail.com

wechat:13316098767

0.2.2

2 years ago

0.2.1

2 years ago

0.2.0

2 years ago

0.1.0

2 years ago