(cont, parts)
| 73 | }; |
| 74 | |
| 75 | function 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 |
no test coverage detected
searching dependent graphs…