0.0.1 • Published 3 months ago
@sglara/ms-parser v0.0.1
ms-parser
A lightweight TypeScript package for parsing time durations into milliseconds.
Installation
npm install ms-parser
# or
yarn add ms-parser
# or
pnpm add ms-parser
Usage
import { ms } from "ms-parser";
// Parse single durations
ms("1m"); // 60000
ms("1.5h"); // 5400000
// Parse combined durations
ms("1h30m"); // 5400000
ms("2m15s"); // 135000
// Invalid input returns NaN
ms("abc"); // NaN
Supported Units
ms
- millisecondss
- secondsm
- minutesh
- hoursd
- days
Features
- TypeScript support
- Zero dependencies
- Handles decimal values
- Supports combined durations
- Returns NaN for invalid input
License
MIT
0.0.1
3 months ago