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/18/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 the TypeScript declaration file [index.d.ts:L16-L17]:

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

And in the implementation [index.js:L1], the function is also exported as default:

export default function escapeStringRegexp(string) {

This is further confirmed in [package.json:L13], which specifies:

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

When you import it, you use the default import syntax:

import escapeStringRegexp from 'escape-string-regexp';

FOLLOW_UPS:

  • What characters does the function escape?
  • How does it handle the hyphen character differently?
  • What are the function's parameter and return types?

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.