Skip to content

Function: partial()

ts
function partial<TBound, TArgs, TResult>(fn, ...boundArgs): (...args) => TResult;

Partially applies leading arguments to a function. 为函数预绑定前置参数。

Type Parameters

Type ParameterDescription
TBound extends unknown[]The bound leading arguments / 预绑定前置参数
TArgs extends unknown[]The full argument tuple / 完整参数元组
TResultThe return type / 返回值类型

Parameters

ParameterTypeDescription
fn(...args) => TResultThe target function / 目标函数
...boundArgsTBoundThe leading arguments to bind / 要预绑定的前置参数

Returns

A partially applied function / 部分应用后的函数

(...args) => TResult

Example

ts
partial(Math.max, 0)(5)
// => 5

Since

1.2.0

Released under the MIT License.