1.1.5 โ€ข Published 4 months ago

node-interval-return v1.1.5

Weekly downloads
-
License
MIT
Repository
github
Last release
4 months ago

๐Ÿ“– 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.