aboutsummaryrefslogtreecommitdiff
path: root/node_modules/release-zalgo/lib/unwrapSync.js
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2019-03-27 21:01:33 +0100
committerFlorian Dold <florian.dold@gmail.com>2019-03-27 21:01:33 +0100
commitcc97a4dd2a967e1c2273bd5f4c5f49a5bf2e2585 (patch)
tree92c5d88706a6ffc654d1b133618d357890e7096b /node_modules/release-zalgo/lib/unwrapSync.js
parent3771b4d6b67b34c130f3a9a1a15f42deefdb2eda (diff)
remove node_modules
Diffstat (limited to 'node_modules/release-zalgo/lib/unwrapSync.js')
-rw-r--r--node_modules/release-zalgo/lib/unwrapSync.js54
1 files changed, 0 insertions, 54 deletions
diff --git a/node_modules/release-zalgo/lib/unwrapSync.js b/node_modules/release-zalgo/lib/unwrapSync.js
deleted file mode 100644
index baa130b18..000000000
--- a/node_modules/release-zalgo/lib/unwrapSync.js
+++ /dev/null
@@ -1,54 +0,0 @@
-'use strict'
-
-const ExtendableError = require('es6-error')
-
-const constants = require('./constants')
-
-class UnwrapError extends ExtendableError {
- constructor (thenable) {
- super('Could not unwrap asynchronous thenable')
- this.thenable = thenable
- }
-}
-
-// Logic is derived from the Promise Resolution Procedure, as described in the
-// Promises/A+ specification: https://promisesaplus.com/#point-45
-//
-// Note that there is no cycle detection.
-function unwrapSync (x) {
- if (!x || typeof x !== 'object' && typeof x !== 'function') {
- return x
- }
-
- const then = x.then
- if (typeof then !== 'function') return x
-
- let state = constants.PENDING
- let value
- const unwrapValue = y => {
- if (state === constants.PENDING) {
- state = constants.RESOLVED
- value = y
- }
- }
- const unwrapReason = r => {
- if (state === constants.PENDING) {
- state = constants.REJECTED
- value = r
- }
- }
- then.call(x, unwrapValue, unwrapReason)
-
- if (state === constants.PENDING) {
- state = constants.ASYNC
- throw new UnwrapError(x)
- }
-
- if (state === constants.RESOLVED) {
- return unwrapSync(value)
- }
-
- // state === REJECTED
- throw value
-}
-module.exports = unwrapSync