@hasezoey/interval-promise-ts
v1.1.0
Published
Interval Promise Re-write to TS
Downloads
2
Readme
Interval Promise re-write to TS
its a rewrite to TS Original by Andy Fleming
using my(hasezoey) TS config & lint options
The Following is from the original Readme
Overview
This library provides a simple mechanism for running a promise with a given amount of time between executions.
Standard Javascript » setInterval()
interval-promise » interval()
Usage
Simple example using async-await
const interval = require('interval-promise')
// Run a function 10 times with 1 second between each iteration
const id = interval.interval(async () => {
await someOtherPromiseReturningFunction()
await another()
}, 1000, {iterations: 10})
// clear it
await clearInterval(id);
import { interval, clearInterval } from "interval-promise";
// Run a function 10 times with 1 second between each iteration
const id: string = interval(async () => {
await someOtherPromiseReturningFunction()
await another()
}, 1000, {iterations: 10})
// clear it
await clearInterval(id);
API
interval(cb: function, intervalLength: number | Infinity, options: IOptions): Promise<void>;
Arguments
clearInterval(id: string): Promise<void>;
Arguments
More on "intervalLength" as a function
It will be called with "0" once (the initial call for the first run), and after that "Infinity" if it is set to run Infinite, otherwise a normal number
Project Values
- Approachability — Basic usage should be concise and readable.
- Debuggability — Error feedback should be helpful and error handling options should be flexible.
- Stability — Functionality should be well-tested and reliable.