Kernel-Promises.js 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426
  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($self._forBlock_(aBlock)); },\x0a\x09\x09signalIfFails: function (aBlock) { $self._forBlock_(aBlock)._catch_(reject); }\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($self._forBlock_(aBlock)); },\x0a\x09\x09signalIfFails: function (aBlock) { $self._forBlock_(aBlock)._catch_(reject); }\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($self._forBlock_(aBlock)); },
  156. signalIfFails: function (aBlock) { $self._forBlock_(aBlock)._catch_(reject); }
  157. };
  158. aBlock._value_(model);
  159. });
  160. return self;
  161. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  162. }, function($ctx1) {$ctx1.fill(self,"new:",{aBlock:aBlock})});
  163. //>>excludeEnd("ctx");
  164. }; }),
  165. $globals.Promise.a$cls);
  166. $core.addMethod(
  167. $core.method({
  168. selector: "signal:",
  169. protocol: "instance creation",
  170. //>>excludeStart("ide", pragmas.excludeIdeData);
  171. args: ["anObject"],
  172. source: "signal: anObject\x0a\x22Returns a Promise rejected with anObject.\x22\x0a<inlineJS: 'return $recv(anObject)._in_(function (x) {return Promise.reject(x)})'>",
  173. referencedClasses: [],
  174. //>>excludeEnd("ide");
  175. pragmas: [["inlineJS:", ["return $recv(anObject)._in_(function (x) {return Promise.reject(x)})"]]],
  176. messageSends: []
  177. }, function ($methodClass){ return function (anObject){
  178. var self=this,$self=this;
  179. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  180. return $core.withContext(function($ctx1) {
  181. //>>excludeEnd("ctx");
  182. return $recv(anObject)._in_(function (x) {return Promise.reject(x)});
  183. return self;
  184. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  185. }, function($ctx1) {$ctx1.fill(self,"signal:",{anObject:anObject})});
  186. //>>excludeEnd("ctx");
  187. }; }),
  188. $globals.Promise.a$cls);
  189. $core.addMethod(
  190. $core.method({
  191. selector: "value:",
  192. protocol: "instance creation",
  193. //>>excludeStart("ide", pragmas.excludeIdeData);
  194. args: ["anObject"],
  195. source: "value: anObject\x0a\x22Returns a Promise resolved with anObject.\x22\x0a<inlineJS: 'return $recv(anObject)._in_(function (x) {return Promise.resolve(x)})'>",
  196. referencedClasses: [],
  197. //>>excludeEnd("ide");
  198. pragmas: [["inlineJS:", ["return $recv(anObject)._in_(function (x) {return Promise.resolve(x)})"]]],
  199. messageSends: []
  200. }, function ($methodClass){ return function (anObject){
  201. var self=this,$self=this;
  202. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  203. return $core.withContext(function($ctx1) {
  204. //>>excludeEnd("ctx");
  205. return $recv(anObject)._in_(function (x) {return Promise.resolve(x)});
  206. return self;
  207. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  208. }, function($ctx1) {$ctx1.fill(self,"value:",{anObject:anObject})});
  209. //>>excludeEnd("ctx");
  210. }; }),
  211. $globals.Promise.a$cls);
  212. $core.addTrait("TThenable", "Kernel-Promises");
  213. $core.addMethod(
  214. $core.method({
  215. selector: "catch:",
  216. protocol: "promises",
  217. //>>excludeStart("ide", pragmas.excludeIdeData);
  218. args: ["aBlock"],
  219. source: "catch: aBlock\x0a<inlineJS: 'return self.then(null, function (err) { return aBlock._value_(err); })'>",
  220. referencedClasses: [],
  221. //>>excludeEnd("ide");
  222. pragmas: [["inlineJS:", ["return self.then(null, function (err) { return aBlock._value_(err); })"]]],
  223. messageSends: []
  224. }, function ($methodClass){ return function (aBlock){
  225. var self=this,$self=this;
  226. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  227. return $core.withContext(function($ctx1) {
  228. //>>excludeEnd("ctx");
  229. return self.then(null, function (err) { return aBlock._value_(err); });
  230. return self;
  231. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  232. }, function($ctx1) {$ctx1.fill(self,"catch:",{aBlock:aBlock})});
  233. //>>excludeEnd("ctx");
  234. }; }),
  235. $globals.TThenable);
  236. $core.addMethod(
  237. $core.method({
  238. selector: "isThenable",
  239. protocol: "testing",
  240. //>>excludeStart("ide", pragmas.excludeIdeData);
  241. args: [],
  242. source: "isThenable\x0a\x09^ true",
  243. referencedClasses: [],
  244. //>>excludeEnd("ide");
  245. pragmas: [],
  246. messageSends: []
  247. }, function ($methodClass){ return function (){
  248. var self=this,$self=this;
  249. return true;
  250. }; }),
  251. $globals.TThenable);
  252. $core.addMethod(
  253. $core.method({
  254. selector: "on:do:",
  255. protocol: "promises",
  256. //>>excludeStart("ide", pragmas.excludeIdeData);
  257. args: ["aClass", "aBlock"],
  258. 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})'>",
  259. referencedClasses: [],
  260. //>>excludeEnd("ide");
  261. pragmas: [["inlineJS:", ["return self.then(null, function (err) {\x0a if (err._isKindOf_(aClass)) return aBlock._value_(err);\x0a else throw err;\x0a})"]]],
  262. messageSends: []
  263. }, function ($methodClass){ return function (aClass,aBlock){
  264. var self=this,$self=this;
  265. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  266. return $core.withContext(function($ctx1) {
  267. //>>excludeEnd("ctx");
  268. return self.then(null, function (err) {
  269. if (err._isKindOf_(aClass)) return aBlock._value_(err);
  270. else throw err;
  271. });
  272. return self;
  273. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  274. }, function($ctx1) {$ctx1.fill(self,"on:do:",{aClass:aClass,aBlock:aBlock})});
  275. //>>excludeEnd("ctx");
  276. }; }),
  277. $globals.TThenable);
  278. $core.addMethod(
  279. $core.method({
  280. selector: "on:do:catch:",
  281. protocol: "promises",
  282. //>>excludeStart("ide", pragmas.excludeIdeData);
  283. args: ["aClass", "aBlock", "anotherBlock"],
  284. source: "on: aClass do: aBlock catch: anotherBlock\x0a\x09^ (self on: aClass do: aBlock) catch: anotherBlock",
  285. referencedClasses: [],
  286. //>>excludeEnd("ide");
  287. pragmas: [],
  288. messageSends: ["catch:", "on:do:"]
  289. }, function ($methodClass){ return function (aClass,aBlock,anotherBlock){
  290. var self=this,$self=this;
  291. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  292. return $core.withContext(function($ctx1) {
  293. //>>excludeEnd("ctx");
  294. return $recv($self._on_do_(aClass,aBlock))._catch_(anotherBlock);
  295. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  296. }, function($ctx1) {$ctx1.fill(self,"on:do:catch:",{aClass:aClass,aBlock:aBlock,anotherBlock:anotherBlock})});
  297. //>>excludeEnd("ctx");
  298. }; }),
  299. $globals.TThenable);
  300. $core.addMethod(
  301. $core.method({
  302. selector: "then:",
  303. protocol: "promises",
  304. //>>excludeStart("ide", pragmas.excludeIdeData);
  305. args: ["aBlockOrArray"],
  306. 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)'>",
  307. referencedClasses: [],
  308. //>>excludeEnd("ide");
  309. 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)"]]],
  310. messageSends: []
  311. }, function ($methodClass){ return function (aBlockOrArray){
  312. var self=this,$self=this;
  313. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  314. return $core.withContext(function($ctx1) {
  315. //>>excludeEnd("ctx");
  316. var array = Array.isArray(aBlockOrArray) ? aBlockOrArray : [aBlockOrArray];
  317. return array.reduce(function (soFar, aBlock) {
  318. return soFar.then(typeof aBlock === "function" && aBlock.length > 1 ?
  319. function (result) {
  320. if (Array.isArray(result)) {
  321. return aBlock._valueWithPossibleArguments_([result].concat(result.slice(0, aBlock.length-1)));
  322. } else {
  323. return aBlock._value_(result);
  324. }
  325. } :
  326. function (result) {
  327. return aBlock._value_(result);
  328. }
  329. );
  330. }, self);
  331. return self;
  332. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  333. }, function($ctx1) {$ctx1.fill(self,"then:",{aBlockOrArray:aBlockOrArray})});
  334. //>>excludeEnd("ctx");
  335. }; }),
  336. $globals.TThenable);
  337. $core.addMethod(
  338. $core.method({
  339. selector: "then:catch:",
  340. protocol: "promises",
  341. //>>excludeStart("ide", pragmas.excludeIdeData);
  342. args: ["aBlockOrArray", "anotherBlock"],
  343. source: "then: aBlockOrArray catch: anotherBlock\x0a\x09^ (self then: aBlockOrArray) catch: anotherBlock",
  344. referencedClasses: [],
  345. //>>excludeEnd("ide");
  346. pragmas: [],
  347. messageSends: ["catch:", "then:"]
  348. }, function ($methodClass){ return function (aBlockOrArray,anotherBlock){
  349. var self=this,$self=this;
  350. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  351. return $core.withContext(function($ctx1) {
  352. //>>excludeEnd("ctx");
  353. return $recv($self._then_(aBlockOrArray))._catch_(anotherBlock);
  354. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  355. }, function($ctx1) {$ctx1.fill(self,"then:catch:",{aBlockOrArray:aBlockOrArray,anotherBlock:anotherBlock})});
  356. //>>excludeEnd("ctx");
  357. }; }),
  358. $globals.TThenable);
  359. $core.addMethod(
  360. $core.method({
  361. selector: "then:on:do:",
  362. protocol: "promises",
  363. //>>excludeStart("ide", pragmas.excludeIdeData);
  364. args: ["aBlockOrArray", "aClass", "aBlock"],
  365. source: "then: aBlockOrArray on: aClass do: aBlock\x0a\x09^ (self then: aBlockOrArray) on: aClass do: aBlock",
  366. referencedClasses: [],
  367. //>>excludeEnd("ide");
  368. pragmas: [],
  369. messageSends: ["on:do:", "then:"]
  370. }, function ($methodClass){ return function (aBlockOrArray,aClass,aBlock){
  371. var self=this,$self=this;
  372. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  373. return $core.withContext(function($ctx1) {
  374. //>>excludeEnd("ctx");
  375. return $recv($self._then_(aBlockOrArray))._on_do_(aClass,aBlock);
  376. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  377. }, function($ctx1) {$ctx1.fill(self,"then:on:do:",{aBlockOrArray:aBlockOrArray,aClass:aClass,aBlock:aBlock})});
  378. //>>excludeEnd("ctx");
  379. }; }),
  380. $globals.TThenable);
  381. $core.addMethod(
  382. $core.method({
  383. selector: "then:on:do:catch:",
  384. protocol: "promises",
  385. //>>excludeStart("ide", pragmas.excludeIdeData);
  386. args: ["aBlockOrArray", "aClass", "aBlock", "anotherBlock"],
  387. source: "then: aBlockOrArray on: aClass do: aBlock catch: anotherBlock\x0a\x09^ ((self then: aBlockOrArray) on: aClass do: aBlock) catch: anotherBlock",
  388. referencedClasses: [],
  389. //>>excludeEnd("ide");
  390. pragmas: [],
  391. messageSends: ["catch:", "on:do:", "then:"]
  392. }, function ($methodClass){ return function (aBlockOrArray,aClass,aBlock,anotherBlock){
  393. var self=this,$self=this;
  394. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  395. return $core.withContext(function($ctx1) {
  396. //>>excludeEnd("ctx");
  397. return $recv($recv($self._then_(aBlockOrArray))._on_do_(aClass,aBlock))._catch_(anotherBlock);
  398. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  399. }, function($ctx1) {$ctx1.fill(self,"then:on:do:catch:",{aBlockOrArray:aBlockOrArray,aClass:aClass,aBlock:aBlock,anotherBlock:anotherBlock})});
  400. //>>excludeEnd("ctx");
  401. }; }),
  402. $globals.TThenable);
  403. $core.setTraitComposition([{trait: $globals.TThenable}], $globals.Promise);
  404. });