This commit is contained in:
lalBi94
2023-03-05 13:23:23 +01:00
commit 7bc56c09b5
14034 changed files with 1834369 additions and 0 deletions

21
node_modules/release-zalgo/lib/Async.js generated vendored Normal file
View File

@@ -0,0 +1,21 @@
'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

24
node_modules/release-zalgo/lib/Sync.js generated vendored Normal file
View File

@@ -0,0 +1,24 @@
'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

39
node_modules/release-zalgo/lib/Thenable.js generated vendored Normal file
View File

@@ -0,0 +1,39 @@
'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

6
node_modules/release-zalgo/lib/constants.js generated vendored Normal file
View File

@@ -0,0 +1,6 @@
'use strict'
exports.PENDING = Symbol('PENDING')
exports.RESOLVED = Symbol('RESOLVED')
exports.REJECTED = Symbol('REJECTED')
exports.ASYNC = Symbol('ASYNC')

54
node_modules/release-zalgo/lib/unwrapSync.js generated vendored Normal file
View File

@@ -0,0 +1,54 @@
'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