New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

hrn

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

hrn

hrn is short for human-readable number, a simple javascript library to format number into human-readable string.

latest
Source
npmnpm
Version
1.0.1
Version published
Weekly downloads
40
-79.17%
Maintainers
1
Weekly downloads
 
Created
Source

hrn

hrn is short for Human Readable Number, a simple javascript for browserjs / nodejs library to format number into human-readable string.

Build Status npm npm npm

1. Install

npm install --save hrn

2. Import It

var hrn = require('hrn');

//or

import hrn from 'hrn';

3. Usage & API

There is only one API named hrn(number, fixed, formatter).

hrn(1234000);                   // '1.2 M'
hrn(1234000, 3);                // '1.234 M'
hrn(1234000, 3, 'en');          // '1.234 M'
hrn(12340, 2, 'zh_CN');         // '1.23 万', `en` / `zh_CN` supported, `en` is default.

You can customize the number formatter.

// format number
var formatter = ['kmgtpezy'.split(''), 1e3];
hrn('1234000', 1, formatter)    // '1.2 m'


// format time diff
formatter = [['s', 'm', 'h', 'd'], [1, 60, 60, 24]];
hrn(23, 1, formatter);					// '23.0 s' -> 23 seconds
hrn(23 * 60, 1, formatter);				// '23.0 m' -> 23 minutes
hrn(23 * 60 * 60, 1, formatter);		// '23.0 h' -> 23 hours
hrn(23 * 60 * 60 * 24, 1, formatter); 	// '23.0 d' -> 23 days

4. Test

npm install

npm test

5. LICENSE

MIT@hustcc

Keywords

hrn

FAQs

Package last updated on 02 Mar 2018

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