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

function

Locked, prototype-pollution-resistant copy of the global Function constructor and its prototype helpers.

The Function constructor is wrapped in a createFunction factory and Function.prototype.call, apply, and bind are captured at module-load time and frozen into a tamper-proof namespace, so reflective invocation keeps working even if the global Function is later patched. Effective only when imported before any untrusted code has had a chance to mutate the prototype chain.

API Reference

ƒ Functions

§function

createFunction(...args: string[]): (args: unknown[]) => unknown

(Safe copy) Creates a new Function using the captured Function constructor. Use this instead of new Function().
NOTE: Dynamic code generation via Function constructor should be avoided when possible due to security risks similar to eval().

Parameters

NameTypeDescription
§...args
string[]
Function body and parameter strings.

Returns

(args: unknown[]) => unknown
A new Function.

Variables

§type

Function

(Safe copy) Namespace object containing Function utilities. Note: Importing this imports all methods in this namespace (no tree-shaking).
§type

functionApply

(Safe copy) Reference to the captured Function.prototype.apply.
§type

functionBind

(Safe copy) Reference to the captured Function.prototype.bind.
§type

functionCall

(Safe copy) Reference to the captured Function.prototype.call.
§type

functionPrototype

(Safe copy) Reference to the captured Function.prototype.