{"ScriptPreparationCode":"var stringIds = [\r\n \u0022report_123\u0022,\r\n \u0022report_33\u0022,\r\n \u0022index_1234\u0022,\r\n \u0022index_5678\u0022,\r\n \u0022users_\u0022,\r\n \u0022details_2\u0022,\r\n \u0022isOpen\u0022,\r\n \u0022report_45\u0022,\r\n \u0022report_678\u0022,\r\n \u0022index_90\u0022,\r\n \u0022users_12\u0022,\r\n \u0022details_\u0022,\r\n \u0022isOpen_56\u0022,\r\n \u0022report_789\u0022,\r\n \u0022report_\u0022,\r\n \u0022index_111\u0022,\r\n \u0022users_22\u0022,\r\n \u0022details_33\u0022,\r\n \u0022isOpen\u0022,\r\n \u0022report_555\u0022,\r\n \u0022report_999\u0022,\r\n \u0022index_1000\u0022,\r\n \u0022users_200\u0022,\r\n \u0022details_300\u0022,\r\n \u0022isOpen\u0022,\r\n \u0022report_88\u0022,\r\n \u0022report_\u0022,\r\n \u0022index_66\u0022,\r\n \u0022users_55\u0022,\r\n \u0022details_44\u0022,\r\n \u0022isOpen\u0022,\r\n \u0022report_11\u0022,\r\n \u0022report_22\u0022,\r\n \u0022index_33\u0022,\r\n \u0022users_44\u0022,\r\n \u0022details_55\u0022,\r\n \u0022isOpen\u0022,\r\n \u0022report_100\u0022,\r\n \u0022report_200\u0022,\r\n \u0022index_300\u0022\r\n];\r\nvar collections = [\r\n {\r\n collectionKey: \u0022report_\u0022,\r\n item: \u0022123\u0022\r\n },\r\n {\r\n collectionKey: \u0022users_\u0022,\r\n item: \u0022\u0022\r\n },\r\n {\r\n collectionKey: \u0022index_\u0022,\r\n item: \u00225678\u0022\r\n },\r\n {\r\n collectionKey: \u0022report_\u0022,\r\n item: \u0022\u0022\r\n },\r\n {\r\n collectionKey: \u0022details_\u0022,\r\n item: \u0022222\u0022\r\n },\r\n {\r\n collectionKey: \u0022isOpen_\u0022,\r\n item: \u0022101\u0022\r\n },\r\n {\r\n collectionKey: \u0022report_\u0022,\r\n item: \u0022\u0022\r\n },\r\n {\r\n collectionKey: \u0022users_\u0022,\r\n item: \u0022678\u0022\r\n },\r\n {\r\n collectionKey: \u0022details_\u0022,\r\n item: \u00224445\u0022\r\n },\r\n {\r\n collectionKey: \u0022index_\u0022,\r\n item: \u002290\u0022\r\n },\r\n {\r\n collectionKey: \u0022index_\u0022,\r\n item: \u002290233\u0022\r\n },\r\n {\r\n collectionKey: \u0022details_\u0022,\r\n item: \u0022300\u0022\r\n },\r\n {\r\n collectionKey: \u0022isOpen_\u0022,\r\n item: \u0022555\u0022\r\n },\r\n {\r\n collectionKey: \u0022report_\u0022,\r\n item: \u0022789\u0022\r\n },\r\n {\r\n collectionKey: \u0022report_\u0022,\r\n item: \u0022\u0022\r\n },\r\n {\r\n collectionKey: \u0022report_\u0022,\r\n item: \u0022\u0022\r\n },\r\n {\r\n collectionKey: \u0022report_\u0022,\r\n item: \u0022\u0022\r\n },\r\n {\r\n collectionKey: \u0022report_\u0022,\r\n item: \u0022\u0022\r\n },\r\n {\r\n collectionKey: \u0022users_\u0022,\r\n item: \u002211\u0022\r\n },\r\n {\r\n collectionKey: \u0022index_\u0022,\r\n item: \u0022222\u0022\r\n },\r\n { key: \u0022isOpen\u0022 },\r\n { key: \u0022hasInternet\u0022 },\r\n { key: \u0022hasInternet\u0022 },\r\n { key: \u0022hasInternet\u0022 },\r\n { key: \u0022hasInternet\u0022 },\r\n { key: \u0022hasInternet\u0022 },\r\n { key: \u0022hasInternet\u0022 },\r\n { key: \u0022hasInternet\u0022 },\r\n { key: \u0022hasInternet\u0022 },\r\n { key: \u0022details\u0022 },\r\n { key: \u0022isClosed\u0022 },\r\n { key: \u0022hasError\u0022 },\r\n { key: \u0022isLoaded\u0022 },\r\n { key: \u0022isValid\u0022 },\r\n { key: \u0022hasData\u0022 },\r\n { key: \u0022isVisible\u0022 },\r\n { key: \u0022isEnabled\u0022 },\r\n { key: \u0022hasAccess\u0022 },\r\n { key: \u0022isAdmin\u0022 },\r\n { key: \u0022isOnline\u0022 }\r\n];\r\n","TestCases":[{"Name":"Strings manipulation","Code":"const cache = {\r\n \u0022report_123\u0022: [1],\r\n \u0022report_33\u0022: [2],\r\n \u0022index_1234\u0022: [3],\r\n \u0022index_5678\u0022: [4],\r\n \u0022users_\u0022: [5],\r\n \u0022details_2\u0022: [6],\r\n \u0022isOpen\u0022: [34],\r\n \u0022report_678\u0022: [8],\r\n \u0022index_\u0022: [9],\r\n \u0022users_12\u0022: [10],\r\n \u0022details_\u0022: [11],\r\n \u0022report_789\u0022: [12],\r\n \u0022index_111\u0022: [14],\r\n \u0022users_22\u0022: [15],\r\n \u0022details_33\u0022: [16],\r\n \u0022report_555\u0022: [17],\r\n \u0022report_999\u0022: [18],\r\n \u0022index_1000\u0022: [19],\r\n \u0022users_200\u0022: [20],\r\n \u0022details_300\u0022: [21],\r\n \u0022report_88\u0022: [22],\r\n \u0022index_66\u0022: [23],\r\n \u0022users_55\u0022: [24],\r\n \u0022details_44\u0022: [25],\r\n \u0022report_11\u0022: [26],\r\n \u0022report_22\u0022: [27],\r\n \u0022index_33\u0022: [28],\r\n \u0022users_44\u0022: [29],\r\n \u0022details_55\u0022: [30],\r\n \u0022report_100\u0022: [31],\r\n \u0022report_\u0022: [32, 7, 13],\r\n \u0022index_300\u0022: [33],\r\n \u0022isOpen\u0022: [36],\r\n};\r\n\r\nfunction splitCollectionMemberKey(key) {\r\n const underscoreIndex = key.indexOf(\u0027_\u0027);\r\n\r\n if (underscoreIndex === -1) {\r\n return [];\r\n }\r\n\r\n return [key.substring(0, underscoreIndex \u002B 1), key.substring(underscoreIndex \u002B 1)];\r\n}\r\n\r\nfunction isCollectionMemberKey(collectionKey, key) {\r\n return key.startsWith(collectionKey) \u0026\u0026 key.length \u003E collectionKey.length;\r\n}\r\n\r\nfunction getCollectionKey(key) {\r\n if (!key) {\r\n return \u0027\u0027;\r\n }\r\n return key.replace(/_\\w\u002B/g, \u0027_\u0027);\r\n}\r\n\r\nfunction keyChanged(key) {\r\n\tlet stateMappingKeys = cache[key] ?? [];\r\n const collectionKey = getCollectionKey(key);\r\n const plainCollectionKey = collectionKey.lastIndexOf(\u0027_\u0027) !== -1 ? collectionKey : undefined;\r\n\r\n \tif (plainCollectionKey) {\r\n // Getting the collection key from the specific key because only collection keys were stored in the mapping.\r\n stateMappingKeys = [...stateMappingKeys, ...(cache[plainCollectionKey] ?? [])];\r\n }\r\n\tconst collectionWithValue = splitCollectionMemberKey(key);\r\n}\r\n\r\nstringIds.forEach((k) =\u003E keyChanged(k));","IsDeferred":false},{"Name":"using Objects","Code":"const cache = {\r\n \u0022isOpen\u0022: [1],\r\n \u0022hasInternet\u0022: [2],\r\n \u0022hasInternet\u0022: [3],\r\n \u0022hasInternet\u0022: [4],\r\n \u0022hasInternet\u0022: [5],\r\n \u0022hasInternet\u0022: [6],\r\n \u0022hasInternet\u0022: [7],\r\n \u0022hasInternet\u0022: [8],\r\n \u0022hasInternet\u0022: [9],\r\n \u0022details\u0022: [10],\r\n \u0022isClosed\u0022: [11],\r\n \u0022hasError\u0022: [12],\r\n \u0022isLoaded\u0022: [13],\r\n \u0022isValid\u0022: [14],\r\n \u0022hasData\u0022: [15],\r\n \u0022isVisible\u0022: [16 ],\r\n \u0022isEnabled\u0022: [17],\r\n \u0022hasAccess\u0022: [18],\r\n \u0022isAdmin\u0022: [19],\r\n \u0022isOnline\u0022: [2],\r\n\u0022report_123\u0022: [100],\r\n\u0022users_\u0022: [101],\r\n\u0022index_5678\u0022: [102],\r\n\u0022details_222\u0022: [104],\r\n\u0022isOpen_101\u0022: [105],\r\n\u0022users_678\u0022: [107],\r\n\u0022details_4445\u0022: [108],\r\n\u0022index_90\u0022: [109],\r\n\u0022index_90233\u0022: [200],\r\n\u0022details_300\u0022: [201],\r\n\u0022isOpen_555\u0022: [202],\r\n\u0022report_789\u0022: [203],\r\n\u0022report_\u0022: [103, 106, 204, 205, 206, 207],\r\n\u0022users_11\u0022: [208],\r\n\u0022index_222\u0022: [209]\r\n\r\n};\r\n\r\nfunction normalizeConnection(mapping) {\r\n if (mapping.collectionKey) {\r\n mapping.isCollection = true;\r\n mapping.isRoot = mapping.item.length === 0;\r\n } else {\r\n mapping.isCollection = false;\r\n }\r\n return mapping;\r\n}\r\n\r\n\r\nconst finalKeys = collections.map((k) =\u003E normalizeConnection(k));\r\n\r\nfunction keyChanged(mapping) {\r\n\tconst key = mapping.isCollection ? \u0060${mapping.collectionKey}${mapping.item}\u0060 : mapping.key;\r\n\tlet stateMappingKeys = cache[key] ?? [];\r\n\r\n \tif (mapping.isRoot) {\r\n // Getting the collection key from the specific key because only collection keys were stored in the mapping.\r\n stateMappingKeys = [...stateMappingKeys, ...(cache[mapping.collectionKey] ?? [])];\r\n }\r\n\tconst collectionWithValue = [mapping.collectionKey, mapping.item];\r\n}\r\n\r\nfinalKeys.forEach((k) =\u003E keyChanged(k));","IsDeferred":false}]}