mirror of
https://github.com/Sevichecc/Urara-Blog.git
synced 2025-05-04 01:19:30 +08:00
28 lines
803 B
Text
28 lines
803 B
Text
/*
|
|
Copyright 2018 Google LLC
|
|
|
|
Use of this source code is governed by an MIT-style
|
|
license that can be found in the LICENSE file or at
|
|
https://opensource.org/licenses/MIT.
|
|
*/
|
|
import '../_version.js';
|
|
/**
|
|
* The Deferred class composes Promises in a way that allows for them to be
|
|
* resolved or rejected from outside the constructor. In most cases promises
|
|
* should be used directly, but Deferreds can be necessary when the logic to
|
|
* resolve a promise must be separate.
|
|
*
|
|
* @private
|
|
*/
|
|
class Deferred {
|
|
/**
|
|
* Creates a promise and exposes its resolve and reject functions as methods.
|
|
*/
|
|
constructor() {
|
|
this.promise = new Promise((resolve, reject) => {
|
|
this.resolve = resolve;
|
|
this.reject = reject;
|
|
});
|
|
}
|
|
}
|
|
export { Deferred };
|