MCPcopy Index your code
hub / github.com/NativeScript/NativeScript / getProperties

Function getProperties

packages/core/ui/core/bindable/index.ts:22–47  ·  view source on GitHub ↗
(property: string)

Source from the content-addressed store, hash-verified

20const propertiesCache = {};
21
22function 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".

Callers 1

constructorMethod · 0.85

Calls 2

replaceMethod · 0.80
matchMethod · 0.45

Tested by

no test coverage detected