MCPcopy Create free account
hub / github.com/ccxt/ccxt / parseObject

Function parseObject

ts/src/static_dependencies/qs/parse.js:98–131  ·  view source on GitHub ↗
(chain, val, options)

Source from the content-addressed store, hash-verified

96};
97
98var parseObject = function (chain, val, options) {
99 var leaf = val;
100
101 for (var i = chain.length - 1; i >= 0; --i) {
102 var obj;
103 var root = chain[i];
104
105 if (root === '[]' && options.parseArrays) {
106 obj = [].concat(leaf);
107 } else {
108 obj = options.plainObjects ? Object.create(null) : {};
109 var cleanRoot = root.charAt(0) === '[' && root.charAt(root.length - 1) === ']' ? root.slice(1, -1) : root;
110 var index = parseInt(cleanRoot, 10);
111 if (!options.parseArrays && cleanRoot === '') {
112 obj = { 0: leaf };
113 } else if (
114 !isNaN(index)
115 && root !== cleanRoot
116 && String(index) === cleanRoot
117 && index >= 0
118 && (options.parseArrays && index <= options.arrayLimit)
119 ) {
120 obj = [];
121 obj[index] = leaf;
122 } else {
123 obj[cleanRoot] = leaf;
124 }
125 }
126
127 leaf = obj;
128 }
129
130 return leaf;
131};
132
133var parseKeys = function parseQueryStringKeys(givenKey, val, options) {
134 if (!givenKey) {

Callers 1

parseKeysFunction · 0.70

Calls 5

parseIntFunction · 0.85
StringClass · 0.85
concatMethod · 0.45
createMethod · 0.45
sliceMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…