unduration

unduration is a tiny (0.2kb) library that aims to standardize the way we handle durations in JavaScript, aiming to replace things like:
defineHandler('/', {
ttl: 1000 * 60 * 60 * 24,
ttl: 86_400_000
})
With:
defineHandler('/', {
ttl: '1m',
ttl: {
minutes: 1,
}
})
Libraries tend to use different formats for durations, which makes it hard to use them together. unduration aims to solve this problem by providing a standard way to define durations, and utilities to use this standard.
Usage
Install package:
npm install unduration
yarn add unduration
pnpm install unduration
bun install unduration
Import:
import { defineDuration } from "unduration";
const { defineDuration } = require("unduration");
Development
- Clone this repository
- Install latest LTS version of Node.js
- Enable Corepack using
corepack enable
- Install dependencies using
pnpm install
- Run interactive tests using
pnpm dev
License
Made with 💛
Published under MIT License.