winterval

1.0.0 • Public • Published

Winterval

A powerful version of JavaScript interval.

Installation

# NPM
npm install winterval

# Yarn
yarn add winterval

Usage

import createInterval from 'winterval';  // TypeScript
const createInterval = require('winterval').default;  // JavaScript

// Create and starts a new interval.
const interval = createInterval(
    () => { /* ... */ }, // The function that will be executed between the intervals.
    2000, // The time between the interval function executions.
    false // If `true`, the interval function will execute immediately.
);

// You can stop the interval with the stop function.
interval.stop();

// If do you want to start the interval again, use the start function.
interval.start();

// Winterval also features a pause function.
setTimeout(() => {
    // To pause the interval, you can use the pause function.
    // After 500 milliseconds of the interval execution, lets pause this interval.
    interval.pause();

    // Then, after 500 milliseconds we resumes the interval by calling the start function.
    setTimeout(() => interval.start(), 500);
}, 2500);

License

MIT © Itallo Gabriel (https://github.com/7wf)

Readme

Keywords

Package Sidebar

Install

npm i winterval

Weekly Downloads

0

Version

1.0.0

License

MIT

Unpacked Size

11 kB

Total Files

6

Last publish

Collaborators

  • 7wf