aboutsummaryrefslogtreecommitdiff
path: root/node_modules/release-zalgo/lib
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/release-zalgo/lib')
-rw-r--r--node_modules/release-zalgo/lib/Async.js21
-rw-r--r--node_modules/release-zalgo/lib/Sync.js24
-rw-r--r--node_modules/release-zalgo/lib/Thenable.js39
-rw-r--r--node_modules/release-zalgo/lib/constants.js6
-rw-r--r--node_modules/release-zalgo/lib/unwrapSync.js54
5 files changed, 0 insertions, 144 deletions
diff --git a/node_modules/release-zalgo/lib/Async.js b/node_modules/release-zalgo/lib/Async.js
deleted file mode 100644
index 846f7add0..000000000
--- a/node_modules/release-zalgo/lib/Async.js
+++ /dev/null
@@ -1,21 +0,0 @@
-'use strict'
-
-class Async {
- run (executors) {
- const args = Array.from(arguments).slice(1)
- return new Promise(resolve => resolve(executors.async.apply(null, args)))
- }
-
- all (arr) {
- return Promise.all(arr)
- }
-
- returns (value) {
- return Promise.resolve(value)
- }
-
- throws (reason) {
- return Promise.reject(reason)
- }
-}
-module.exports = Async
diff --git a/node_modules/release-zalgo/lib/Sync.js b/node_modules/release-zalgo/lib/Sync.js
deleted file mode 100644
index d081d5f59..000000000
--- a/node_modules/release-zalgo/lib/Sync.js
+++ /dev/null
@@ -1,24 +0,0 @@
-'use strict'
-
-const Thenable = require('./Thenable')
-const unwrapSync = require('./unwrapSync')
-
-class Sync {
- run (executors) {
- const args = Array.from(arguments).slice(1)
- return new Thenable(() => executors.sync.apply(null, args))
- }
-
- all (arr) {
- return new Thenable(() => arr.map(value => unwrapSync(value)))
- }
-
- returns (value) {
- return new Thenable(() => value)
- }
-
- throws (reason) {
- return new Thenable(() => { throw reason })
- }
-}
-module.exports = Sync
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
diff --git a/node_modules/release-zalgo/lib/constants.js b/node_modules/release-zalgo/lib/constants.js
deleted file mode 100644
index 8c417b5fa..000000000
--- a/node_modules/release-zalgo/lib/constants.js
+++ /dev/null
@@ -1,6 +0,0 @@
-'use strict'
-
-exports.PENDING = Symbol('PENDING')
-exports.RESOLVED = Symbol('RESOLVED')
-exports.REJECTED = Symbol('REJECTED')
-exports.ASYNC = Symbol('ASYNC')
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