Skip to content

overSome

js
_.overSome([predicates=[_.identity]])

创建一个函数,检查在使用收到的参数调用时,任何 predicates 是否都返回真值。

¥Creates a function that checks if any of the predicates return truthy when invoked with the arguments it receives.

以下简写可用于提供谓词。传递 Object,它将用作 _.matches 的参数来创建谓词。传递 _.matchesProperty 的参数 Array,将使用它们创建谓词。

¥Following shorthands are possible for providing predicates. Pass an Object and it will be used as an parameter for _.matches to create the predicate. Pass an Array of parameters for _.matchesProperty and the predicate will be created using them.

新增于

¥Since

4.0.0

参数

¥Arguments

  1. [predicates=[_.identity]] (...(函数|函数[])):属性标识符。

    ¥[predicates=[_.identity]] (...(Function|Function[])): The predicates to check.

返回

¥Returns

(函数):返回新函数。

¥(Function): Returns the new function.

示例

¥Example

js
var func = _.overSome([Boolean, isFinite]);

func('1');
// => true

func(null);
// => true

func(NaN);
// => false

var matchesFunc = _.overSome([{ 'a': 1 }, { 'a': 2 }])
var matchesPropertyFunc = _.overSome([['a', 1], ['a', 2]])

Lodash v4.17 中文网 - 粤ICP备13048890号