Security News
JavaScript Leaders Demand Oracle Release the JavaScript Trademark
In an open letter, JavaScript community leaders urge Oracle to give up the JavaScript trademark, arguing that it has been effectively abandoned through nonuse.
The parse-ms npm package is a utility for parsing milliseconds into an object with more readable time properties such as days, hours, minutes, and seconds. It is useful for converting a duration in milliseconds into a more human-readable format.
Parse milliseconds into an object
This feature allows you to convert a duration in milliseconds into an object with properties for days, hours, minutes, seconds, milliseconds, microseconds, and nanoseconds.
const parseMs = require('parse-ms');
const result = parseMs(1337000000);
console.log(result); // { days: 15, hours: 11, minutes: 23, seconds: 20, milliseconds: 0, microseconds: 0, nanoseconds: 0 }
Handle large durations
This feature demonstrates the ability to handle and accurately parse large durations, breaking them down into their respective time units.
const parseMs = require('parse-ms');
const result = parseMs(9876543210);
console.log(result); // { days: 114, hours: 1, minutes: 29, seconds: 3, milliseconds: 210, microseconds: 0, nanoseconds: 0 }
The 'ms' package is a utility for converting various time formats to milliseconds and vice versa. Unlike parse-ms, which focuses on breaking down milliseconds into an object with time properties, 'ms' can convert human-readable time formats (like '2 days', '1h', '5m') into milliseconds and back. It is more versatile in terms of input formats but does not provide the detailed breakdown that parse-ms does.
The 'pretty-ms' package is designed to convert milliseconds into a human-readable string format. It is similar to parse-ms in that it deals with milliseconds, but instead of returning an object, it returns a formatted string (e.g., '1d 3h 4m 5s'). It is useful for displaying durations in a user-friendly way but does not provide the detailed object breakdown that parse-ms offers.
Parse milliseconds into an object
$ npm install --save parse-ms
parseMs(1337000001);
//=> { days: 15, hours: 11, minutes: 23, seconds: 20, milliseconds: 1 }
MIT © Sindre Sorhus
FAQs
Parse milliseconds into an object
The npm package parse-ms receives a total of 4,728,074 weekly downloads. As such, parse-ms popularity was classified as popular.
We found that parse-ms demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
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.
Security News
In an open letter, JavaScript community leaders urge Oracle to give up the JavaScript trademark, arguing that it has been effectively abandoned through nonuse.
Security News
The initial version of the Socket Python SDK is now on PyPI, enabling developers to more easily interact with the Socket REST API in Python projects.
Security News
Floating dependency ranges in npm can introduce instability and security risks into your project by allowing unverified or incompatible versions to be installed automatically, leading to unpredictable behavior and potential conflicts.