RepoPilot

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

About sindresorhus/escape-string-regexp · 2 messages · last activity 6/15/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.

You can see this in both the TypeScript definition and the JavaScript implementation:

  • [index.d.ts:L16] shows export default function escapeStringRegexp(string: string): string;
  • [index.js:L1] shows export default function escapeStringRegexp(string) {

This is also confirmed in [package.json:L7], which specifies "exports": "./index.js", and the usage example in [readme.md:L16] demonstrates importing it as a default export: import escapeStringRegexp from 'escape-string-regexp';

FOLLOW_UPS:

  • What characters does the function escape?
  • How does it handle the hyphen character differently?
  • What error does the function throw for invalid input?

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.