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
23 lines
495 B
Plaintext
23 lines
495 B
Plaintext
import next from "./next.js";
|
|
|
|
type MaybeParams<T> = (err: Error | any | null, result?: T) => void;
|
|
export default function maybe<T>(cb: MaybeParams<T> | undefined, promise: Promise<T>): Promise<T> | void {
|
|
if (cb) {
|
|
promise.then(
|
|
function (result) {
|
|
next(function () {
|
|
cb(null, result);
|
|
});
|
|
},
|
|
function (err) {
|
|
next(function () {
|
|
cb(err);
|
|
});
|
|
},
|
|
);
|
|
return undefined;
|
|
} else {
|
|
return promise;
|
|
}
|
|
}
|