Function: every()
ts
function every<T>(collection, predicate): boolean;Checks whether every item in an array or object matches a predicate. 检查数组或对象中的所有元素是否都满足断言。
Type Parameters
| Type Parameter | Description |
|---|---|
T extends Record<string, unknown> | readonly unknown[] | The source collection type / 源集合类型 |
Parameters
| Parameter | Type | Description |
|---|---|---|
collection | T | The source collection / 源集合 |
predicate | (value, key, collection) => boolean | The match predicate / 匹配断言 |
Returns
boolean
true when all items match / 全部匹配时返回 true
Example
ts
every({ a: 1, b: 2 }, (value) => value > 0)
// => trueSince
1.2.0