Question
How is the function exported? Is it a default export or a named one?
About sindresorhus/escape-string-regexp · 2 messages · last activity 7/6/2026
How is the function exported? Is it a default export or a named one?
The function is exported as a default export.
You can see this in two places:
[index.js:L1] — The function definition uses export default:
export default function escapeStringRegexp(string) {
[index.d.ts:L16] — The TypeScript declaration also declares it as a default export:
export default function escapeStringRegexp(string: string): string;
[package.json:L6] — The exports field confirms this:
"exports": "./index.js",
This means you import it like:
import escapeStringRegexp from 'escape-string-regexp';
rather than as a named import like import { escapeStringRegexp }.
FOLLOW_UPS:
Want to ask your own question?
Open chat for sindresorhus/escape-string-regexpPublic Q&A. Generated by RepoPilot from the actual source of sindresorhus/escape-string-regexp. AI answers can be incomplete or stale — verify before relying on them.