Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function memoizedBind(fn, ...args) {
- // Memoize the bind call (with cache size 1).
- if (!areArgumentsShallowlyEqual(fn.__lastArgs, args)) {
- fn.__lastResult = fn.bind.apply(fn, args);
- fn.__lastArgs = args;
- }
- return fn.__lastResult;
- }
- // ======================================================
- // Before transform
- myFn.bind(this, foo, bar);
- // ======================================================
- // After transform
- memoizedBind(myFn, this, foo, bar);
Add Comment
Please, Sign In to add comment