node-interval-return
TypeScript icon, indicating that this package has built-in type declarations

1.1.5 • Public • Published

NODE-INTERVAL-RETURN

GitHub top language Made by Repository size GitHub last commit


📖 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.

Package Sidebar

Install

npm i node-interval-return

Weekly Downloads

2

Version

1.1.5

License

MIT

Unpacked Size

12.2 kB

Total Files

7

Last publish

Collaborators

  • damartripamungkas