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

ms-typescript

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

ms-typescript

Tiny millisecond conversion utility. Original package was developed by Vercel. This is reworked TypeScript version

latest
Source
npmnpm
Version
2.0.0
Version published
Weekly downloads
7.2K
-20.08%
Maintainers
1
Weekly downloads
 
Created
Source

ms

Use this package to easily convert various time formats to milliseconds.

Examples

toMs('2 days')  // 172800000
toMs('1d')      // 86400000
toMs('10h')     // 36000000
toMs('2.5 hrs') // 9000000
toMs('2h')      // 7200000
toMs('1m')      // 60000
toMs('5s')      // 5000
toMs('1y')      // 31557600000
toMs('100')     // 100
toMs('-3 days') // -259200000
toMs('-1h')     // -3600000
toMs('-200')    // -200

Convert from Milliseconds

fromMs(60000)             // "1m"
fromMs(2 * 60000)         // "2m"
fromMs(-3 * 60000)        // "-3m"
fromMs(toMs('10 hours'))    // "10h"

Time Format Written-Out

fromMs(60000, { long: true })             // "1 minute"
fromMs(2 * 60000, { long: true })         // "2 minutes"
fromMs(-3 * 60000, { long: true })        // "-3 minutes"
fromMs(toMs('10 hours'), { long: true })    // "10 hours"

Features

  • Works both in Node.js and in the browser
  • Provides functions to convert from milliseconds and to milliseconds
  • If you pass a string with a number and a valid unit, the number of equivalent milliseconds is returned
  • TypeScript
  • ES6 import supported

Keywords

time

FAQs

Package last updated on 30 Jun 2021

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