# sindresorhus/escape-string-regexp architecture

> Architecture diagram of the GitHub repository sindresorhus/escape-string-regexp, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-21). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/sindresorhus/escape-string-regexp
- Repository: https://github.com/sindresorhus/escape-string-regexp

## Overview

This is a small JavaScript utility library: callers pass a string to the exported function, which rejects non-strings and escapes RegExp metacharacters and hyphens before returning the result. The README also describes embedding escaped output in a RegExp or character class. The graph stays focused on that runtime behavior; it does not map tests or packaging. Source evidence is limited to the README and the sampled implementation and declaration.

Main entry points: [`index.js`](https://github.com/sindresorhus/escape-string-regexp/blob/main/index.js) (Escape string)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Runtime utility"]
  node_escape["Escape string<br/>[index.js]"]
end

node_caller(("Library caller"))
node_regex["RegExp construction"]

node_caller -->|"passes string"| node_escape
node_escape -->|"returns escaped text"| node_regex

click node_escape "https://github.com/sindresorhus/escape-string-regexp/blob/main/index.js"

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_escape toneBlue
class node_caller,node_regex toneIndigo
```

## Components

### Runtime utility

- [Escape string](https://github.com/sindresorhus/escape-string-regexp/blob/main/index.js): `index.js`

### Other components

- **Library caller**
- **RegExp construction**

## Connections

- Library caller → Escape string: passes string (evidence: `readme.md`)
- Escape string → RegExp construction: returns escaped text (evidence: `readme.md`)
