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

Function convertKeys

javascript/selenium-webdriver/lib/webdriver.js:176–201  ·  view source on GitHub ↗
(obj)

Source from the content-addressed store, hash-verified

174}
175
176async function convertKeys(obj) {
177 const isArray = Array.isArray(obj)
178 const numKeys = isArray ? obj.length : Object.keys(obj).length
179 const ret = isArray ? new Array(numKeys) : {}
180 if (!numKeys) {
181 return ret
182 }
183
184 async function forEachKey(obj, fn) {
185 if (Array.isArray(obj)) {
186 for (let i = 0, n = obj.length; i < n; i++) {
187 await fn(obj[i], i)
188 }
189 } else {
190 for (let key in obj) {
191 await fn(obj[key], key)
192 }
193 }
194 }
195
196 await forEachKey(obj, async function (value, key) {
197 ret[key] = await toWireValue(value)
198 })
199
200 return ret
201}
202
203/**
204 * Converts a value from its JSON representation according to the WebDriver wire

Callers 1

toWireValueFunction · 0.85

Calls 3

forEachKeyFunction · 0.85
toWireValueFunction · 0.85
keysMethod · 0.45

Tested by

no test coverage detected