Question
How is the function exported? Is it a default export or a named one?
About sindresorhus/escape-string-regexp · 2 messages · last activity 6/29/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 [index.js:L1], where the function is defined as:
export default function escapeStringRegexp(string) {
This is also confirmed in the TypeScript definitions at [index.d.ts:L16-L17]:
export default function escapeStringRegexp(string: string): string;
And in the package.json configuration at [package.json:L11], the exports field points to the main file:
"exports": "./index.js",
The usage examples in the README at [readme.md:L16-L17] also demonstrate this default export pattern:
import escapeStringRegexp from 'escape-string-regexp';
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.