Parse strings that indicate a time to their millisecond equivalents.
This module is written with Node.js and Browserify in mind and can therefor be installed using the node package manager:
npm install --save millisecond
The module exposes one single function interface, so you simply require it using:
'use strict';var ms = ;
And to parse a string simply supply it as first argument and it will return
a number. If we're unable to parse it, we will automatically return
; // returns 1000; // returns 1; // returns 0
It understands the following strings:
The space after the number is optional so you can also write
1ms instead of
1 ms. In addition to that it also accepts numbers and strings which only includes
numbers and we assume that these are always in milliseconds.
This module is heavily inspired by the
ms module which is also licensed under
MIT. If you also need to transform numbers back in to strings I suggest you look
at that library.