mirror of
https://github.com/hanzoai/agency.git
synced 2026-11-02 19:13:28 +00:00
75 lines
2.0 KiB
Plaintext
75 lines
2.0 KiB
Plaintext
"use strict";
|
|
var __defProp = Object.defineProperty;
|
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
var __export = (target, all) => {
|
|
for (var name in all)
|
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
};
|
|
var __copyProps = (to, from, except, desc) => {
|
|
if (from && typeof from === "object" || typeof from === "function") {
|
|
for (let key of __getOwnPropNames(from))
|
|
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
}
|
|
return to;
|
|
};
|
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
|
|
// src/thenable.ts
|
|
var thenable_exports = {};
|
|
__export(thenable_exports, {
|
|
pendingThenable: () => pendingThenable,
|
|
tryResolveSync: () => tryResolveSync
|
|
});
|
|
module.exports = __toCommonJS(thenable_exports);
|
|
var import_utils = require("./utils.cjs");
|
|
function pendingThenable() {
|
|
let resolve;
|
|
let reject;
|
|
const thenable = new Promise((_resolve, _reject) => {
|
|
resolve = _resolve;
|
|
reject = _reject;
|
|
});
|
|
thenable.status = "pending";
|
|
thenable.catch(() => {
|
|
});
|
|
function finalize(data) {
|
|
Object.assign(thenable, data);
|
|
delete thenable.resolve;
|
|
delete thenable.reject;
|
|
}
|
|
thenable.resolve = (value) => {
|
|
finalize({
|
|
status: "fulfilled",
|
|
value
|
|
});
|
|
resolve(value);
|
|
};
|
|
thenable.reject = (reason) => {
|
|
finalize({
|
|
status: "rejected",
|
|
reason
|
|
});
|
|
reject(reason);
|
|
};
|
|
return thenable;
|
|
}
|
|
function tryResolveSync(promise) {
|
|
let data;
|
|
promise.then((result) => {
|
|
data = result;
|
|
return result;
|
|
}, import_utils.noop)?.catch(import_utils.noop);
|
|
if (data !== void 0) {
|
|
return { data };
|
|
}
|
|
return void 0;
|
|
}
|
|
// Annotate the CommonJS export names for ESM import in node:
|
|
0 && (module.exports = {
|
|
pendingThenable,
|
|
tryResolveSync
|
|
});
|
|
//# sourceMappingURL=thenable.cjs.map |