1.1.5 โข Published 4 months ago
node-interval-return v1.1.5
๐ Description :
This package is designed to run setInterval
with several features. It includes functionalities such as returning a promise, executing a specific task first, stopping the interval, and automatically stopping the interval in the background if a return is triggered.
๐ป Step to install :
npm install --production node-interval-return
โ๏ธ Example :
Typescript
import { interval, intervalReturn } from "node-interval-return";
ESM (import)
import { interval, intervalReturn } from "node-interval-return";
CommonJs (require)
const { interval, intervalReturn } = require("node-interval-return");
Usage
const { intervalReturn } = require("node-interval-return");
(async () => {
const runInterval1 = await intervalReturn(5000, true, (res, rej) => {
res("is result value");
});
console.log(
`[runInterval1] running with do first without waiting interval complete, result: ${runInterval1}`
);
try {
const runInterval2 = await intervalReturn(5000, true, (res, rej) => {
rej("is error value");
});
} catch (err) {
console.log(
`[runInterval2] running with do first without waiting interval complete, error: ${err}`
);
}
})();
full example see here
๐งพ Pre-Requisistes :
node.js
๐ License :
Licensed under the MIT License.