
Security News
Axios Maintainer Confirms Social Engineering Attack Behind npm Compromise
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.
Convert between time units using human-readable syntax. Similar to TimeUnit in Java.
Unitime is a lightweight JavaScript utility module which provides powerful, human-readable functions for converting various time units. The project was inspired by Java's TimeUnit by Doug Lea.
const { h, ms } = require("unitime");
h`720`.days(); // evaluates to 7
ms`3`.nanos(); // evaluates to 3000000
npm install unitime
Unitime provides lightweight methods for converting between different units of time with a human-readable syntax. The idea is reducing the mental load caused by interpreting complex time declarations like 24*60*60*1000 or 86400000 which both describe the number of milliseconds in a single day. Using this library you can simply write d(1), or d`1` if you prefer template literals.
Time formats that are currently supported are:
You can specify the target format on initialization to make the code even more concise. This is especially useful when writing configuration files in JavaScript:
const { d, h } = require("unitime").to("ms")
const config = {
duration: d`7`, // evaluates to 604800000
interval: h`12` // evaluates to 43200000
}
The library is written entirely in Typescript.
You can predefine the target unit by using .to(unit) when initializing:
const { ns, s } = require("unitime").to("ms")
ns`100`; // 0.0001
s(1000); // 1000000
You can also individually decide the target unit for each variable:
const { ns, s } = require("unitime")
ns`100`.millis(); // 0.0001
s(100).minutes(); // 1.6666666666666667
This work by Jonatan Hamberg is licensed under the MIT License.
FAQs
Convert between time units using human-readable syntax. Similar to TimeUnit in Java.
We found that unitime demonstrated a not healthy version release cadence and project activity because the last version was released 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
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.

Security News
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.