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

ms-extended

Package Overview
Dependencies
Maintainers
0
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ms-extended

Milliseconds utility library extended with non-millisecond utilities

latest
Source
npmnpm
Version
0.1.5
Version published
Maintainers
0
Created
Source

ms-extended

An extension of the ms package that adds support for seconds, minutes, and hours conversions.

Installation

npm install ms-extended

Usage

import { sec, min, hr } from 'ms-extended'

// Convert to seconds
sec('1m')      // 60
sec('2h')      // 7200
sec('1 day')   // 86400

// Convert to minutes
min('1h')      // 60
min('2 days')  // 2880
min('30s')     // 0.5

// Convert to hours
hr('1 day')    // 24
hr('30m')      // 0.5
hr('2h')       // 2

Features

  • Built on top of the popular ms package
  • TypeScript support with strict types
  • Converts time strings to seconds, minutes, or hours
  • Supports all time formats from the ms package
  • Zero dependencies (besides ms)

TypeScript Support

This package includes TypeScript definitions and uses Template Literal Types for type safety:

import { sec, StringValue } from 'ms-extended'

function example(value: StringValue) {
  return sec(value)
}

// Valid
example('1h')        // Works
example('2.5 days')  // Works

// Invalid
example('invalid')   // TypeScript error

License

MIT

Contributing

  • Fork this repository
  • Create your feature branch (git checkout -b feature/amazing-feature)
  • Commit your changes (git commit -m 'Add amazing feature')
  • Push to the branch (git push origin feature/amazing-feature)
  • Open a Pull Request

FAQs

Package last updated on 01 Feb 2025

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