toJS property
A JSPromise that either resolves with the result of the completed Future or rejects with its error if it is a JS value and otherwise rejects with a JSWrappedPromiseError that wraps its Dart error value.
Implementation
JSPromise<T> get toJS {
return JSPromise<T>(
(JSFunction resolve, JSFunction reject) {
this.then(
(JSAny? value) {
resolve.callAsFunction(resolve, value);
return value;
},
onError: (Object error, StackTrace stackTrace) {
final jsError = _convertError(error, stackTrace);
reject.callAsFunction(reject, jsError);
return jsError;
},
);
}.toJS,
);
}