Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- export function defaultMemoize(func, equalityCheck = defaultEqualityCheck) {
- let lastArgs = null
- let lastResult = null
- // we reference arguments instead of spreading them for performance reasons
- return function () {
- if (!areArgumentsShallowlyEqual(equalityCheck, lastArgs, arguments)) {
- // apply arguments instead of spreading for performance.
- lastResult = func.apply(null, arguments)
- }
- lastArgs = arguments
- return lastResult
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement