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/1/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 [index.js:L1] where the function is defined with export default function escapeStringRegexp(string), and in [index.d.ts:L16-L17] where the TypeScript type definition also declares export default function escapeStringRegexp(string: string): string;.

This is further confirmed in the usage example in [readme.md:L16-L17], which shows importing it as:

import escapeStringRegexp from 'escape-string-regexp';

This default import syntax is the standard way to import a default export in ES modules.

FOLLOW_UPS:

  • What characters does the function escape?
  • Why does the function escape hyphens differently?
  • How can the escaped string be used safely?

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.