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

Function convertKeys

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

Source from the content-addressed store, hash-verified

172}
173
174async function convertKeys(obj) {
175 const isArray = Array.isArray(obj)
176 const numKeys = isArray ? obj.length : Object.keys(obj).length
177 const ret = isArray ? new Array(numKeys) : {}
178 if (!numKeys) {
179 return ret
180 }
181
182 async function forEachKey(obj, fn) {
183 if (Array.isArray(obj)) {
184 for (let i = 0, n = obj.length; i < n; i++) {
185 await fn(obj[i], i)
186 }
187 } else {
188 for (let key in obj) {
189 await fn(obj[key], key)
190 }
191 }
192 }
193
194 await forEachKey(obj, async function (value, key) {
195 ret[key] = await toWireValue(value)
196 })
197
198 return ret
199}
200
201/**
202 * 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