Kernel-Promises.js 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429
  1. define(["amber/boot", "require", "amber/core/Kernel-Objects"], function($boot,requirejs){"use strict";
  2. var $core=$boot.api,nil=$boot.nilAsValue,$nil=$boot.nilAsReceiver,$recv=$boot.asReceiver,$globals=$boot.globals;
  3. var $pkg = $core.addPackage("Kernel-Promises");
  4. $pkg.transport = {"type":"amd","amdNamespace":"amber/core"};
  5. $core.addClass("Promise", $globals.Object, "Kernel-Promises");
  6. $core.addMethod(
  7. $core.method({
  8. selector: "all:",
  9. protocol: "composites",
  10. //>>excludeStart("ide", pragmas.excludeIdeData);
  11. args: ["aCollection"],
  12. source: "all: aCollection\x0a\x22Returns a Promise resolved with results of sub-promises.\x22\x0a<inlineJS: 'return Promise.all($recv(aCollection)._asArray())'>",
  13. referencedClasses: [],
  14. //>>excludeEnd("ide");
  15. pragmas: [["inlineJS:", ["return Promise.all($recv(aCollection)._asArray())"]]],
  16. messageSends: []
  17. }, function ($methodClass){ return function (aCollection){
  18. var self=this,$self=this;
  19. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  20. return $core.withContext(function($ctx1) {
  21. //>>excludeEnd("ctx");
  22. return Promise.all($recv(aCollection)._asArray());
  23. return self;
  24. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  25. }, function($ctx1) {$ctx1.fill(self,"all:",{aCollection:aCollection})});
  26. //>>excludeEnd("ctx");
  27. }; }),
  28. $globals.Promise.a$cls);
  29. $core.addMethod(
  30. $core.method({
  31. selector: "any:",
  32. protocol: "composites",
  33. //>>excludeStart("ide", pragmas.excludeIdeData);
  34. args: ["aCollection"],
  35. source: "any: aCollection\x0a\x22Returns a Promise resolved with first result of sub-promises.\x22\x0a<inlineJS: 'return Promise.race($recv(aCollection)._asArray())'>",
  36. referencedClasses: [],
  37. //>>excludeEnd("ide");
  38. pragmas: [["inlineJS:", ["return Promise.race($recv(aCollection)._asArray())"]]],
  39. messageSends: []
  40. }, function ($methodClass){ return function (aCollection){
  41. var self=this,$self=this;
  42. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  43. return $core.withContext(function($ctx1) {
  44. //>>excludeEnd("ctx");
  45. return Promise.race($recv(aCollection)._asArray());
  46. return self;
  47. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  48. }, function($ctx1) {$ctx1.fill(self,"any:",{aCollection:aCollection})});
  49. //>>excludeEnd("ctx");
  50. }; }),
  51. $globals.Promise.a$cls);
  52. $core.addMethod(
  53. $core.method({
  54. selector: "delayMilliseconds:",
  55. protocol: "instance creation",
  56. //>>excludeStart("ide", pragmas.excludeIdeData);
  57. args: ["aNumber"],
  58. source: "delayMilliseconds: aNumber\x0a\x09^ self new: [ :model | [ model value: nil ] valueWithTimeout: aNumber ]",
  59. referencedClasses: [],
  60. //>>excludeEnd("ide");
  61. pragmas: [],
  62. messageSends: ["new:", "valueWithTimeout:", "value:"]
  63. }, function ($methodClass){ return function (aNumber){
  64. var self=this,$self=this;
  65. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  66. return $core.withContext(function($ctx1) {
  67. //>>excludeEnd("ctx");
  68. return $self._new_((function(model){
  69. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  70. return $core.withContext(function($ctx2) {
  71. //>>excludeEnd("ctx");
  72. return $recv((function(){
  73. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  74. return $core.withContext(function($ctx3) {
  75. //>>excludeEnd("ctx");
  76. return $recv(model)._value_(nil);
  77. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  78. }, function($ctx3) {$ctx3.fillBlock({},$ctx2,2)});
  79. //>>excludeEnd("ctx");
  80. }))._valueWithTimeout_(aNumber);
  81. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  82. }, function($ctx2) {$ctx2.fillBlock({model:model},$ctx1,1)});
  83. //>>excludeEnd("ctx");
  84. }));
  85. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  86. }, function($ctx1) {$ctx1.fill(self,"delayMilliseconds:",{aNumber:aNumber})});
  87. //>>excludeEnd("ctx");
  88. }; }),
  89. $globals.Promise.a$cls);
  90. $core.addMethod(
  91. $core.method({
  92. selector: "forBlock:",
  93. protocol: "instance creation",
  94. //>>excludeStart("ide", pragmas.excludeIdeData);
  95. args: ["aBlock"],
  96. source: "forBlock: aBlock\x0a\x22Returns a Promise that is resolved with the value of aBlock,\x0aand rejected if error happens while evaluating aBlock.\x22\x0a\x09^ self new then: aBlock",
  97. referencedClasses: [],
  98. //>>excludeEnd("ide");
  99. pragmas: [],
  100. messageSends: ["then:", "new"]
  101. }, function ($methodClass){ return function (aBlock){
  102. var self=this,$self=this;
  103. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  104. return $core.withContext(function($ctx1) {
  105. //>>excludeEnd("ctx");
  106. return $recv($self._new())._then_(aBlock);
  107. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  108. }, function($ctx1) {$ctx1.fill(self,"forBlock:",{aBlock:aBlock})});
  109. //>>excludeEnd("ctx");
  110. }; }),
  111. $globals.Promise.a$cls);
  112. $core.addMethod(
  113. $core.method({
  114. selector: "new",
  115. protocol: "instance creation",
  116. //>>excludeStart("ide", pragmas.excludeIdeData);
  117. args: [],
  118. source: "new\x0a\x22Returns a dumb Promise resolved with nil.\x22\x0a<inlineJS: 'return Promise.resolve()'>",
  119. referencedClasses: [],
  120. //>>excludeEnd("ide");
  121. pragmas: [["inlineJS:", ["return Promise.resolve()"]]],
  122. messageSends: []
  123. }, function ($methodClass){ return function (){
  124. var self=this,$self=this;
  125. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  126. return $core.withContext(function($ctx1) {
  127. //>>excludeEnd("ctx");
  128. return Promise.resolve();
  129. return self;
  130. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  131. }, function($ctx1) {$ctx1.fill(self,"new",{})});
  132. //>>excludeEnd("ctx");
  133. }; }),
  134. $globals.Promise.a$cls);
  135. $core.addMethod(
  136. $core.method({
  137. selector: "new:",
  138. protocol: "instance creation",
  139. //>>excludeStart("ide", pragmas.excludeIdeData);
  140. args: ["aBlock"],
  141. source: "new: aBlock\x0a\x22Returns a Promise that is eventually resolved or rejected.\x0aPass a block that is called with one argument, model.\x0aYou should call model value: ... to resolve the promise\x0aand model signal: ... to reject the promise.\x0aIf error happens during run of the block,\x0apromise is rejected with that error as well.\x22\x0a<inlineJS: 'return new Promise(function (resolve, reject) {\x0a var model = {\x0a\x09\x09value: resolve,\x0a\x09\x09signal: reject,\x0a\x09\x09do: function (aBlock) { resolve(this.try(aBlock)); },\x0a\x09\x09try: function (aBlock) {\x0a\x09\x09\x09try { return aBlock._value(); }\x0a\x09\x09\x09catch (e) { reject(e); }\x0a\x09\x09}\x0a\x09};\x0a aBlock._value_(model);\x0a})'>",
  142. referencedClasses: [],
  143. //>>excludeEnd("ide");
  144. pragmas: [["inlineJS:", ["return new Promise(function (resolve, reject) {\x0a var model = {\x0a\x09\x09value: resolve,\x0a\x09\x09signal: reject,\x0a\x09\x09do: function (aBlock) { resolve(this.try(aBlock)); },\x0a\x09\x09try: function (aBlock) {\x0a\x09\x09\x09try { return aBlock._value(); }\x0a\x09\x09\x09catch (e) { reject(e); }\x0a\x09\x09}\x0a\x09};\x0a aBlock._value_(model);\x0a})"]]],
  145. messageSends: []
  146. }, function ($methodClass){ return function (aBlock){
  147. var self=this,$self=this;
  148. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  149. return $core.withContext(function($ctx1) {
  150. //>>excludeEnd("ctx");
  151. return new Promise(function (resolve, reject) {
  152. var model = {
  153. value: resolve,
  154. signal: reject,
  155. do: function (aBlock) { resolve(this.try(aBlock)); },
  156. try: function (aBlock) {
  157. try { return aBlock._value(); }
  158. catch (e) { reject(e); }
  159. }
  160. };
  161. aBlock._value_(model);
  162. });
  163. return self;
  164. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  165. }, function($ctx1) {$ctx1.fill(self,"new:",{aBlock:aBlock})});
  166. //>>excludeEnd("ctx");
  167. }; }),
  168. $globals.Promise.a$cls);
  169. $core.addMethod(
  170. $core.method({
  171. selector: "signal:",
  172. protocol: "instance creation",
  173. //>>excludeStart("ide", pragmas.excludeIdeData);
  174. args: ["anObject"],
  175. source: "signal: anObject\x0a\x22Returns a Promise rejected with anObject.\x22\x0a<inlineJS: 'return $recv(anObject)._in_(function (x) {return Promise.reject(x)})'>",
  176. referencedClasses: [],
  177. //>>excludeEnd("ide");
  178. pragmas: [["inlineJS:", ["return $recv(anObject)._in_(function (x) {return Promise.reject(x)})"]]],
  179. messageSends: []
  180. }, function ($methodClass){ return function (anObject){
  181. var self=this,$self=this;
  182. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  183. return $core.withContext(function($ctx1) {
  184. //>>excludeEnd("ctx");
  185. return $recv(anObject)._in_(function (x) {return Promise.reject(x)});
  186. return self;
  187. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  188. }, function($ctx1) {$ctx1.fill(self,"signal:",{anObject:anObject})});
  189. //>>excludeEnd("ctx");
  190. }; }),
  191. $globals.Promise.a$cls);
  192. $core.addMethod(
  193. $core.method({
  194. selector: "value:",
  195. protocol: "instance creation",
  196. //>>excludeStart("ide", pragmas.excludeIdeData);
  197. args: ["anObject"],
  198. source: "value: anObject\x0a\x22Returns a Promise resolved with anObject.\x22\x0a<inlineJS: 'return $recv(anObject)._in_(function (x) {return Promise.resolve(x)})'>",
  199. referencedClasses: [],
  200. //>>excludeEnd("ide");
  201. pragmas: [["inlineJS:", ["return $recv(anObject)._in_(function (x) {return Promise.resolve(x)})"]]],
  202. messageSends: []
  203. }, function ($methodClass){ return function (anObject){
  204. var self=this,$self=this;
  205. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  206. return $core.withContext(function($ctx1) {
  207. //>>excludeEnd("ctx");
  208. return $recv(anObject)._in_(function (x) {return Promise.resolve(x)});
  209. return self;
  210. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  211. }, function($ctx1) {$ctx1.fill(self,"value:",{anObject:anObject})});
  212. //>>excludeEnd("ctx");
  213. }; }),
  214. $globals.Promise.a$cls);
  215. $core.addTrait("TThenable", "Kernel-Promises");
  216. $core.addMethod(
  217. $core.method({
  218. selector: "catch:",
  219. protocol: "promises",
  220. //>>excludeStart("ide", pragmas.excludeIdeData);
  221. args: ["aBlock"],
  222. source: "catch: aBlock\x0a<inlineJS: 'return self.then(null, function (err) { return aBlock._value_(err); })'>",
  223. referencedClasses: [],
  224. //>>excludeEnd("ide");
  225. pragmas: [["inlineJS:", ["return self.then(null, function (err) { return aBlock._value_(err); })"]]],
  226. messageSends: []
  227. }, function ($methodClass){ return function (aBlock){
  228. var self=this,$self=this;
  229. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  230. return $core.withContext(function($ctx1) {
  231. //>>excludeEnd("ctx");
  232. return self.then(null, function (err) { return aBlock._value_(err); });
  233. return self;
  234. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  235. }, function($ctx1) {$ctx1.fill(self,"catch:",{aBlock:aBlock})});
  236. //>>excludeEnd("ctx");
  237. }; }),
  238. $globals.TThenable);
  239. $core.addMethod(
  240. $core.method({
  241. selector: "isThenable",
  242. protocol: "testing",
  243. //>>excludeStart("ide", pragmas.excludeIdeData);
  244. args: [],
  245. source: "isThenable\x0a\x09^ true",
  246. referencedClasses: [],
  247. //>>excludeEnd("ide");
  248. pragmas: [],
  249. messageSends: []
  250. }, function ($methodClass){ return function (){
  251. var self=this,$self=this;
  252. return true;
  253. }; }),
  254. $globals.TThenable);
  255. $core.addMethod(
  256. $core.method({
  257. selector: "on:do:",
  258. protocol: "promises",
  259. //>>excludeStart("ide", pragmas.excludeIdeData);
  260. args: ["aClass", "aBlock"],
  261. source: "on: aClass do: aBlock\x0a<inlineJS: 'return self.then(null, function (err) {\x0a if (err._isKindOf_(aClass)) return aBlock._value_(err);\x0a else throw err;\x0a})'>",
  262. referencedClasses: [],
  263. //>>excludeEnd("ide");
  264. pragmas: [["inlineJS:", ["return self.then(null, function (err) {\x0a if (err._isKindOf_(aClass)) return aBlock._value_(err);\x0a else throw err;\x0a})"]]],
  265. messageSends: []
  266. }, function ($methodClass){ return function (aClass,aBlock){
  267. var self=this,$self=this;
  268. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  269. return $core.withContext(function($ctx1) {
  270. //>>excludeEnd("ctx");
  271. return self.then(null, function (err) {
  272. if (err._isKindOf_(aClass)) return aBlock._value_(err);
  273. else throw err;
  274. });
  275. return self;
  276. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  277. }, function($ctx1) {$ctx1.fill(self,"on:do:",{aClass:aClass,aBlock:aBlock})});
  278. //>>excludeEnd("ctx");
  279. }; }),
  280. $globals.TThenable);
  281. $core.addMethod(
  282. $core.method({
  283. selector: "on:do:catch:",
  284. protocol: "promises",
  285. //>>excludeStart("ide", pragmas.excludeIdeData);
  286. args: ["aClass", "aBlock", "anotherBlock"],
  287. source: "on: aClass do: aBlock catch: anotherBlock\x0a\x09^ (self on: aClass do: aBlock) catch: anotherBlock",
  288. referencedClasses: [],
  289. //>>excludeEnd("ide");
  290. pragmas: [],
  291. messageSends: ["catch:", "on:do:"]
  292. }, function ($methodClass){ return function (aClass,aBlock,anotherBlock){
  293. var self=this,$self=this;
  294. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  295. return $core.withContext(function($ctx1) {
  296. //>>excludeEnd("ctx");
  297. return $recv($self._on_do_(aClass,aBlock))._catch_(anotherBlock);
  298. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  299. }, function($ctx1) {$ctx1.fill(self,"on:do:catch:",{aClass:aClass,aBlock:aBlock,anotherBlock:anotherBlock})});
  300. //>>excludeEnd("ctx");
  301. }; }),
  302. $globals.TThenable);
  303. $core.addMethod(
  304. $core.method({
  305. selector: "then:",
  306. protocol: "promises",
  307. //>>excludeStart("ide", pragmas.excludeIdeData);
  308. args: ["aBlockOrArray"],
  309. source: "then: aBlockOrArray\x0a\x22Accepts a block or array of blocks.\x0aEach of blocks in the array or the singleton one is\x0aused in .then call to a promise, to accept a result\x0aand transform it to the result for the next one.\x0aIn case a block has more than one argument\x0aand result is an array, first n-1 elements of the array\x0aare put into additional arguments beyond the first.\x0aThe first argument always contains the result as-is.\x22\x0a<inlineJS: '\x0avar array = Array.isArray(aBlockOrArray) ? aBlockOrArray : [aBlockOrArray];\x0areturn array.reduce(function (soFar, aBlock) {\x0a return soFar.then(typeof aBlock === \x22function\x22 && aBlock.length > 1 ?\x0a function (result) {\x0a if (Array.isArray(result)) {\x0a return aBlock._valueWithPossibleArguments_([result].concat(result.slice(0, aBlock.length-1)));\x0a } else {\x0a return aBlock._value_(result);\x0a }\x0a } :\x0a function (result) {\x0a return aBlock._value_(result);\x0a }\x0a );\x0a}, self)'>",
  310. referencedClasses: [],
  311. //>>excludeEnd("ide");
  312. pragmas: [["inlineJS:", ["\x0avar array = Array.isArray(aBlockOrArray) ? aBlockOrArray : [aBlockOrArray];\x0areturn array.reduce(function (soFar, aBlock) {\x0a return soFar.then(typeof aBlock === \x22function\x22 && aBlock.length > 1 ?\x0a function (result) {\x0a if (Array.isArray(result)) {\x0a return aBlock._valueWithPossibleArguments_([result].concat(result.slice(0, aBlock.length-1)));\x0a } else {\x0a return aBlock._value_(result);\x0a }\x0a } :\x0a function (result) {\x0a return aBlock._value_(result);\x0a }\x0a );\x0a}, self)"]]],
  313. messageSends: []
  314. }, function ($methodClass){ return function (aBlockOrArray){
  315. var self=this,$self=this;
  316. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  317. return $core.withContext(function($ctx1) {
  318. //>>excludeEnd("ctx");
  319. var array = Array.isArray(aBlockOrArray) ? aBlockOrArray : [aBlockOrArray];
  320. return array.reduce(function (soFar, aBlock) {
  321. return soFar.then(typeof aBlock === "function" && aBlock.length > 1 ?
  322. function (result) {
  323. if (Array.isArray(result)) {
  324. return aBlock._valueWithPossibleArguments_([result].concat(result.slice(0, aBlock.length-1)));
  325. } else {
  326. return aBlock._value_(result);
  327. }
  328. } :
  329. function (result) {
  330. return aBlock._value_(result);
  331. }
  332. );
  333. }, self);
  334. return self;
  335. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  336. }, function($ctx1) {$ctx1.fill(self,"then:",{aBlockOrArray:aBlockOrArray})});
  337. //>>excludeEnd("ctx");
  338. }; }),
  339. $globals.TThenable);
  340. $core.addMethod(
  341. $core.method({
  342. selector: "then:catch:",
  343. protocol: "promises",
  344. //>>excludeStart("ide", pragmas.excludeIdeData);
  345. args: ["aBlockOrArray", "anotherBlock"],
  346. source: "then: aBlockOrArray catch: anotherBlock\x0a\x09^ (self then: aBlockOrArray) catch: anotherBlock",
  347. referencedClasses: [],
  348. //>>excludeEnd("ide");
  349. pragmas: [],
  350. messageSends: ["catch:", "then:"]
  351. }, function ($methodClass){ return function (aBlockOrArray,anotherBlock){
  352. var self=this,$self=this;
  353. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  354. return $core.withContext(function($ctx1) {
  355. //>>excludeEnd("ctx");
  356. return $recv($self._then_(aBlockOrArray))._catch_(anotherBlock);
  357. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  358. }, function($ctx1) {$ctx1.fill(self,"then:catch:",{aBlockOrArray:aBlockOrArray,anotherBlock:anotherBlock})});
  359. //>>excludeEnd("ctx");
  360. }; }),
  361. $globals.TThenable);
  362. $core.addMethod(
  363. $core.method({
  364. selector: "then:on:do:",
  365. protocol: "promises",
  366. //>>excludeStart("ide", pragmas.excludeIdeData);
  367. args: ["aBlockOrArray", "aClass", "aBlock"],
  368. source: "then: aBlockOrArray on: aClass do: aBlock\x0a\x09^ (self then: aBlockOrArray) on: aClass do: aBlock",
  369. referencedClasses: [],
  370. //>>excludeEnd("ide");
  371. pragmas: [],
  372. messageSends: ["on:do:", "then:"]
  373. }, function ($methodClass){ return function (aBlockOrArray,aClass,aBlock){
  374. var self=this,$self=this;
  375. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  376. return $core.withContext(function($ctx1) {
  377. //>>excludeEnd("ctx");
  378. return $recv($self._then_(aBlockOrArray))._on_do_(aClass,aBlock);
  379. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  380. }, function($ctx1) {$ctx1.fill(self,"then:on:do:",{aBlockOrArray:aBlockOrArray,aClass:aClass,aBlock:aBlock})});
  381. //>>excludeEnd("ctx");
  382. }; }),
  383. $globals.TThenable);
  384. $core.addMethod(
  385. $core.method({
  386. selector: "then:on:do:catch:",
  387. protocol: "promises",
  388. //>>excludeStart("ide", pragmas.excludeIdeData);
  389. args: ["aBlockOrArray", "aClass", "aBlock", "anotherBlock"],
  390. source: "then: aBlockOrArray on: aClass do: aBlock catch: anotherBlock\x0a\x09^ ((self then: aBlockOrArray) on: aClass do: aBlock) catch: anotherBlock",
  391. referencedClasses: [],
  392. //>>excludeEnd("ide");
  393. pragmas: [],
  394. messageSends: ["catch:", "on:do:", "then:"]
  395. }, function ($methodClass){ return function (aBlockOrArray,aClass,aBlock,anotherBlock){
  396. var self=this,$self=this;
  397. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  398. return $core.withContext(function($ctx1) {
  399. //>>excludeEnd("ctx");
  400. return $recv($recv($self._then_(aBlockOrArray))._on_do_(aClass,aBlock))._catch_(anotherBlock);
  401. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  402. }, function($ctx1) {$ctx1.fill(self,"then:on:do:catch:",{aBlockOrArray:aBlockOrArray,aClass:aClass,aBlock:aBlock,anotherBlock:anotherBlock})});
  403. //>>excludeEnd("ctx");
  404. }; }),
  405. $globals.TThenable);
  406. $core.setTraitComposition([{trait: $globals.TThenable}], $globals.Promise);
  407. });