|
@@ -2,6 +2,7 @@ package goja
|
|
|
|
|
|
import (
|
|
|
"github.com/dop251/goja/unistring"
|
|
|
+ "reflect"
|
|
|
)
|
|
|
|
|
|
type PromiseState int
|
|
@@ -42,6 +43,8 @@ type promiseReaction struct {
|
|
|
handler *jobCallback
|
|
|
}
|
|
|
|
|
|
+var typePromise = reflect.TypeOf((*Promise)(nil))
|
|
|
+
|
|
|
// Promise is a Go wrapper around ECMAScript Promise. Calling Runtime.ToValue() on it
|
|
|
// returns the underlying Object. Calling Export() on a Promise Object returns a Promise.
|
|
|
//
|
|
@@ -136,6 +139,14 @@ func (p *Promise) fulfill(value Value) Value {
|
|
|
return _undefined
|
|
|
}
|
|
|
|
|
|
+func (p *Promise) exportType() reflect.Type {
|
|
|
+ return typePromise
|
|
|
+}
|
|
|
+
|
|
|
+func (p *Promise) export(*objectExportCtx) interface{} {
|
|
|
+ return p
|
|
|
+}
|
|
|
+
|
|
|
func (r *Runtime) newPromiseResolveThenableJob(p *Promise, thenable Value, then *jobCallback) func() {
|
|
|
return func() {
|
|
|
resolve, reject := p.createResolvingFunctions()
|