MCPcopy Index your code
hub / github.com/SeleniumHQ/selenium / fullyResolveKeys

Function fullyResolveKeys

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

* @param {!(Array|Object)} obj the object to resolve. * @return {!Thenable} A promise that will be resolved with the * input object once all of its values have been fully resolved.

(obj)

Source from the content-addressed store, hash-verified

224 * input object once all of its values have been fully resolved.
225 */
226async function fullyResolveKeys(obj) {
227 const isArray = Array.isArray(obj)
228 const numKeys = isArray ? obj.length : Object.keys(obj).length
229
230 if (!numKeys) {
231 return obj
232 }
233
234 async function forEachProperty(obj, fn) {
235 for (let key in obj) {
236 await fn(obj[key], key)
237 }
238 }
239
240 async function forEachElement(arr, fn) {
241 for (let i = 0; i < arr.length; i++) {
242 await fn(arr[i], i)
243 }
244 }
245
246 const forEachKey = isArray ? forEachElement : forEachProperty
247 await forEachKey(obj, async function (partialValue, key) {
248 if (!Array.isArray(partialValue) && (!partialValue || typeof partialValue !== 'object')) {
249 return
250 }
251 obj[key] = await fullyResolved(partialValue)
252 })
253 return obj
254}
255
256// PUBLIC API
257

Callers 1

fullyResolvedFunction · 0.85

Calls 3

forEachKeyFunction · 0.85
fullyResolvedFunction · 0.85
keysMethod · 0.45

Tested by

no test coverage detected