MCPcopy
hub / github.com/axios/axios / parsePropPath

Function parsePropPath

lib/helpers/formDataToJSON.js:25–40  ·  view source on GitHub ↗

* It takes a string like `foo[x][y][z]` and returns an array like `['foo', 'x', 'y', 'z'] * * @param {string} name - The name of the property to get. * * @returns An array of strings.

(name)

Source from the content-addressed store, hash-verified

23 * @returns An array of strings.
24 */
25function parsePropPath(name) {
26 // foo[x][y][z]
27 // foo.x.y.z
28 // foo-x-y-z
29 // foo x y z
30 const path = [];
31 const pattern = /\w+|\[(\w*)]/g;
32 let match;
33
34 while ((match = pattern.exec(name)) !== null) {
35 throwIfDepthExceeded(path.length);
36 path.push(match[0] === '[]' ? '' : match[1] || match[0]);
37 }
38
39 return path;
40}
41
42/**
43 * Convert an array to an object.

Callers 1

formDataToJSONFunction · 0.85

Calls 1

throwIfDepthExceededFunction · 0.85

Tested by

no test coverage detected