How vercel/ms works
This is a small, dependency-free time conversion utility. Its principal workflow accepts a string or number through ms, dispatches strings to parsing and numbers to formatting, and returns milliseconds or a unit string. The README also documents direct parse, parseStrict, and format entry points, plus typed string inputs. The sampled source is the complete runtime implementation, so the internal conversion and formatting steps are visible.
Main entry points: index.ts Formatter
Components 9
Public API
- ms dispatcher
src/index.ts - Strict parser
src/index.ts
Conversion Logic
- String parser
src/index.ts - Unit conversion
src/index.ts - Formatter
src/index.ts - Short format
src/index.ts - Long format
src/index.ts
Other components
- Caller
- Converted value
Connections 14
- Caller → ms dispatcher: calls
- Caller → String parser: calls
- Caller → Strict parser: calls
- Caller → Formatter: calls
- ms dispatcher → String parser: dispatches strings
- ms dispatcher → Formatter: dispatches numbers
- String parser → Unit conversion: converts units
- Strict parser → String parser: delegates parsing
- Formatter → Short format: selects default
- Formatter → Long format: selects long
- ms dispatcher → Converted value: returns value
- String parser → Converted value: returns milliseconds
- Strict parser → Converted value: returns milliseconds
- Formatter → Converted value: returns string