The goog.memoize
Namespace
goog.memoize(f, opt_serializer)
Decorator around functions that caches the inner function's return values.
f
{Function
}
- The function to wrap. Its return value may only depend
on its arguments and 'this' context. There may be further restrictions
on the arguments depending on the capabilities of the serializer used.
opt_serializer
{function
(number
, Object
): string
=}
- A function to
serialize f's arguments. It must have the same signature as
goog.memoize.simpleSerializer. It defaults to that function.
@this {Object} The object whose function is being wrapped.
- returns {!
Function
}
- The wrapped function.
.ENABLE_MEMOIZE
.clearCache(cacheOwner)
Clears the memoization cache on the given object.
cacheOwner
{Object
}
- The owner of the cache. This is the {@code this}
context of the memoized function.
.simpleSerializer(functionUid, args)
Simple and fast argument serializer function for goog.memoize.
Supports string, number, boolean, null and undefined arguments. Doesn't
support \x0B characters in the strings.
functionUid
{number
}
- Unique identifier of the function whose result
is cached.
args
{Object
}
- The arguments that the function to memoize is called
with. Note: it is an array-like object, because supports indexing and
has the length property.
- returns {
string
}
- The list of arguments with type information concatenated
with the functionUid argument, serialized as \x0B-separated string.