RepoPilot

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

Question

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

RepoPilot

The function is exported as a default export.

This is evident in two places:

  1. In the TypeScript definition [index.d.ts:L16], the function is declared as:

    export default function escapeStringRegexp(string: string): string;
    
  2. In the JavaScript implementation [index.js:L1], it's implemented as:

    export default function escapeStringRegexp(string) {
    
  3. 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?

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.