(property: string)
| 20 | const propertiesCache = {}; |
| 21 | |
| 22 | function getProperties(property: string): Array<string> { |
| 23 | if (!property) { |
| 24 | return emptyArray; |
| 25 | } |
| 26 | |
| 27 | let result: Array<string> = propertiesCache[property]; |
| 28 | if (result) { |
| 29 | return result; |
| 30 | } |
| 31 | |
| 32 | // first replace all '$parents[..]' with a safe string |
| 33 | // second removes all ] since they are not important for property access and not needed |
| 34 | // then split properties either on '.' or '[' |
| 35 | const parentsMatches = property.match(parentsRegex); |
| 36 | result = property.replace(parentsRegex, 'parentsMatch').replace(/\]/g, '').split(/\.|\[/); |
| 37 | |
| 38 | let parentsMatchesCounter = 0; |
| 39 | for (let i = 0, resultLength = result.length; i < resultLength; i++) { |
| 40 | if (result[i] === 'parentsMatch') { |
| 41 | result[i] = parentsMatches[parentsMatchesCounter++]; |
| 42 | } |
| 43 | } |
| 44 | propertiesCache[property] = result; |
| 45 | |
| 46 | return result; |
| 47 | } |
| 48 | |
| 49 | /** |
| 50 | * Normalizes "ontap" to "tap", and "ondoubletap" to "ondoubletap". |
no test coverage detected