{"ScriptPreparationCode":"const formatOptions = {\r\n minimumFractionDigits: 0,\r\n maximumFractionDigits: 0,\r\n useGrouping: false,\r\n style: \u0027percent\u0027,\r\n};\r\n\r\nconst staticInstanceDe = new Intl.NumberFormat(\u0022de\u0022, formatOptions);\r\nconst staticInstanceFr = new Intl.NumberFormat(\u0022fr\u0022, formatOptions);\r\n\r\nconst lodashCache = _.memoize(\r\n (locale, options) =\u003E new Intl.NumberFormat(locale, options),\r\n (locale, options) =\u003E \u0060${locale}-${JSON.stringify(options)}\u0060,\r\n);\r\n\r\nconst mapCache = new Map();\r\nconst getMapCacheInstance = (locale, options) =\u003E {\r\n let lang;\r\n if (!mapCache.has(locale)) {\r\n lang = new Map();\r\n mapCache.set(locale, lang);\r\n } else {\r\n lang = mapCache.get(locale);\r\n }\r\n if (!lang.has(options)) {\r\n const newInstance = new Intl.NumberFormat(locale, options);\r\n lang.set(options, newInstance);\r\n return newInstance;\r\n }\r\n return lang.get(options);\r\n}\r\n\r\nconst objCache = {};\r\nconst getObjCacheInstance = (locale, options) =\u003E {\r\n let lang = objCache[locale];\r\n if (!lang) {\r\n lang = {};\r\n objCache[locale] = lang;\r\n }\r\n if (!lang[options]) {\r\n const newInstance = new Intl.NumberFormat(locale, options);\r\n lang[options] = newInstance;\r\n return newInstance;\r\n }\r\n return lang[options];\r\n}","TestCases":[{"Name":"Always new instance","Code":"new Intl.NumberFormat(\u0022de\u0022, formatOptions).format(0.123)\r\nnew Intl.NumberFormat(\u0022fr\u0022, formatOptions).format(0.123)","IsDeferred":false},{"Name":"static global instance","Code":"staticInstanceDe.format(0.123)\r\nstaticInstanceFr.format(0.123)","IsDeferred":false},{"Name":"Lodash cache","Code":"lodashCache(\u0022de\u0022, formatOptions).format(0.123)\r\nlodashCache(\u0022fr\u0022, formatOptions).format(0.123)","IsDeferred":false},{"Name":"Custom cache with maps","Code":"getMapCacheInstance(\u0022de\u0022, formatOptions).format(0.123)\r\ngetMapCacheInstance(\u0022fr\u0022, formatOptions).format(0.123)","IsDeferred":false},{"Name":"Custom cache with objects","Code":"getObjCacheInstance(\u0022de\u0022, formatOptions).format(0.123)\r\ngetObjCacheInstance(\u0022fr\u0022, formatOptions).format(0.123)","IsDeferred":false}]}