opusdev/vector-similarity-api
1
1# ms2 34 5Use this package to easily convert various time formats to milliseconds.6 7## Examples8 9```js10ms('2 days') // 17280000011ms('1d') // 8640000012ms('10h') // 3600000013ms('2.5 hrs') // 900000014ms('2h') // 720000015ms('1m') // 6000016ms('5s') // 500017ms('1y') // 3155760000018ms('100') // 10019ms('-3 days') // -25920000020ms('-1h') // -360000021ms('-200') // -20022```23 24### Convert from Milliseconds25 26```js27ms(60000) // "1m"28ms(2 * 60000) // "2m"29ms(-3 * 60000) // "-3m"30ms(ms('10 hours')) // "10h"31```32 33### Time Format Written-Out34 35```js36ms(60000, { long: true }) // "1 minute"37ms(2 * 60000, { long: true }) // "2 minutes"38ms(-3 * 60000, { long: true }) // "-3 minutes"39ms(ms('10 hours'), { long: true }) // "10 hours"40```41 42## Features43 44- Works both in [Node.js](https://nodejs.org) and in the browser45- If a number is supplied to `ms`, a string with a unit is returned46- If a string that contains the number is supplied, it returns it as a number (e.g.: it returns `100` for `'100'`)47- If you pass a string with a number and a valid unit, the number of equivalent milliseconds is returned48 49## Related Packages50 51- [ms.macro](https://github.com/knpwrs/ms.macro) - Run `ms` as a macro at build-time.52 53## Caught a Bug?54 551. [Fork](https://help.github.com/articles/fork-a-repo/) this repository to your own GitHub account and then [clone](https://help.github.com/articles/cloning-a-repository/) it to your local device562. Link the package to the global module directory: `npm link`573. Within the module you want to test your local development instance of ms, just link it to the dependencies: `npm link ms`. Instead of the default one from npm, Node.js will now use your clone of ms!58 59As always, you can run the tests using: `npm test`60 