1.0.0 • Published 5 years ago

winterval v1.0.0

Weekly downloads
4
License
MIT
Repository
github
Last release
5 years ago

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)