Skip to content

Async Find

zak-zaffar edited this page Dec 23, 2019 · 11 revisions

Docblock /**

  • Async Find
  • Find an item in an iterable object asynchronously and resolve when found or all callbacks resolve
  • @async
  • @param {Function} callback - callback(currentValue, index, array)
  • @param {Object} [thisArg] - must be iterable
  • @return {any}
  • @throws {TypeError} */ async function asyncFind(callback, [thisArg]) {...} Examples As a function const { asyncFind } = require('iterable-async'), array = [1, 2, 3];

const found = await asyncFind(async element => { return element > 2; }, array);

console.log('Resolved element' + found) // Resolved element 3 As a method const { asyncForEach } = require('iterable-async'), array = [1, 2, 3];

array.asyncForEach = asyncForEach;

array.asyncForEach(async element => { console.log('Resolved element ' + element); }); // Resolved element 1 // Resolved element 2 // Resolved element 3 Add a custom footer Pages 3 Find a Page… Home Async Find Async For Each Add a custom sidebar Clone this wiki locally https://github.com/Sykander/iterable-async.wiki.git © 2019 GitHub, Inc. Terms Privacy Security Status Help Contact GitHub Pricing API Training Blog About

Clone this wiki locally