easy-ms
Easy and human friendly millisecond implementation that you will definitely love it
Installation
$ npm install --save easy-ms
Usage
It's easy and versatile. Below show examples of how to return 90,000 milliseconds.
var ms = ; //the simple // ms(ms) // ms(s, ms) // ms(m, s, ms) // ms(h, m, s, ms) // ms(d, h, m, s, ms) // ms(y, d, h, m, s, ms) // ms(y, d, h, m, s, ms) //with string as well //1 minute 30 second //1 minute 30 second //1 minute 30 second //1 minute 30 second //with object if you like it this way //I don't know why you want to do it this way, but it is absolutely fine //chain-able //chain-add //chain 5 seconds //you still remember of using strings? //or objects //or just numbers? //it all works //chain minus //maybe you like to minus of some time //or sub? //or subtract? //it's up to you.
We wish we could accept anything to be passed into easy-ms.
But below is a list of what does not work. They will return NaN
Inspiration
But do more than both combined.
Caveat
The value returned by the function ms(...)
is monkey patched Number. It might created some unwanted behaviors.
var ms = ;var val = ; //1000 millisecond //It is not strictly equalval == 1000; //return trueval === 1000; //return false //To circumvent this, use Number(...)Numberval === 1000; //return true;val + 0 === 1000; //return true, but not recommended //It might print more than you expected in console.logconsole;/*return { [Number: 1000] year: [Function: bound addTime], yrs: [Function: bound addTime], yr: [Function: bound addTime], ...*/console;//return 1000 //It works fine in stringsstr = 'wait for ' + val; // 'wait for 1000'str = `wait for `; // 'wait for 1000'
License
MIT