🚀 Socket Launch Week Day 5:Introducing Repository Access Permissions and Custom Roles.Learn more
Sign In

humanizer

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

humanizer

Humanize a value.

latest
Source
npmnpm
Version
0.1.1
Version published
Weekly downloads
164
-51.34%
Maintainers
1
Weekly downloads
 
Created
Source

Humanizer Build Status

Humanizer a value. Humanizer provides "ago" libraries-like capabilities and so on... In fact, unlike other libraries, humanizer can work with any type of unit at any scale.

Humanizer is tested against browsers and NodeJS.

npm install humanizer
var Humanizer = require('humanizer');

// Define the time unit
time = new Humanizer('ms', 1) // the base unit is 1 `ms`
   .unit('day',  24*3600*1000)
   .unit('hour', 3600*1000)
   .unit('min',  60*1000)
   .unit('sec',  1000)
   .setRound(function roundFn(val){ // set a (optional) round function
    return Math.round(val*10)/10;
  });

// time.humanize(value, [preferedUnit]);
time.humanize(60*1000); // [60, 'sec']
time.humanize(20*3600*1000); // [20, 'hour']
time.humanize(20*3600*1000, 'sec'); // [20, 'sec'] (feels more like a conversion to me though)

// time.humanizeRange(value, start, end, [preferedUnit]);
time.humanizeRange(4956, +new Date(2013, 3, 29), +new Date(2013, 3, 29, 15, 47)));
// -> [314, 'hour']
// -> 314 'things' by `hour`

Keywords

humanize

FAQs

Package last updated on 29 Apr 2013

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts