parse-ms-time
v1.0.1
Published
Ultra-fast parser to convert time strings (ms, s, m, h, d, y) into milliseconds.
Downloads
28
Maintainers
Readme
parse-ms-time
Why use parse-ms-time? Setting durations in code (like timeouts, TTLs) using raw millisecond integers makes code hard to read. Writing durations as text strings requires a robust parser.
An ultra-fast parser to convert time strings (ms, s, m, h, d, y) into millisecond integers, supporting fraction inputs.
⚡ Features
- Supports standard time suffixes (ms, s, m, h, d, y)
- Handles floating point inputs (e.g. 1.5h)
- Zero dependencies, fast regex execution
📦 Installation
npm i parse-ms-time🚀 Usage
import { parseMs } from 'parse-ms-time';
console.log(parseMs('2d')); // 172800000
console.log(parseMs('1.5h')); // 5400000
console.log(parseMs('45m')); // 2700000⚙️ API Reference
parseMs(str)
- Returns millisecond integer.
📺 Demonstration

📄 License
MIT License.
