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

indexOf

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

A version of Sequence#indexOf which returns an AsyncHandle.

Signature

AsyncSequence.indexOf = function(value) { /*...*/ }
AsyncSequence.indexOf = function indexOf(value) {
  var foundIndex = -1;

  var handle = this.each(function(e, i) {
if (e === value) {
  foundIndex = i;
  return false;
}
  });

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

The element to search for in the sequence.

returnsAsyncHandle

An AsyncHandle (promise) which resolves to the found index, once it is detected, or -1.