accurate-timer-subscription
TypeScript icon, indicating that this package has built-in type declarations

0.0.2 • Public • Published

accurate-timer-subscription

A Node.js module that makes accurate intervals using setTimeout and then emits an rxjs event on that iteration. This is the first module I made so I'd be happy to get feedback from others.

Installation

npm install accurate-timer-subscription --save

Usage

import { AccurateTimer } from 'accurate-timer-subscription';
import { Subscription } from 'rxjs';

const timer = new AccurateTimer(1000);
const sub = new Subscription();

// Subscribe to events
sub.add(timer.subscribe((v) => {
    console.log('Date:', v);
}))
// Start the timer
timer.start();
// Change interval while running
timer.setMilliseconds(2000);
// Stop the timer
timer.stop();
Output should be of type new Date().toISOString() or 0 for errors

Test

npm run test

Package Sidebar

Install

npm i accurate-timer-subscription

Weekly Downloads

3

Version

0.0.2

License

MIT

Unpacked Size

18 kB

Total Files

11

Last publish

Collaborators

  • danikays