
Security News
/Research
Wallet-Draining npm Package Impersonates Nodemailer to Hijack Crypto Transactions
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
human-interval
Advanced tools
The human-interval npm package allows you to parse human-readable time intervals into milliseconds. This can be useful for setting timeouts, scheduling tasks, or any other scenario where you need to convert a human-friendly time format into a machine-readable one.
Parse human-readable intervals
This feature allows you to convert a human-readable time interval (e.g., '3 minutes and 30 seconds') into milliseconds. This is useful for applications that need to work with precise time intervals but want to allow users to input times in a more natural format.
const humanInterval = require('human-interval');
const milliseconds = humanInterval('3 minutes and 30 seconds');
console.log(milliseconds); // 210000
Support for various time units
The package supports a wide range of time units including seconds, minutes, hours, days, weeks, months, and years. This allows for flexible and comprehensive time interval parsing.
const humanInterval = require('human-interval');
const milliseconds = humanInterval('2 days, 4 hours, and 20 minutes');
console.log(milliseconds); // 187200000
Combining multiple intervals
You can combine multiple time intervals in a single string, and the package will correctly parse the total time in milliseconds. This is useful for more complex scheduling needs.
const humanInterval = require('human-interval');
const milliseconds = humanInterval('1 hour and 45 minutes');
console.log(milliseconds); // 6300000
The 'ms' package is a simple utility for converting various time formats to milliseconds. It supports a more limited set of time units compared to human-interval but is very lightweight and easy to use. It is ideal for simpler use cases where you don't need the full range of time units supported by human-interval.
The 'parse-duration' package is another utility for parsing human-readable time durations into milliseconds. It supports a wide range of time units and is similar in functionality to human-interval. However, it also includes additional features like parsing negative durations and handling edge cases more gracefully.
The 'moment-duration-format' package extends the Moment.js library to support formatting and parsing of durations. While it offers more advanced formatting options compared to human-interval, it requires Moment.js as a dependency, which can add to the package size.
Human-readable interval parser for Javascript.
Converts words written in English to numbers by using node-numbered.
Originally inspired by matthewmueller/date.
Human Interval is used by job scheduling libraries such as Agenda and Bree. They are a job schedulers for Node.js with cron expression syntax, human-friendly times, Dates, and more!
const humanInterval = require('human-interval');
setTimeout(() => {
// Do something!
}, humanInterval('three minutes'));
Human Interval understands all of the following examples:
humanInterval('minute');
humanInterval('one minute');
humanInterval('1.5 minutes');
humanInterval('3 days and 4 hours');
humanInterval('3 days, 4 hours and 36 seconds');
humanInterval('4 months, 3 days, 5 hours and forty-five seconds');
Supports the following units in the plural and singular forms:
seconds
minutes
hours
days
weeks
months
— assumes 30 daysyears
— assumes 365 daysSupports numbers being written out in English words.
humanInterval('five minutes');
Supports hyphenated numbers.
humanInterval('twenty-five seconds');
Supports negative numbers if the time starts with a -
symbol immediately followed by a number.
humanInterval('-2 minutes');
FAQs
Human readable time measurements
The npm package human-interval receives a total of 101,799 weekly downloads. As such, human-interval popularity was classified as popular.
We found that human-interval demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers 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
/Research
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
Security News
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.
Security News
/Research
Malicious Nx npm versions stole secrets and wallet info using AI CLI tools; Socket’s AI scanner detected the supply chain attack and flagged the malware.