MCPcopy Index your code
hub / github.com/node-config/node-config / getPath

Method getPath

lib/util.js:600–619  ·  view source on GitHub ↗

* Underlying get mechanism * * @method getPath * @param {object} object - Object to get the property for * @param {string|string[]} property - The property name to get (as an array or '.' delimited string) * @return {*} value - Property value, including undefined if not defined.

(object, property)

Source from the content-addressed store, hash-verified

598 * @return {*} value - Property value, including undefined if not defined.
599 */
600 static getPath(object, property) {
601 const path = Array.isArray(property) ? property : property.split('.');
602
603 let next = object;
604 for (let i = 0; i < path.length; i++) {
605 const name = path[i];
606 const value = next[name];
607
608 if (i === path.length - 1) {
609 return value;
610 }
611
612 // Note that typeof null === 'object'
613 if (value === null || typeof value !== 'object') {
614 return undefined;
615 }
616
617 next = value;
618 }
619 }
620
621 /**
622 * Set objects given a path as a string list

Callers 6

setModuleDefaultsMethod · 0.80
getMethod · 0.80
hasMethod · 0.80
setModuleDefaultsMethod · 0.80
0-util.jsFile · 0.80
default.jsFile · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected