Skip to content

Tiny fluent time conversions package for better code readability

License

Notifications You must be signed in to change notification settings

jameshulse/mr-time

Folders and files

NameName
Last commit message
Last commit date

Latest commit

570810a · Jan 4, 2018

History

30 Commits
Oct 7, 2017
Oct 7, 2017
Oct 7, 2017
Oct 7, 2017
Sep 30, 2017
Sep 29, 2017
Sep 29, 2017
Jan 4, 2018
Oct 7, 2017
Oct 7, 2017
Oct 7, 2017

Repository files navigation

Build Status Coverage Status npm

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

setTimeout(myMethod, 86400000); // Nobody will have any idea how long this is

Better

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⭐

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

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