当前位置: 首页 > 文档资料 > Lazy.js 英文文档 >

every

优质
小牛编辑
128浏览
2023-12-01

Checks whether every element in this sequence satisfies a given predicate.

Signature

Sequence.every = function(predicate) { /*...*/ }
Sequence.every = function every(predicate) {
  predicate = createCallback(predicate);

  return this.each(function(e, i) {
return !!predicate(e, i);
  });
}
NameType(s)Description
predicateFunction

A function to call on (potentially) every element in this sequence.

returnsboolean

True if predicate returns true for every element in the sequence (or the sequence is empty). False if predicate returns false for at least one element.

Examples

var numbers = [1, 2, 3, 4, 5];

var objects = [{ foo: true }, { foo: false, bar: true }];

Lazy(numbers).every(isEven)     // => false
Lazy(numbers).every(isPositive) // => true
Lazy(objects).all('foo')        // => false
Lazy(objects).all('bar')        // => false