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/20/2026
How is the function exported? Is it a default export or a named one?
The function is exported as a default export.
In index.js:L1, the function is declared directly with export default function escapeStringRegexp(string) {...}, making it the module's default export.
This is confirmed in several other places:
export default function escapeStringRegexp(string: string): string; [index.d.ts:L16-L17]import escapeStringRegexp from 'escape-string-regexp'; (seen in the README usage section, [readme.md:L14-L23], and in the test files [test.js:L1-L2] and [index.test-d.ts:L1-L2])package.json exports field points to ./index.js [package.json:L14], which is the module containing that default export.So there's no named export — consumers always import it as the default, e.g. import escapeStringRegexp from 'escape-string-regexp'.
FOLLOW_UPS:
- escaped differently than other characters?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.