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/6/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 two places:

  1. [index.js:L1] — The function definition uses export default:

    export default function escapeStringRegexp(string) {
    
  2. [index.d.ts:L16] — The TypeScript declaration also declares it as a default export:

    export default function escapeStringRegexp(string: string): string;
    
  3. [package.json:L6] — The exports field confirms this:

    "exports": "./index.js",
    

This means you import it like:

import escapeStringRegexp from 'escape-string-regexp';

rather than as a named import like import { escapeStringRegexp }.

FOLLOW_UPS:

  • What characters does the function escape?
  • How does the function handle the hyphen character?
  • What is the minimum Node.js version required?

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.