MCPcopy
hub / github.com/appium/appium / parseCapsArray

Function parseCapsArray

lib/basedriver/helpers.js:410–428  ·  view source on GitHub ↗

* Takes a desired capability and tries to JSON.parse it as an array, * and either returns the parsed array or a singleton array. * * @param {string|Array } cap A desired capability

(cap)

Source from the content-addressed store, hash-verified

408 * @param {string|Array<String>} cap A desired capability
409 */
410function parseCapsArray (cap) {
411 if (_.isArray(cap)) {
412 return cap;
413 }
414
415 let parsedCaps;
416 try {
417 parsedCaps = JSON.parse(cap);
418 if (_.isArray(parsedCaps)) {
419 return parsedCaps;
420 }
421 } catch (ign) {
422 logger.warn(`Failed to parse capability as JSON array`);
423 }
424 if (_.isString(cap)) {
425 return [cap];
426 }
427 throw new Error(`must provide a string or JSON Array; received ${cap}`);
428}
429
430export {
431 configureApp, isPackageOrBundle, duplicateKeys, parseCapsArray

Callers 1

helpers-specs.jsFile · 0.90

Calls 1

parseMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…