Skip to content

Commit

Permalink
Adds badges
Browse files Browse the repository at this point in the history
  • Loading branch information
repraze committed Jun 29, 2019
1 parent 9570333 commit a36cbd8
Showing 1 changed file with 30 additions and 30 deletions.
60 changes: 30 additions & 30 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# delta-time

[![Build Status](https://travis-ci.org/repraze-org/delta-time.svg?branch=master)](https://travis-ci.org/repraze-org/delta-time)
[![npm](https://img.shields.io/npm/v/delta-time.svg?logo=npm&style=flat-square)](https://www.npmjs.com/package/delta-time) [![Travis (.org)](https://img.shields.io/travis/repraze-org/delta-time.svg?logo=travis&style=flat-square)](https://travis-ci.org/repraze-org/delta-time) [![Codecov](https://img.shields.io/codecov/c/github/repraze-org/delta-time.svg?logo=codecov&style=flat-square)](https://codecov.io/gh/repraze-org/delta-time) [![GitHub](https://img.shields.io/github/license/repraze-org/delta-time.svg?logo=github&style=flat-square)](https://github.com/repraze-org/delta-time) [![npm](https://img.shields.io/npm/dm/delta-time.svg?logo=npm&style=flat-square)](https://www.npmjs.com/package/delta-time)

A simple module to compute intervals

* Simple function to parse user friendly intervals
* Clear-up your code from messy time computations
* Plug it into your utility to ease the interface
- Simple function to parse user friendly intervals
- Clear-up your code from messy time computations
- Plug it into your utility to ease the interface

## Installation

Expand All @@ -15,58 +15,58 @@ A simple module to compute intervals
## Usage

```javascript
var dt = require('delta-time');
var dt = require("delta-time");
```

### Perfect for timeouts

```javascript
setTimeout(function(){
setTimeout(function() {
console.log("foo");
}, dt('500ms'));
}, dt("500ms"));

setTimeout(function(){
setTimeout(function() {
console.log("bar");
}, dt('5 secs'));
}, dt("5 secs"));

setTimeout(function(){
setTimeout(function() {
console.log("baz");
}, dt('1h30m5s'));
}, dt("1h30m5s"));
```

### Allows complex specifications

```javascript
dt('- 1 day') // -86400000
dt('2 hours - 30 seconds') // 7170000
dt("- 1 day"); // -86400000
dt("2 hours - 30 seconds"); // 7170000
```

### Not just for milliseconds

```javascript
dt('1000 ms', 's') // 1
dt('2 week', 'days') // 14
dt('300 Years, 5 Months and 2 Hours', 'days') // 109727.28333333334
dt("1000 ms", "s"); // 1
dt("2 week", "days"); // 14
dt("300 Years, 5 Months and 2 Hours", "days"); // 109727.28333333334
```

## API

### function(time, [unit])

* Takes a number or a string describing a time interval
* A combination of units can be given
* Returns the value of the interval in ms
* If a unit is provided, it will be used instead of ms
- Takes a number or a string describing a time interval
- A combination of units can be given
- Returns the value of the interval in ms
- If a unit is provided, it will be used instead of ms

## Language

* nanosecond : ns, nano(s), nanosecond(s)
* microsecond : μs, micro(s), microsecond(s)
* millisecond : ms, milli(s), millisecond(s)
* second : s, sec(s), second(s)
* minute : m, min(s), minute(s)
* hour : h, hr(s), hour(s)
* day : d, day(s)
* week : w, wk(s), week(s)
* month : mo(s), month(s)
* year : y, yr(s), year(s)
- nanosecond : ns, nano(s), nanosecond(s)
- microsecond : μs, micro(s), microsecond(s)
- millisecond : ms, milli(s), millisecond(s)
- second : s, sec(s), second(s)
- minute : m, min(s), minute(s)
- hour : h, hr(s), hour(s)
- day : d, day(s)
- week : w, wk(s), week(s)
- month : mo(s), month(s)
- year : y, yr(s), year(s)

0 comments on commit a36cbd8

Please sign in to comment.