Question
How is the function exported? Is it a default export or a named one?
About sindresorhus/escape-string-regexp · 2 messages · last activity 9/1/2026
How is the function exported? Is it a default export or a named one?
The function is a default export.
In [index.js:L1-L10], the module declares:
export default function escapeStringRegexp(string) {
This is confirmed in a few other places:
package.json sets "exports": "./index.js" [package.json:L1-L40], and since "type": "module" is set, this is loaded as an ES module.export default function escapeStringRegexp(string: string): string; [index.d.ts:L16-L17].import escapeStringRegexp from './index.js'; [test.js:L2] and import escapeStringRegexp from './index.js'; [index.test-d.ts:L2], as well as in the README example import escapeStringRegexp from 'escape-string-regexp'; [readme.md:L16].There is no named export alongside it — the single function is the module's only export, and consumers must import it as the default.
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.