NODE-INTERVAL-RETURN
📖 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.