2.0.1 • Published 3 years ago

@vinka/clock v2.0.1

Weekly downloads
49
License
MIT
Repository
github
Last release
3 years ago

Clock that supports simulated (and boosted) time

npm install --save @vinka/clock

Initialize and create a service with exposed now() function:

const moment = require('moment');
const Clock = require('@vinka/clock');

const clock = new Clock(moment);

exports.now = () => clock.now();

To initialize with regular time:

new Clock(moment)

To initialize with simulated time:

new Clock(moment, moment('2013-04-23T13:00:00'));

To initialize with simulated time and going 10x speed:

new Clock(moment, moment('2013-04-23T13:00:00'), 10);

To make clock go backwards:

new Clock(moment, moment(), -1);

Clock functions:

  • now(): get the current simulated time as moment (utc) object.
  • pause(): this will pause the time.
  • resume(): resume after pause.
2.0.1

3 years ago

2.0.0

3 years ago

1.2.0

3 years ago

1.1.0

5 years ago

1.0.0

7 years ago