(cb, maxCacheSize, ignoreNullOrUndefinedResult)
| 24041 | }; |
| 24042 | } |
| 24043 | function memoizeFunction(cb, maxCacheSize, ignoreNullOrUndefinedResult) { |
| 24044 | if (maxCacheSize === void 0) maxCacheSize = 100; |
| 24045 | if (ignoreNullOrUndefinedResult === void 0) ignoreNullOrUndefinedResult = false; |
| 24046 | // Avoid breaking scenarios which don't have weak map. |
| 24047 | if (!_weakMap) return cb; |
| 24048 | if (!_initializedStylesheetResets) { |
| 24049 | var stylesheet = (0, _mergeStyles.Stylesheet).getInstance(); |
| 24050 | if (stylesheet && stylesheet.onReset) (0, _mergeStyles.Stylesheet).getInstance().onReset(resetMemoizations); |
| 24051 | _initializedStylesheetResets = true; |
| 24052 | } |
| 24053 | var rootNode; |
| 24054 | var cacheSize = 0; |
| 24055 | var localResetCounter = _resetCounter; |
| 24056 | return function memoizedFunction() { |
| 24057 | var args = []; |
| 24058 | for(var _i = 0; _i < arguments.length; _i++)args[_i] = arguments[_i]; |
| 24059 | var currentNode = rootNode; |
| 24060 | if (rootNode === undefined || localResetCounter !== _resetCounter || maxCacheSize > 0 && cacheSize > maxCacheSize) { |
| 24061 | rootNode = _createNode(); |
| 24062 | cacheSize = 0; |
| 24063 | localResetCounter = _resetCounter; |
| 24064 | } |
| 24065 | currentNode = rootNode; |
| 24066 | // Traverse the tree until we find the match. |
| 24067 | for(var i = 0; i < args.length; i++){ |
| 24068 | var arg = _normalizeArg(args[i]); |
| 24069 | if (!currentNode.map.has(arg)) currentNode.map.set(arg, _createNode()); |
| 24070 | currentNode = currentNode.map.get(arg); |
| 24071 | } |
| 24072 | if (!currentNode.hasOwnProperty("value")) { |
| 24073 | currentNode.value = cb.apply(void 0, args); |
| 24074 | cacheSize++; |
| 24075 | } |
| 24076 | if (ignoreNullOrUndefinedResult && (currentNode.value === null || currentNode.value === undefined)) currentNode.value = cb.apply(void 0, args); |
| 24077 | return currentNode.value; |
| 24078 | }; |
| 24079 | } |
| 24080 | function createMemoizer(getValue) { |
| 24081 | if (!_weakMap) // Without a `WeakMap` implementation, memoization is not possible. |
| 24082 | return getValue; |
no test coverage detected