RepoPilot

How is the function exported? Is it a default export or a named one?

About sindresorhus/escape-string-regexp · 2 messages · last activity 7/27/2026

Question

How is the function exported? Is it a default export or a named one?

RepoPilot

The function is exported as a default export.

In the implementation:

export default function escapeStringRegexp(string) {
	...
}

[index.js:L1-L12]

This matches the TypeScript declaration:

export default function escapeStringRegexp(string: string): string;

[index.d.ts:L16-L17]

And it's consistently imported that way throughout the repo, e.g.:

  • import escapeStringRegexp from 'escape-string-regexp'; in the README usage example [readme.md:L14-L28]
  • import escapeStringRegexp from './index.js'; in the test-d type test [index.test-d.ts:L1-L5]
  • import escapeStringRegexp from './index.js'; in the AVA test suite [test.js:L1-L2]

The package.json also confirms the module setup that makes this default export accessible via a simple import — it's declared as an ES module ("type": "module") with "exports": "./index.js" [package.json:L14-L15].

FOLLOW_UPS:

  • What characters does the function actually escape?
  • Why is - escaped differently with \x2d?
  • What does the CI workflow test across Node versions?

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.