Socket
Socket
Sign inDemoInstall

format-ms

Package Overview
Dependencies
0
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    format-ms

Format milliseconds into a human readable message by converting units


Version published
Weekly downloads
55
increased by1733.33%
Maintainers
1
Install size
5.73 kB
Created
Weekly downloads
 

Readme

Source

Format Milliseconds

A utility function for converting milliseconds into a human readable message.

const { formatMilliseconds, parseMilliseconds } = require('format-ms')

console.log(formatMilliseconds(1000000))
// output: '16m 40s'

console.log(formatMilliseconds(-445500))
// output: '7m 25s 500ms ago'

console.log(formatMilliseconds(961000, { units: 'long' }))
// output: '16 minutes 1 second'

console.log(formatMilliseconds(-445500, { largestOnly: true }))
// output: '7m ago'

console.log(formatMilliseconds(445500, { ignore: [ 'millisecond' ] }))
// output: '7m 25s'

console.log(parseMilliseconds(987654321000))
// output: {
//   years: 31,
//   weeks: 21,
//   days: 0,
//   hours: 4,
//   minutes: 25,
//   seconds: 21,
//   milliseconds: 0 }

Keywords

FAQs

Last updated on 21 Feb 2019

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc