# vercel/ms architecture

> Architecture diagram of the GitHub repository vercel/ms, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/vercel/ms
- Repository: https://github.com/vercel/ms

## Overview

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: [`src/index.ts`](https://github.com/vercel/ms/blob/main/src/index.ts) (Formatter)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["Public API"]
  node_ms["ms dispatcher<br/>[index.ts]"]
  node_strict["Strict parser<br/>[index.ts]"]
end

subgraph group_conversion["Conversion Logic"]
  node_parse["String parser<br/>[index.ts]"]
  node_units["Unit conversion<br/>[index.ts]"]
  node_format["Formatter<br/>[index.ts]"]
  node_short["Short format<br/>[index.ts]"]
  node_long["Long format<br/>[index.ts]"]
end

node_consumer(("Caller"))
node_result(("Converted value"))

node_consumer -->|"calls"| node_ms
node_consumer -->|"calls"| node_parse
node_consumer -->|"calls"| node_strict
node_consumer -->|"calls"| node_format
node_ms -->|"dispatches strings"| node_parse
node_ms -->|"dispatches numbers"| node_format
node_parse -->|"converts units"| node_units
node_strict -->|"delegates parsing"| node_parse
node_format -->|"selects default"| node_short
node_format -->|"selects long"| node_long
node_ms -->|"returns value"| node_result
node_parse -->|"returns milliseconds"| node_result
node_strict -->|"returns milliseconds"| node_result
node_format -->|"returns string"| node_result

click node_ms "https://github.com/vercel/ms/blob/main/src/index.ts"
click node_parse "https://github.com/vercel/ms/blob/main/src/index.ts"
click node_units "https://github.com/vercel/ms/blob/main/src/index.ts"
click node_strict "https://github.com/vercel/ms/blob/main/src/index.ts"
click node_format "https://github.com/vercel/ms/blob/main/src/index.ts"
click node_short "https://github.com/vercel/ms/blob/main/src/index.ts"
click node_long "https://github.com/vercel/ms/blob/main/src/index.ts"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_ms,node_strict toneBlue
class node_parse,node_units,node_format,node_short,node_long toneAmber
class node_consumer,node_result toneIndigo
```

## Components

### Public API

- [ms dispatcher](https://github.com/vercel/ms/blob/main/src/index.ts): `src/index.ts`
- [Strict parser](https://github.com/vercel/ms/blob/main/src/index.ts): `src/index.ts`

### Conversion Logic

- [String parser](https://github.com/vercel/ms/blob/main/src/index.ts): `src/index.ts`
- [Unit conversion](https://github.com/vercel/ms/blob/main/src/index.ts): `src/index.ts`
- [Formatter](https://github.com/vercel/ms/blob/main/src/index.ts): `src/index.ts`
- [Short format](https://github.com/vercel/ms/blob/main/src/index.ts): `src/index.ts`
- [Long format](https://github.com/vercel/ms/blob/main/src/index.ts): `src/index.ts`

### Other components

- **Caller**
- **Converted value**

## Connections

- 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
