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

contains

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

A version of Sequence#contains which returns an AsyncHandle.

Signature

AsyncSequence.contains = function(value) { /*...*/ }
AsyncSequence.contains = function contains(value) {
  var found = false;

  var handle = this.each(function(e) {
if (e === value) {
  found = true;
  return false;
}
  });

  return handle.then(function() {
return found;
  });
}
NameType(s)Description
value*

The element to search for in the sequence.

returnsAsyncHandle

An AsyncHandle (promise) which resolves to either true or false to indicate whether the element was found.