{"ScriptPreparationCode":null,"TestCases":[{"Name":"forEach \u002B find \u002B push","Code":"const responseData = new Array(100).fill(null).map((_, index) =\u003E ({\r\n contract: \u0060contract_${index}\u0060, \r\n token_id: index,\r\n hash: \u0060hash_${index}\u0060,\r\n}));\r\n\r\nconst cachedData = new Array(100).fill(null).map((_, index) =\u003E ({\r\n contract: \u0060contract_${index % 2}\u0060,\r\n token_id: index,\r\n hash: \u0060hash_${index}\u0060,\r\n nft: index % 2 === 0 ? { data: \u0060NFT data for ${index}\u0060 } : null,\r\n}));\r\n\r\nconst readyForRender = [];\r\nconst toUpdate = [];\r\n\r\nresponseData.forEach(item =\u003E {\r\n const actualCachedData = cachedData.find(\r\n cache =\u003E cache.contract === item.contract \u0026\u0026\r\n cache.token_id === item.token_id \u0026\u0026\r\n cache.hash === item.hash\r\n );\r\n\r\n if (actualCachedData \u0026\u0026 actualCachedData.nft) {\r\n readyForRender.push(actualCachedData);\r\n } else {\r\n toUpdate.push(item);\r\n }\r\n});\r\n","IsDeferred":false},{"Name":"Reduce \u002B find","Code":"const responseData = new Array(100).fill(null).map((_, index) =\u003E ({\r\n contract: \u0060contract_${index}\u0060, \r\n token_id: index,\r\n hash: \u0060hash_${index}\u0060,\r\n}));\r\n\r\nconst cachedData = new Array(100).fill(null).map((_, index) =\u003E ({\r\n contract: \u0060contract_${index % 2}\u0060,\r\n token_id: index,\r\n hash: \u0060hash_${index}\u0060,\r\n nft: index % 2 === 0 ? { data: \u0060NFT data for ${index}\u0060 } : null,\r\n}));\r\n\r\nconst { readyForRender, toUpdate } = responseData.reduce((accumulator, item) =\u003E {\r\n const actualCachedData = cachedData.find(cache =\u003E\r\n cache.contract === item.contract \u0026\u0026\r\n cache.token_id === item.token_id \u0026\u0026\r\n cache.hash === item.hash\r\n );\r\n\r\n if (actualCachedData \u0026\u0026 actualCachedData.nft) {\r\n return {\r\n ...accumulator,\r\n readyForRender: [...accumulator.readyForRender, actualCachedData],\r\n };\r\n } else {\r\n return {\r\n ...accumulator,\r\n toUpdate: [...accumulator.toUpdate, item],\r\n };\r\n }\r\n}, { readyForRender: [], toUpdate: [] });\r\n","IsDeferred":false},{"Name":"map \u002B find \u002B filter","Code":"const responseData = new Array(100).fill(null).map((_, index) =\u003E ({\r\n contract: \u0060contract_${index}\u0060, \r\n token_id: index,\r\n hash: \u0060hash_${index}\u0060,\r\n}));\r\n\r\nconst cachedData = new Array(100).fill(null).map((_, index) =\u003E ({\r\n contract: \u0060contract_${index % 2}\u0060,\r\n token_id: index,\r\n hash: \u0060hash_${index}\u0060,\r\n nft: index % 2 === 0 ? { data: \u0060NFT data for ${index}\u0060 } : null,\r\n}));\r\n\r\nconst loadedIndices = responseData.map((item, index) =\u003E {\r\n const actualCachedData = cachedData.find(cache =\u003E\r\n cache.contract === item.contract \u0026\u0026\r\n cache.token_id === item.token_id \u0026\u0026\r\n cache.hash === item.hash\r\n );\r\n\r\n return actualCachedData \u0026\u0026 actualCachedData.nft ? index : null;\r\n}).filter(index =\u003E index !== null);\r\n\r\nconst readyForRender = loadedIndices.map(index =\u003E cachedData[index]);\r\nconst toUpdate = responseData.filter((_, index) =\u003E !loadedIndices.includes(index));\r\n","IsDeferred":false}]}