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

1.0.5 • Public • Published

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

Dependents (0)

Package Sidebar

Install

npm i msec

Weekly Downloads

2

Version

1.0.5

License

BSD-2-Clause

Unpacked Size

5.09 kB

Total Files

10

Last publish

Collaborators

  • zewish