@slimio/timer
    TypeScript icon, indicating that this package has built-in type declarations

    1.0.2 • Public • Published

    Timer

    Version Maintenance MIT dep size Known Vulnerabilities Build Status Greenkeeper badge

    SlimIO - Node.js Driftless Interval Timer. This package is inspired by driftless

    ⚠️ This package is experimental (Please dont use it outside).

    Requirements

    Getting Started

    This package is available in the Node Package Repository and can be easily installed with npm or yarn.

    $ npm i @slimio/timer
    # or 
    $ yarn add @slimio/timer

    Why

    Node.js timer (interval and timeout) drift with the time. This package aim to implement a no-drift setInterval.

    Usage example

    const timer = require("@slimio/timer");
     
    const timerId = timer.setInterval(() => {
        console.log("hello world!");
    }, 1000);
     
    // Later...
    timer.clearInterval(timerId);

    API

    timer.setInterval(handler: Function, intervalMs: number): number

    Create a new interval. Same API as Node.js !

    timer.clearInterval(intervalId: number): void

    Clear a given interval id (the number returned by setInterval).

    Dependencies

    This project have no dependencies.

    License

    MIT

    Install

    npm i @slimio/timer

    DownloadsWeekly Downloads

    3

    Version

    1.0.2

    License

    MIT

    Unpacked Size

    7.33 kB

    Total Files

    5

    Last publish

    Collaborators

    • mcroquet
    • ahkrin
    • fraxken
    • alexandre.malaj