4.3.0 • Published 1 year ago

precision-timeout-interval v4.3.0

Weekly downloads
-
License
ISC
Repository
github
Last release
1 year ago

Installation

npm i precision-timeout-interval@latest

Importing

  // ES6:
  import { prcTimeout, prcInterval } from 'precision-timeout-interval';
  // CommonJS: 
  const { prcTimeout, prcInterval } = require('precision-timeout-interval');

Easy Interface

  let timeoutController = prcTimeout(delayInMilliseconds, callbackFunction);
  let interval = prcInterval(delayInMilliseconds, callbackFunction);
  • Timeouts are now cancellable:

let myTimeout = prcTimeout(500, () => console.log("I'm gona be cancelled") );
myTimeout.cancel()
  • And of course intervals are too

  • Interval controller is completely changed

    Meet with new interval controller methods: cancel, restart, pauseResume and setPeriod

let myInterval = prcInterval(100, () => console.log("Hello V4") ); // start
myInterval.pauseResume(); // pause
myInterval.pauseResume(); // resume
myInterval.restart(); // restart counter
myInterval.setPeriod(1000); // set a new period and restart
myInterval.cancel() // stop

WithDelta Support Since V3.0.0

Timers and Intervals can autobind delta time if you wish as callback parameter. Usefull especially for game developers.

prcTimeoutWithDelta(50, (deltaT) =>{
  console.log("Hello, after "+ deltaT +" msecs");
});
4.3.0

1 year ago

4.1.0

2 years ago

4.0.0

2 years ago

3.1.2

2 years ago

3.1.1

2 years ago

3.1.0

2 years ago

3.0.0

2 years ago

2.0.0

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago