Alybaba.js 3.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. define(["amber/boot"
  2. //>>excludeStart("imports", pragmas.excludeImports);
  3. , "axon/Axon", "lyst/Lyst"
  4. //>>excludeEnd("imports");
  5. , "amber_core/Kernel-Objects"], function($boot
  6. //>>excludeStart("imports", pragmas.excludeImports);
  7. //>>excludeEnd("imports");
  8. ){"use strict";
  9. if(!$boot.nilAsReceiver)$boot.nilAsReceiver=$boot.nil;
  10. if(!("nilAsValue" in $boot))$boot.nilAsValue=$boot.nilAsReceiver;
  11. var $core=$boot.api,nil=$boot.nilAsValue,$nil=$boot.nilAsReceiver,$recv=$boot.asReceiver,$globals=$boot.globals;
  12. if(!$boot.nilAsClass)$boot.nilAsClass=$boot.dnu;
  13. $core.addPackage("Alybaba");
  14. $core.packages["Alybaba"].innerEval = function (expr) { return eval(expr); };
  15. $core.packages["Alybaba"].imports = ["axon/Axon", "lyst/Lyst"];
  16. $core.packages["Alybaba"].transport = {"type":"amd","amdNamespace":"alybaba"};
  17. $core.addMethod(
  18. $core.method({
  19. selector: "atLyst:consume:",
  20. protocol: "*Alybaba",
  21. fn: function (aCollection,aBlock){
  22. var self=this,$self=this;
  23. var value;
  24. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  25. return $core.withContext(function($ctx1) {
  26. //>>excludeEnd("ctx");
  27. var $early={};
  28. try {
  29. value=$self._atLyst_ifAbsent_(aCollection,(function(){
  30. throw $early=[self];
  31. }));
  32. return $recv(aBlock)._value_(value);
  33. }
  34. catch(e) {if(e===$early)return e[0]; throw e}
  35. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  36. }, function($ctx1) {$ctx1.fill(self,"atLyst:consume:",{aCollection:aCollection,aBlock:aBlock,value:value},$globals.Object)});
  37. //>>excludeEnd("ctx");
  38. },
  39. //>>excludeStart("ide", pragmas.excludeIdeData);
  40. args: ["aCollection", "aBlock"],
  41. source: "atLyst: aCollection consume: aBlock\x0a\x09| value |\x0a\x09value := self atLyst: aCollection ifAbsent: [ ^self ].\x0a\x09^ aBlock value: value",
  42. referencedClasses: [],
  43. //>>excludeEnd("ide");
  44. messageSends: ["atLyst:ifAbsent:", "value:"]
  45. }),
  46. $globals.Object);
  47. $core.addMethod(
  48. $core.method({
  49. selector: "atLyst:transform:",
  50. protocol: "*Alybaba",
  51. fn: function (aCollection,aBlock){
  52. var self=this,$self=this;
  53. var value;
  54. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  55. return $core.withContext(function($ctx1) {
  56. //>>excludeEnd("ctx");
  57. var $1,$receiver;
  58. var $early={};
  59. try {
  60. $recv(aCollection)._last();
  61. value=$self._atLyst_ifAbsent_(aCollection,(function(){
  62. throw $early=[self];
  63. }));
  64. value=$recv(aBlock)._value_(value);
  65. value=$self._atLyst_ifAbsent_put_(aCollection,(function(){
  66. throw $early=[self];
  67. }),value);
  68. $1=$self._registeredAxon();
  69. if(($receiver = $1) == null || $receiver.a$nil){
  70. $1;
  71. } else {
  72. var axon;
  73. axon=$receiver;
  74. $recv(axon)._changed_(aCollection);
  75. }
  76. return self;
  77. }
  78. catch(e) {if(e===$early)return e[0]; throw e}
  79. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  80. }, function($ctx1) {$ctx1.fill(self,"atLyst:transform:",{aCollection:aCollection,aBlock:aBlock,value:value},$globals.Object)});
  81. //>>excludeEnd("ctx");
  82. },
  83. //>>excludeStart("ide", pragmas.excludeIdeData);
  84. args: ["aCollection", "aBlock"],
  85. source: "atLyst: aCollection transform: aBlock\x0a\x09| value |\x0a\x09aCollection last. \x22raise if empty\x22\x0a\x09value := self atLyst: aCollection ifAbsent: [ ^self ].\x0a\x09value := aBlock value: value.\x0a\x09value := self atLyst: aCollection ifAbsent: [ ^self ] put: value.\x0a\x09self registeredAxon ifNotNil: [:axon | axon changed: aCollection]",
  86. referencedClasses: [],
  87. //>>excludeEnd("ide");
  88. messageSends: ["last", "atLyst:ifAbsent:", "value:", "atLyst:ifAbsent:put:", "ifNotNil:", "registeredAxon", "changed:"]
  89. }),
  90. $globals.Object);
  91. });