Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
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 parse-ms
import parseMilliseconds from 'parse-ms';
parseMilliseconds(1337000001);
/*
{
days: 15,
hours: 11,
minutes: 23,
seconds: 20,
milliseconds: 1,
microseconds: 0,
nanoseconds: 0
}
*/
parseMilliseconds(1337000001n);
/*
{
days: 15n,
hours: 11n,
minutes: 23n,
seconds: 20n,
milliseconds: 1n,
microseconds: 0n,
nanoseconds: 0n
}
*/
FAQs
Parse milliseconds into an object
The npm package parse-ms receives a total of 5,215,512 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.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.