MCPcopy
hub / github.com/codeceptjs/CodeceptJS / filterAsync

Function filterAsync

lib/helper/WebDriver.js:3025–3037  ·  view source on GitHub ↗

* Mimic Array.filter() API, but with an async callback function. * Execute each callback on each array item serially. Useful when using WebDriver API. * * Added due because of problem with chrome driver when too many requests * are made simultaneously. https://bugs.chromium.org/p/chromedriver/is

(array, callback)

Source from the content-addressed store, hash-verified

3023 * @return {Promise<Array>} - Array of values.
3024 */
3025async function filterAsync(array, callback) {
3026 const inputArray = Array.isArray(array) ? array : [array]
3027 const values = []
3028 for (let index = 0; index < inputArray.length; index++) {
3029 const res = await callback(inputArray[index], index, inputArray)
3030 const value = Array.isArray(res) ? res[0] : res
3031
3032 if (value) {
3033 values.push(inputArray[index])
3034 }
3035 }
3036 return values
3037}
3038
3039async function findClickable(locator, locateFn) {
3040 locator = new Locator(locator)

Callers 2

filterBySelectedFunction · 0.85
filterSelectedByValueFunction · 0.85

Calls 2

callbackFunction · 0.85
pushMethod · 0.80

Tested by

no test coverage detected