MCPcopy Create free account
hub / github.com/estools/esquery / getPath

Function getPath

esquery.js:35–41  ·  view source on GitHub ↗

* Get the value of a property which may be multiple levels down * in the object. * @param {?PlainObject} obj * @param {string[]} keys * @returns {undefined|boolean|string|number|external:AST}

(obj, keys)

Source from the content-addressed store, hash-verified

33 * @returns {undefined|boolean|string|number|external:AST}
34 */
35function getPath(obj, keys) {
36 for (let i = 0; i < keys.length; ++i) {
37 if (obj == null) { return obj; }
38 obj = obj[keys[i]];
39 }
40 return obj;
41}
42
43/**
44 * Determine whether `node` can be reached by following `path`,

Callers 1

generateMatcherFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected