-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunction.ts
More file actions
27 lines (25 loc) · 1.01 KB
/
function.ts
File metadata and controls
27 lines (25 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
/**
* @file Safe references to `Function.prototype` methods. `apply`, `bind`,
* `call`, `toString` — used by reflection-heavy code paths (logger sinks,
* lazy bindings, debug formatters) where calling the global builtin without a
* captured reference would expose to prototype tampering.
*/
import { uncurryThis } from './uncurry'
export const FunctionPrototypeApply = uncurryThis(Function.prototype.apply) as (
self: (...args: unknown[]) => unknown,
thisArg: unknown,
args: unknown[],
) => unknown
export const FunctionPrototypeBind = uncurryThis(Function.prototype.bind) as (
self: (...args: unknown[]) => unknown,
thisArg: unknown,
...args: unknown[]
) => (...args: unknown[]) => unknown
export const FunctionPrototypeCall = uncurryThis(Function.prototype.call) as (
self: (...args: unknown[]) => unknown,
thisArg: unknown,
...args: unknown[]
) => unknown
export const FunctionPrototypeToString = uncurryThis(
Function.prototype.toString,
) as (self: (...args: unknown[]) => unknown) => string