Socket
Socket
Sign inDemoInstall

@types/ms

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@types/ms

TypeScript definitions for ms


Version published
Weekly downloads
9.7M
decreased by-0.67%
Maintainers
1
Weekly downloads
 
Created

What is @types/ms?

The @types/ms package provides TypeScript type definitions for the ms package, which is a utility to easily convert various time formats to milliseconds and vice versa. It's particularly useful when working with time-related operations in Node.js applications. By using @types/ms, developers can get autocomplete and type checking functionalities for the ms package in TypeScript projects, enhancing development efficiency and reducing runtime errors.

What are @types/ms's main functionalities?

Convert time format to milliseconds

This feature allows you to convert human-readable time formats (like '2 days', '1h', or '10 hours') into milliseconds. It's particularly useful for setting timeouts, intervals, or calculating time differences in applications.

"import ms from 'ms';\nconsole.log(ms('2 days')); // 172800000\nconsole.log(ms('1h')); // 3600000\nconsole.log(ms('10 hours')); // 36000000"

Convert milliseconds to time format

This feature enables the conversion of milliseconds into a more human-readable time format. It supports both short and long formats, and can also handle negative values, which can be useful for displaying countdowns or elapsed time.

"import ms from 'ms';\nconsole.log(ms(60000, { long: true })); // '1 minute'\nconsole.log(ms(2 * 60000)); // '2m'\nconsole.log(ms(-3 * 60000, { long: true })); // '-3 minutes'"

Other packages similar to @types/ms

FAQs

Package last updated on 04 Sep 2019

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