From 1720ce081c47897b8429a5098ffb6f9cc71fafcd Mon Sep 17 00:00:00 2001 From: Closure Team Date: Mon, 29 Nov 2021 09:09:26 -0800 Subject: [PATCH] [Closure] Convert `goog.promise.Resolver` to `goog.module` and to ES6. RELNOTES: n/a PiperOrigin-RevId: 412903963 Change-Id: Ib71d583308c6154c111c9e78f2c3c0aa97b0d25a --- closure/goog/promise/resolver.js | 55 +++++++++++++++----------------- 1 file changed, 26 insertions(+), 29 deletions(-) diff --git a/closure/goog/promise/resolver.js b/closure/goog/promise/resolver.js index febf793fd4..939027532d 100644 --- a/closure/goog/promise/resolver.js +++ b/closure/goog/promise/resolver.js @@ -3,40 +3,37 @@ * Copyright The Closure Library Authors. * SPDX-License-Identifier: Apache-2.0 */ +goog.module('goog.promise.Resolver'); +goog.module.declareLegacyNamespace(); -goog.provide('goog.promise.Resolver'); - -goog.requireType('goog.Promise'); - - +const GoogPromise = goog.requireType('goog.Promise'); +const Thenable = goog.requireType('goog.Thenable'); /** * Resolver interface for promises. The resolver is a convenience interface that * bundles the promise and its associated resolve and reject functions together, * for cases where the resolver needs to be persisted internally. - * - * @interface * @template TYPE + * @interface */ -goog.promise.Resolver = function() {}; - - -/** - * The promise that created this resolver. - * @type {!goog.Promise} - */ -goog.promise.Resolver.prototype.promise; - - -/** - * Resolves this resolver with the specified value. - * @type {function((TYPE|goog.Promise|Thenable)=)} - */ -goog.promise.Resolver.prototype.resolve; - - -/** - * Rejects this resolver with the specified reason. - * @type {function(*=): void} - */ -goog.promise.Resolver.prototype.reject; +class Resolver { + constructor() { + /** + * The promise that created this resolver. + * @type {!GoogPromise} + */ + this.promise; + /** + * Resolves this resolver with the specified value. + * @type {function((TYPE|GoogPromise|Promise|IThenable|Thenable)=)} + */ + this.resolve; + /** + * Rejects this resolver with the specified reason. + * @type {function(*=): void} + */ + this.reject; + } +} + +exports = Resolver;