Guest User

Untitled

a guest
Jul 23rd, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. var Medium = function(fn, args){
  2. var __fn = cloneFunction(fn);
  3. var __length = fn.length;
  4. var __args = args.length >= fn.length ? args : fill(fn.length, args);
  5. var __self = this;
  6.  
  7. this.getFn = function(){ return cloneFunction(__fn) };
  8. ...
  9. }
  10.  
  11. Medium.prototype.pass = function(sprdArgs){
  12. var fnArgs = this.getArgs();
  13. return arguments.length > 0
  14. ? this.use("load", arguments)
  15. : this.use("update", fnArgs);
  16. }
  17. ...
  18.  
  19. var Medium = function(fn, args){
  20. ...
  21. this.method = function(thisArg, funcName, args){
  22. var funcs = {
  23. load: function(args){ ... },
  24. update: function(params){ ... },
  25. execute: function(){ ... }
  26. };
  27.  
  28. return thisArg === __self
  29. ? funcs[funcName].apply(thisArg, args)
  30. : null;
  31. }
  32. }
  33.  
  34. Medium.prototype.use = function(funcName, sprdArgs){
  35. var args = clone(arguments);
  36. var sprdArgs = filter(args, function(elem, i){
  37. return i !== 0;
  38. });
  39.  
  40. return this.method(this, funcName, sprdArgs);
  41. }
Add Comment
Please, Sign In to add comment