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; }); }
Name | Type(s) | Description |
---|---|---|
value | * | The element to search for in the sequence. |
returns | AsyncHandle | An AsyncHandle (promise) which resolves to the found index, once it is detected, or -1. |