Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 20s
Build & Deploy / 🧪 QA (push) Failing after 34s
Build & Deploy / 🏗️ Build (push) Has started running
Build & Deploy / 🚀 Deploy (push) Has been cancelled
Build & Deploy / 🧪 Smoke Test (push) Has been cancelled
Build & Deploy / ⚡ Lighthouse (push) Has been cancelled
Build & Deploy / 🔔 Notify (push) Has been cancelled
29 lines
570 B
Plaintext
29 lines
570 B
Plaintext
'use strict'
|
|
|
|
/**
|
|
* @template {*} T
|
|
* @typedef {Object} DeferredPromise
|
|
* @property {Promise<T>} promise
|
|
* @property {(value?: T) => void} resolve
|
|
* @property {(reason?: any) => void} reject
|
|
*/
|
|
|
|
/**
|
|
* @template {*} T
|
|
* @returns {DeferredPromise<T>} An object containing a promise and its resolve/reject methods.
|
|
*/
|
|
function createDeferredPromise () {
|
|
let res
|
|
let rej
|
|
const promise = new Promise((resolve, reject) => {
|
|
res = resolve
|
|
rej = reject
|
|
})
|
|
|
|
return { promise, resolve: res, reject: rej }
|
|
}
|
|
|
|
module.exports = {
|
|
createDeferredPromise
|
|
}
|