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

Function parseKeys

ts/src/static_dependencies/qs/parse.js:133–185  ·  view source on GitHub ↗
(givenKey, val, options)

Source from the content-addressed store, hash-verified

131};
132
133var parseKeys = function parseQueryStringKeys(givenKey, val, options) {
134 if (!givenKey) {
135 return;
136 }
137
138 // Transform dot notation to bracket notation
139 var key = options.allowDots ? givenKey.replace(/\.([^.[]+)/g, '[$1]') : givenKey;
140
141 // The regex chunks
142
143 var brackets = /(\[[^[\]]*])/;
144 var child = /(\[[^[\]]*])/g;
145
146 // Get the parent
147
148 var segment = brackets.exec(key);
149 var parent = segment ? key.slice(0, segment.index) : key;
150
151 // Stash the parent if it exists
152
153 var keys = [];
154 if (parent) {
155 // If we aren't using plain objects, optionally prefix keys that would overwrite object prototype properties
156 if (!options.plainObjects && has.call(Object.prototype, parent)) {
157 if (!options.allowPrototypes) {
158 return;
159 }
160 }
161
162 keys.push(parent);
163 }
164
165 // Loop through children appending to the array until we hit depth
166
167 var i = 0;
168 while ((segment = child.exec(key)) !== null && i < options.depth) {
169 i += 1;
170 if (!options.plainObjects && has.call(Object.prototype, segment[1].slice(1, -1))) {
171 if (!options.allowPrototypes) {
172 return;
173 }
174 }
175 keys.push(segment[1]);
176 }
177
178 // If there's a remainder, just add whatever is left
179
180 if (segment) {
181 keys.push('[' + key.slice(segment.index) + ']');
182 }
183
184 return parseObject(keys, val, options);
185};
186
187var normalizeParseOptions = function normalizeParseOptions(opts) {
188 if (!opts) {

Callers 1

parse.jsFile · 0.70

Calls 5

replaceMethod · 0.80
callMethod · 0.80
pushMethod · 0.80
parseObjectFunction · 0.70
sliceMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…