diff options
author | Florian Dold <florian.dold@gmail.com> | 2019-03-27 21:01:33 +0100 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2019-03-27 21:01:33 +0100 |
commit | cc97a4dd2a967e1c2273bd5f4c5f49a5bf2e2585 (patch) | |
tree | 92c5d88706a6ffc654d1b133618d357890e7096b /node_modules/release-zalgo/lib/Thenable.js | |
parent | 3771b4d6b67b34c130f3a9a1a15f42deefdb2eda (diff) |
remove node_modules
Diffstat (limited to 'node_modules/release-zalgo/lib/Thenable.js')
-rw-r--r-- | node_modules/release-zalgo/lib/Thenable.js | 39 |
1 files changed, 0 insertions, 39 deletions
diff --git a/node_modules/release-zalgo/lib/Thenable.js b/node_modules/release-zalgo/lib/Thenable.js deleted file mode 100644 index 7a809b266..000000000 --- a/node_modules/release-zalgo/lib/Thenable.js +++ /dev/null @@ -1,39 +0,0 @@ -'use strict' - -const constants = require('./constants') -const unwrapSync = require('./unwrapSync') - -// Behaves like a Promise, though the then() and catch() methods are unbound and -// must be called with the instance as their thisArg. -// -// The executor must either return a value or throw a rejection reason. It is -// not provided resolver or rejecter methods. The executor may return another -// thenable. -class Thenable { - constructor (executor) { - try { - this.result = unwrapSync(executor()) - this.state = constants.RESOLVED - } catch (err) { - this.result = err - this.state = constants.REJECTED - } - } - - then (onFulfilled, onRejected) { - if (this.state === constants.RESOLVED && typeof onFulfilled === 'function') { - return new Thenable(() => onFulfilled(this.result)) - } - - if (this.state === constants.REJECTED && typeof onRejected === 'function') { - return new Thenable(() => onRejected(this.result)) - } - - return this - } - - catch (onRejected) { - return this.then(null, onRejected) - } -} -module.exports = Thenable |