1.0.5 • Published 4 years ago

msec v1.0.5

Weekly downloads
15
License
BSD-2-Clause
Repository
github
Last release
4 years ago

msec

string to milliseconds parser

Usage

'use strict';

let msec = require('msec');

setTimeout(() => {
    console.log('I execute after 1d 2h 37m 15s');
}, msec('1d 2h 37m 15s'));

setInterval(() => {
    console.log('I execute every 2 hours');
}, msec('2h'));

setTimeout(() => {
    console.log('I execute after 1h 3m 15s');
}, msec('5s 10s 1h 3m'));

new Date(Date.now() + msec('2d')); // same time, 2 days later

new Date(Date.now() + msec('2d 4h')); // 2 days and 4 hours later

Install

$ npm install --save msec

Test

$ npm install && npm test