Function: partial()
ts
function partial<TBound, TArgs, TResult>(fn, ...boundArgs): (...args) => TResult;Partially applies leading arguments to a function. 为函数预绑定前置参数。
Type Parameters
| Type Parameter | Description |
|---|---|
TBound extends unknown[] | The bound leading arguments / 预绑定前置参数 |
TArgs extends unknown[] | The full argument tuple / 完整参数元组 |
TResult | The return type / 返回值类型 |
Parameters
| Parameter | Type | Description |
|---|---|---|
fn | (...args) => TResult | The target function / 目标函数 |
...boundArgs | TBound | The leading arguments to bind / 要预绑定的前置参数 |
Returns
A partially applied function / 部分应用后的函数
(...args) => TResult
Example
ts
partial(Math.max, 0)(5)
// => 5Since
1.2.0