[gjs] promise: Fix ES6 compatibility
- From: Philip Chimento <pchimento src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gjs] promise: Fix ES6 compatibility
- Date: Thu, 16 Feb 2017 04:52:18 +0000 (UTC)
commit ee99b27efacd3ac21b3495e572b26707d10bdf9c
Author: Philip Chimento <philip chimento gmail com>
Date: Mon Jan 16 22:10:53 2017 -0800
promise: Fix ES6 compatibility
The promises-es6 tests mandate a few checks on the input argument to "new
Promise()".
https://bugzilla.gnome.org/show_bug.cgi?id=608450
modules/_lie.js | 6 ++++++
1 files changed, 6 insertions(+), 0 deletions(-)
---
diff --git a/modules/_lie.js b/modules/_lie.js
index 0e69a53..602b52d 100644
--- a/modules/_lie.js
+++ b/modules/_lie.js
@@ -69,9 +69,15 @@ if (!process.browser) {
// module.exports = Promise; // removed for GJS
function Promise(resolver) {
+ if (typeof this !== 'object') {
+ throw new TypeError('this must be an object');
+ }
if (typeof resolver !== 'function') {
throw new TypeError('resolver must be a function');
}
+ if (this instanceof Promise && typeof this.state !== 'undefined') {
+ throw new TypeError('this must not be an already-constructed promise');
+ }
this.state = PENDING;
this.queue = [];
this.outcome = void 0;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]