Guest User

Untitled

a guest
Oct 19th, 2017
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. function memoizedBind(fn, ...args) {
  2. // Memoize the bind call (with cache size 1).
  3. if (!areArgumentsShallowlyEqual(fn.__lastArgs, args)) {
  4. fn.__lastResult = fn.bind.apply(fn, args);
  5. fn.__lastArgs = args;
  6. }
  7. return fn.__lastResult;
  8. }
  9.  
  10. // ======================================================
  11. // Before transform
  12.  
  13. myFn.bind(this, foo, bar);
  14.  
  15. // ======================================================
  16. // After transform
  17.  
  18. memoizedBind(myFn, this, foo, bar);
Add Comment
Please, Sign In to add comment