awaitIfThenable function

Future<void> awaitIfThenable(
  1. JSAny? result
)

Awaits result when it is a thenable: delete() is a Promise in the typings of 0.18.0 and 0.19.0, but nothing here relies on it.

Implementation

Future<void> awaitIfThenable(JSAny? result) async {
  if (result != null &&
      result.isA<JSObject>() &&
      ((result as JSObject)['then']?.typeofEquals('function') ?? false)) {
    await (result as JSPromise<JSAny?>).toDart;
  }
}