MCPcopy Create free account
hub / github.com/Belphemur/node-json-db / processArray

Method processArray

src/lib/ArrayInfo.ts:31–55  ·  view source on GitHub ↗

* Check if the property want to access an Array * @param property

(property?: string)

Source from the content-addressed store, hash-verified

29 * @param property
30 */
31 public static processArray(property?: string): ArrayInfo | null {
32 if (typeof property === 'undefined') {
33 return null
34 }
35
36 if (regexCache[property]) {
37 return regexCache[property]
38 }
39
40 const arrayIndexRegex = arrayRegex()
41 const match = arrayIndexRegex.exec(property.trim())
42 if (match != null) {
43 const propertyName = match[1]
44 // reset the match[2] to the full array index.
45 const nestedArrayMatches = '[' + match[2].toString() + ']'
46 const nestedArrayIndicies = getArrayIndicies(nestedArrayMatches)
47 validateArrayIndicies(nestedArrayIndicies)
48 return (regexCache[property] = new ArrayInfo(
49 propertyName,
50 nestedArrayIndicies
51 ))
52 }
53
54 return null
55 }
56
57 /**
58 * Get the index for the array

Callers 4

01-utils.test.tsFile · 0.80
checkArrayMethod · 0.80
setDataMethod · 0.80

Calls 4

getArrayIndiciesFunction · 0.85
validateArrayIndiciesFunction · 0.85
toStringMethod · 0.80
arrayRegexFunction · 0.70

Tested by

no test coverage detected