MCPcopy Create free account
hub / github.com/SeleniumHQ/selenium / map

Function map

javascript/selenium-webdriver/lib/promise.js:129–143  ·  view source on GitHub ↗

* Calls a function for each element in an array and inserts the result into a * new array, which is used as the fulfillment value of the promise returned * by this function. * * If the return value of the mapping function is a promise, this function * will wait for it to be fulfilled before ins

(array, fn, self = undefined)

Source from the content-addressed store, hash-verified

127 * @template TYPE, SELF
128 */
129async function map(array, fn, self = undefined) {
130 const v = await Promise.resolve(array)
131 if (!Array.isArray(v)) {
132 throw TypeError('not an array')
133 }
134
135 const arr = /** @type {!Array} */ (v)
136 const values = []
137
138 for (const [index, item] of arr.entries()) {
139 values.push(await Promise.resolve(fn.call(self, item, index, arr)))
140 }
141
142 return values
143}
144
145/**
146 * Calls a function for each element in an array, and if the function returns

Callers 4

as_jsonMethod · 0.85
as_jsonMethod · 0.85
send_keysMethod · 0.85
get_proxy_urlMethod · 0.85

Calls 3

entriesMethod · 0.80
callMethod · 0.65
resolveMethod · 0.45

Tested by

no test coverage detected