0.0.2 • Published 4 years ago

accurate-timer-subscription v0.0.2

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

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
0.0.2

4 years ago

0.0.1

4 years ago