Guest User

Untitled

a guest
Apr 8th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.50 KB | None | 0 0
  1.  
  2. // regular-style javascript
  3. function foo (a,b,c,d) {
  4. if (a > c) throw new Error("c must be teh greetest");
  5. return a * b * c * d;
  6. }
  7. function b (d,e) {
  8. if (e === d) throw new Error("must not be equal");
  9. return e - d;
  10. }
  11. function x (d) {
  12. return d ? b(1,2) : foo(1,2,3,4); // convert to d ? return x : return y then do return/throw conversion.
  13. }
  14.  
  15. var bar = foo(1,2,3);
  16. print(bar);
  17. bar += 3;
  18. var c = b(4,5);
  19. print(c);
  20. print(b(1,x(false)));
  21.  
  22.  
  23. // continuated version
  24. function foo (a,b,c,d) { var ___callback___ = Array.prototype.pop.call(arguments)
  25. if (a > c) return ___callback___(new Error("c must be teh greetest"));
  26. return ___callback___(null, a * b * c * d);
  27. }
  28. function b (d,e) { var ___callback___ = Array.prototype.pop.call(arguments)
  29. if (e === d) return ___callback___(new Error("must not be equal"));
  30. return ___callback___(null, e - d);
  31. }
  32. function x (d) { var ___callback___ = Array.prototype.pop.call(arguments)
  33. d ? return b(1,2,function (er, ___a) { if (er) throw er
  34. ___callback___(null,___a)}) : return foo(1,2,3,4,function (er, ___a) { if (er) throw er
  35. ___callback___(null,___a)});
  36. }
  37.  
  38. foo(1,2,3,function (er, bar) { if (er) throw er // var bar = foo(1,2,3)
  39. print(bar,function (er) { if (er) throw er // print(bar);
  40. bar += 3;
  41. b(4,5,function (er, c) { if (er) throw er // var c = b(4,5)
  42. print(c,function (er) { if (er) throw er // print(c)
  43. x(false,function (er, ___a) { if (er) throw er
  44. b(1,___a, function (er, ___a) { if (er) throw er
  45. print(___a, function (er) { if (er) throw er
  46. })})})})})})})
Add Comment
Please, Sign In to add comment