https://github.com/a/to-ms
Tiny chained ms creation util for NodeJS and browsers
https://github.com/a/to-ms
Last synced: 7 months ago
JSON representation
Tiny chained ms creation util for NodeJS and browsers
- Host: GitHub
- URL: https://github.com/a/to-ms
- Owner: A
- Created: 2014-09-27T12:11:48.000Z (almost 12 years ago)
- Default Branch: master
- Last Pushed: 2019-07-25T12:45:49.000Z (almost 7 years ago)
- Last Synced: 2025-04-09T13:45:03.351Z (about 1 year ago)
- Language: JavaScript
- Homepage: http://shuvalov-anton.github.io/to-ms
- Size: 54.7 KB
- Stars: 7
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# toMs
[](https://travis-ci.org/shuvalov-anton/to-ms)
[](https://codeclimate.com/github/shuvalov-anton/to-ms)
[](https://coveralls.io/r/shuvalov-anton/to-ms?branch=master)
[](https://nodei.co/npm/to-ms/)
Simple and human friendly millisecond implementation with awesome chaining. Thanks [@subzey][1] for a sketch and advise :D
[1]: https://github.com/subzey
## Install
```
npm install to-ms
```
## Examples
```js
var toMs = require('to-ms');
setTimeout(
function () {
/* do something */
}, toMs
.hour()
.minutes(15)
.seconds(30)
);
```
## Chaining
All methods are chainable. I mean, you can pretty simple write something like this:
```js
var ms = toMs
.days(30)
.hours(10)
.minutes(30)
.seconds(45);
```
## Browser Support
Just use `window.toMs`. To support legacy browsers you must use [ES5-Shim][2].
[2]: https://github.com/es-shims/es5-shim
## Methods
- `toMs.second()`
- `toMs.seconds(Number)`
- `toMs.minute()`
- `toMs.minutes(Number)`
- `toMs.hour()`
- `toMs.hours(Number)`
- `toMs.day()`
- `toMs.days(Number)`
- `toMs.week()`
- `toMs.weeks(Number)`
- `toMs.year()`
- `toMs.years(Number)`