timers-obj
TypeScript icon, indicating that this package has built-in type declarations

2.0.0 • Public • Published

timers-obj

Build Status Coverage Status npm

This module provides the wrappers for standard timers module so all timers (immediate, interval and timeout) can be used as objects.

For constructors, callback argument is after delay argument so it provides more convenient syntax for CoffeeScript and LiveScript, ie.:

timers = await import('timers-obj')

timer = timers.interval 1000, ->
  console.log 'Time is ticking'

Requirements

This is ESM module which requires ES2020 and Node >= 14.

Installation

npm install timers-obj

Additionally for Typescript:

npm install -D @types/node

Usage

import * as timers from "timers-obj"

or:

import {Immediate, immediate, Interval, interval, Timeout, timeout} from "timers-obj"

immediate

Create timer

const timer = timers.immediate(cb, [...args])

Remove timer

timer.remove()

interval

Create timer

const timer = timers.interval(delay, cb, [...args])

Remove timer

timer.remove()

timeout

Create timer

const timer = timers.timeout(delay, cb, [...args])

Remove timer

timer.remove()

License

Copyright (c) 2016-2021 Piotr Roszatycki piotr.roszatycki@gmail.com

MIT

Dependencies (0)

    Dev Dependencies (22)

    Package Sidebar

    Install

    npm i timers-obj

    Weekly Downloads

    0

    Version

    2.0.0

    License

    MIT

    Unpacked Size

    9.62 kB

    Total Files

    7

    Last publish

    Collaborators

    • dex4er