MCPcopy Index your code
hub / github.com/plotly/plotly.js / npGet

Function npGet

src/lib/nested_property.js:75–111  ·  view source on GitHub ↗
(cont, parts)

Source from the content-addressed store, hash-verified

73};
74
75function npGet(cont, parts) {
76 return function(retainNull) {
77 var curCont = cont;
78 var curPart;
79 var allSame;
80 var out;
81 var i;
82 var j;
83
84 for(i = 0; i < parts.length - 1; i++) {
85 curPart = parts[i];
86 if(curPart === -1) {
87 allSame = true;
88 out = [];
89 for(j = 0; j < curCont.length; j++) {
90 out[j] = npGet(curCont[j], parts.slice(i + 1))(retainNull);
91 if(out[j] !== out[0]) allSame = false;
92 }
93 return allSame ? out[0] : out;
94 }
95 if(typeof curPart === 'number' && !isArrayOrTypedArray(curCont)) {
96 return undefined;
97 }
98 curCont = curCont[curPart];
99 if(typeof curCont !== 'object' || curCont === null) {
100 return undefined;
101 }
102 }
103
104 // only hit this if parts.length === 1
105 if(typeof curCont !== 'object' || curCont === null) return undefined;
106
107 out = curCont[parts[i]];
108 if(!retainNull && (out === null)) return undefined;
109 return out;
110 };
111}
112
113/*
114 * Can this value be deleted? We can delete `undefined`, and `null` except INSIDE an

Callers 1

nested_property.jsFile · 0.85

Calls 1

isArrayOrTypedArrayFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…