Advertisement
Guest User

Untitled

a guest
Aug 24th, 2019
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. export function defaultMemoize(func, equalityCheck = defaultEqualityCheck) {
  2. let lastArgs = null
  3. let lastResult = null
  4. // we reference arguments instead of spreading them for performance reasons
  5. return function () {
  6. if (!areArgumentsShallowlyEqual(equalityCheck, lastArgs, arguments)) {
  7. // apply arguments instead of spreading for performance.
  8. lastResult = func.apply(null, arguments)
  9. }
  10.  
  11. lastArgs = arguments
  12. return lastResult
  13. }
  14. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement