|
@@ -389,6 +389,29 @@ return $recv(aValuable)._value_($self.jsObject);
|
|
|
}; }),
|
|
|
$globals.JSObjectProxy);
|
|
|
|
|
|
+$core.addMethod(
|
|
|
+$core.method({
|
|
|
+selector: "isThenable",
|
|
|
+protocol: "testing",
|
|
|
+
|
|
|
+args: [],
|
|
|
+source: "isThenable\x0a\x09^ NativeFunction isNativeFunction: (self at: #then)",
|
|
|
+referencedClasses: ["NativeFunction"],
|
|
|
+
|
|
|
+pragmas: [],
|
|
|
+messageSends: ["isNativeFunction:", "at:"]
|
|
|
+}, function ($methodClass){ return function (){
|
|
|
+var self=this,$self=this;
|
|
|
+
|
|
|
+return $core.withContext(function($ctx1) {
|
|
|
+
|
|
|
+return $recv($globals.NativeFunction)._isNativeFunction_($self._at_("then"));
|
|
|
+
|
|
|
+}, function($ctx1) {$ctx1.fill(self,"isThenable",{})});
|
|
|
+
|
|
|
+}; }),
|
|
|
+$globals.JSObjectProxy);
|
|
|
+
|
|
|
$core.addMethod(
|
|
|
$core.method({
|
|
|
selector: "jsObject",
|
|
@@ -579,17 +602,17 @@ selector: "then:",
|
|
|
protocol: "promises",
|
|
|
|
|
|
args: ["aBlockOrArray"],
|
|
|
-source: "then: aBlockOrArray\x0a(NativeFunction isNativeFunction: (self at: #then))\x0a\x09ifTrue: [ ^ (TThenable >> #then:) sendTo: jsObject arguments: {aBlockOrArray} ]\x0a\x09ifFalse: [ ^ super then: aBlockOrArray ]",
|
|
|
-referencedClasses: ["NativeFunction", "TThenable"],
|
|
|
+source: "then: aBlockOrArray\x0aself isThenable\x0a\x09ifTrue: [ ^ (TThenable >> #then:) sendTo: jsObject arguments: {aBlockOrArray} ]\x0a\x09ifFalse: [ ^ super then: aBlockOrArray ]",
|
|
|
+referencedClasses: ["TThenable"],
|
|
|
|
|
|
pragmas: [],
|
|
|
-messageSends: ["ifTrue:ifFalse:", "isNativeFunction:", "at:", "sendTo:arguments:", ">>", "then:"]
|
|
|
+messageSends: ["ifTrue:ifFalse:", "isThenable", "sendTo:arguments:", ">>", "then:"]
|
|
|
}, function ($methodClass){ return function (aBlockOrArray){
|
|
|
var self=this,$self=this;
|
|
|
|
|
|
return $core.withContext(function($ctx1) {
|
|
|
|
|
|
-if($core.assert($recv($globals.NativeFunction)._isNativeFunction_($self._at_("then")))){
|
|
|
+if($core.assert($self._isThenable())){
|
|
|
return $recv($recv($globals.TThenable).__gt_gt("then:"))._sendTo_arguments_($self.jsObject,[aBlockOrArray]);
|
|
|
} else {
|
|
|
return [(
|