Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

humanized-interval

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

humanized-interval

Human readable time measurements

  • 0.1.7
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2
Maintainers
1
Weekly downloads
 
Created
Source

Humanized Interval

Human readable interval parser and human-readable generator for Node.js/the Browser.

Merged and wrapped rschmukler/human-interval and EvanHahn/HumanizeDuration.js into a single utility.

Heavily inspired by matthewmueller/date.

Example Usage

var humanizedInterval = require('humanized-interval');

setTimeout(function() {
  // Do something crazy!
}, humanizedInterval('three minutes'));

More sophisticated examples

humanizedInterval understands all of the following examples:

humanizedInterval('one minute'); // 60000
humanizedInterval('1.5 minutes'); // 90000
humanizedInterval('3 days and 4 hours'); // 273600000
humanizedInterval('3 days, 4 hours and 36 seconds'); // 273636000

humanizedInterval(50000); // "5 seconds"
humanizedInterval(90000); // "1.5 minutes"

The full list

Supported Units

Humanized Interval supports the following units

  • seconds
  • minutes
  • hours
  • days
  • weeks
  • months -- assumes 30 days
  • years -- assumes 365 days

Wordy Numbers

Humanized Interval supports numbers up to ten being written out in English. If you want to extend it, you can do so by adding more keys to the language map. Alternatively you could add support for alternative languages.

var humanizedInterval = require('humanized-interval');
humanizedInterval.languageMap['one-hundred'] = 100

// Adds support for the following:
humanizedInterval('one-hundred and fifty seconds') // returns 150000

Keywords

FAQs

Package last updated on 18 Aug 2015

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc