{"ScriptPreparationCode":null,"TestCases":[{"Name":"Use delete","Code":"const content = \u00270\u0027.repeat(53000); // ~53kb\r\nvar cache = {};\r\n\r\nlet i = 100; // will give us ~5Mb\r\nwhile (i--) {\r\n const name = \u0060item-${i}\u0060;\r\n cache[name] = content;\r\n}\r\n\r\n// we will delete all 100 items\r\nfunction invalidateItem() {\r\n return true;\r\n}\r\n\r\nconst invalidatedCache = (cache) =\u003E {\r\n const updatedCache = {};\r\n Object.assign(updatedCache, cache);\r\n Object.keys(cache).filter(invalidateItem).forEach((name) =\u003E delete updatedCache[name]);\r\n return updatedCache;\r\n };\r\n\r\n\r\ninvalidatedCache(cache);","IsDeferred":false},{"Name":"Use undefined","Code":"const content = \u00270\u0027.repeat(53000); // ~53kb\r\nvar cache = {};\r\n\r\nlet i = 100; // will give us ~5Mb\r\nwhile (i--) {\r\n const name = \u0060item-${i}\u0060;\r\n cache[name] = content;\r\n}\r\n\r\n// we will delete all 100 items\r\nfunction invalidateItem() {\r\n return true;\r\n}\r\nconst invalidatedCache = (cache) =\u003E {\r\n const updatedCache = {};\r\n Object.assign(updatedCache, cache);\r\n Object.keys(cache).filter(invalidateItem).forEach((name) =\u003E {\r\n updatedCache[name] = undefined;\r\n });\r\n return updatedCache;\r\n };\r\n\r\n\r\ninvalidatedCache(cache);","IsDeferred":false},{"Name":"Use filter and reduce","Code":"const content = \u00270\u0027.repeat(53000); // ~53kb\r\nvar cache = {};\r\n\r\nlet i = 100; // will give us ~5Mb\r\nwhile (i--) {\r\n const name = \u0060item-${i}\u0060;\r\n cache[name] = content;\r\n}\r\n\r\n// we will delete all 100 items\r\nfunction invalidateItem() {\r\n return true;\r\n}\r\nconst invalidatedCache = (cache) =\u003E {\r\n const updatedCache = Object.keys(cache).filter(invalidateItem).reduce((cacheClone, key) =\u003E {\r\n cacheClone[key] = cache[key];\r\n return cacheClone;\r\n }, Object.create(null));\r\n return updatedCache;\r\n };\r\n\r\n\r\ninvalidatedCache(cache);","IsDeferred":false}]}