Question
How is the function exported? Is it a default export or a named one?
About sindresorhus/escape-string-regexp · 2 messages · last activity 5/18/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 the TypeScript declaration file [index.d.ts:L16-L17]:
export default function escapeStringRegexp(string: string): string;
And in the implementation [index.js:L1], the function is also exported as default:
export default function escapeStringRegexp(string) {
This is further confirmed in [package.json:L13], which specifies:
"exports": "./index.js",
When you import it, you use the default import syntax:
import escapeStringRegexp from 'escape-string-regexp';
FOLLOW_UPS:
Want to ask your own question?
Open chat for sindresorhus/escape-string-regexp →Public 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.