How is the function exported? Is it a default export or a named one?
How is the function exported? Is it a default export or a named one?
About sindresorhus/escape-string-regexp · 2 messages · last activity 5/25/2026
The function is exported as a default export.
This is evident in two places:
-
In the TypeScript definition [index.d.ts:L16], the function is declared as:
export default function escapeStringRegexp(string: string): string; -
In the JavaScript implementation [index.js:L1], it's implemented as:
export default function escapeStringRegexp(string) { -
In the package.json configuration [package.json:L7], the exports field specifies:
"exports": "./index.js",
This means when you import the function, you use the default import syntax: import escapeStringRegexp from 'escape-string-regexp'; (as shown in the usage example in [readme.md:L17]).
FOLLOW_UPS:
- What characters does the function escape?
- How does the function handle the hyphen character differently?
- What type checking does the function perform?
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.