PageRenderTime 26ms CodeModel.GetById 13ms app.highlight 8ms RepoModel.GetById 2ms app.codeStats 0ms

/node_modules/ms/readme.md

https://bitbucket.org/coleman333/smartsite
Markdown | 51 lines | 38 code | 13 blank | 0 comment | 0 complexity | 90e631c6afccde3ed414d3d230734864 MD5 | raw file
 1# ms
 2
 3[![Build Status](https://travis-ci.org/zeit/ms.svg?branch=master)](https://travis-ci.org/zeit/ms)
 4[![Slack Channel](http://zeit-slackin.now.sh/badge.svg)](https://zeit.chat/)
 5
 6Use this package to easily convert various time formats to milliseconds.
 7
 8## Examples
 9
10```js
11ms('2 days')  // 172800000
12ms('1d')      // 86400000
13ms('10h')     // 36000000
14ms('2.5 hrs') // 9000000
15ms('2h')      // 7200000
16ms('1m')      // 60000
17ms('5s')      // 5000
18ms('1y')      // 31557600000
19ms('100')     // 100
20```
21
22### Convert from milliseconds
23
24```js
25ms(60000)             // "1m"
26ms(2 * 60000)         // "2m"
27ms(ms('10 hours'))    // "10h"
28```
29
30### Time format written-out
31
32```js
33ms(60000, { long: true })             // "1 minute"
34ms(2 * 60000, { long: true })         // "2 minutes"
35ms(ms('10 hours'), { long: true })    // "10 hours"
36```
37
38## Features
39
40- Works both in [node](https://nodejs.org) and in the browser.
41- If a number is supplied to `ms`, a string with a unit is returned.
42- If a string that contains the number is supplied, it returns it as a number (e.g.: it returns `100` for `'100'`).
43- If you pass a string with a number and a valid unit, the number of equivalent ms is returned.
44
45## Caught a bug?
46
471. [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 device
482. Link the package to the global module directory: `npm link`
493. 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 will now use your clone of ms!
50
51As always, you can run the tests using: `npm test`