find
优质
小牛编辑
129浏览
2023-12-01
A version of Sequence#find which returns an AsyncHandle.
Signature
AsyncSequence.find = function(predicate) { /*...*/ }
AsyncSequence.find = function find(predicate) { var found; var handle = this.each(function(e, i) { if (predicate(e, i)) { found = e; return false; } }); return handle.then(function() { return found; }); }
Name | Type(s) | Description |
---|---|---|
predicate | Function | A function to call on (potentially) every element in the sequence. |
returns | AsyncHandle | An AsyncHandle (promise) which resolves to the found element, once it is detected, or else |