Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jameshulse/mr-time
Tiny fluent time conversions package for better code readability
https://github.com/jameshulse/mr-time
fluent-api javascript node node-js node-module node-modules nodejs npm readability small-tools time
Last synced: 6 days ago
JSON representation
Tiny fluent time conversions package for better code readability
- Host: GitHub
- URL: https://github.com/jameshulse/mr-time
- Owner: jameshulse
- License: mit
- Created: 2017-09-29T15:48:12.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2018-01-04T17:06:15.000Z (about 7 years ago)
- Last Synced: 2024-12-07T09:27:23.434Z (about 1 month ago)
- Topics: fluent-api, javascript, node, node-js, node-module, node-modules, nodejs, npm, readability, small-tools, time
- Language: JavaScript
- Homepage:
- Size: 45.9 KB
- Stars: 1
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[![Build Status](https://travis-ci.org/jameshulse/mr-time.svg?branch=master)](https://travis-ci.org/jameshulse/mr-time) [![Coverage Status](https://coveralls.io/repos/github/jameshulse/mr-time/badge.svg?branch=master)](https://coveralls.io/github/jameshulse/mr-time?branch=master) [![npm](https://img.shields.io/npm/v/mr-time.svg)](https://www.npmjs.com/package/mr-time)
# Mr. Time π¨π»π
### Description
Mr. Time provides better code readibility than random numbers representing amounts of time scattered through your code.Ever needed to provide a timeout to a function call and had to google 'How many milliseconds in 24 hours'. Your options are:
#### Bad
```javascript
setTimeout(myMethod, 86400000); // Nobody will have any idea how long this is
```#### Better
```javascript
const TWENTY_FOUR_HOURS_IN_MILLISECONDS = 86400000; // I still had to google to get this number first...setTimeout(myMethod, TWENTY_FOUR_HOURS_IN_MILLISECONDS);
```#### β Bestβ
```javascript
let T = require('mr-time');setTimeout(myMethod, T(24).hours.in.milliseconds); // No googling, easy to read, everyones happy
```### Installation
`npm install mr-time`
`yarn add mr-time`
### Usage
```javascript
let T = require('mr-time');
let oneDayInMilliseconds = T(1).days.in.milliseconds; // returns 86400000
let twoWeeksInSeconds = T(2).weeks.in.seconds; // returns 1210000
```### Upcoming
- Add month, year, decade, century, nanoseconds etc