Socket
Socket
Sign inDemoInstall

@types/ms

Package Overview
Dependencies
0
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @types/ms

TypeScript definitions for ms


Version published
Weekly downloads
7.2M
decreased by-16.79%
Maintainers
1
Install size
3.13 kB
Created
Weekly downloads
 

Package description

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

Readme

Source

Installation

npm install --save @types/ms

Summary

This package contains type definitions for ms (https://github.com/zeit/ms).

Details

Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/ms.

index.d.ts

/**
 * Short/Long format for `value`.
 *
 * @param {Number} value
 * @param {{long: boolean}} options
 * @return {String}
 */
declare function ms(value: number, options?: { long: boolean }): string;

/**
 * Parse the given `value` and return milliseconds.
 *
 * @param {String} value
 * @return {Number}
 */
declare function ms(value: string): number;

export = ms;

Additional Details

  • Last updated: Tue, 07 Nov 2023 09:09:39 GMT
  • Dependencies: none

Credits

These definitions were written by Zhiyuan Wang.

FAQs

Last updated on 07 Nov 2023

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