@hyperfrontend/immutable-api-utils/built-in-copy/regexp

regexp

Locked, prototype-pollution-resistant copy of the global RegExp constructor.

The RegExp constructor is wrapped in a createRegExp factory at module-load time and frozen into a tamper-proof namespace, so pattern construction keeps working even if the global RegExp is later patched. Effective only when imported before any untrusted code has had a chance to mutate the prototype chain.

API Reference§

ƒ Functions

§function

createRegExp(pattern: string | RegExp, flags?: string): RegExp

(Safe copy) Creates a new RegExp using the captured RegExp constructor. Use this instead of new RegExp().
Parameters
NameTypeDescription
§pattern
string | RegExpThe pattern string or RegExp to copy.
§flags?
stringOptional flags string.
Returns
RegExp
A new RegExp instance.

● Variables

§type

RegExp

(Safe copy) Namespace object containing RegExp factory. Note: Importing this imports all methods in this namespace (no tree-shaking).