Advertisement
Guest User

Untitled

a guest
Aug 5th, 2015
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.31 KB | None | 0 0
  1. // Calls 'f' if the parameters are different from the last call.
  2. // NOTE: Implement 'notEqual' yourself
  3. const changed = f => {
  4. let lastParams = undefined, flag = false;
  5. return (...args) => {
  6. if (!flag || notEqual(lastParams, args)) {
  7. f(args);
  8. lastParams = args;
  9. flag = true
  10. }
  11. };
  12. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement