decord/source/178_valuePromise.js

257 lines
6.7 KiB
JavaScript
Raw Normal View History

2026-07-29 08:29:29 +00:00
// Module ID: 178
// Function ID: 179
// Name: valuePromise
// Dependencies: [177]
// Module 178 (valuePromise)
2026-08-24 06:08:38 +00:00
import noop from "noop" /* 177 */;
2026-07-29 08:29:29 +00:00
function valuePromise(_z) {
2026-08-24 06:08:38 +00:00
let tmp = noop;
tmp = new tmp(noop._D);
2026-07-29 08:29:29 +00:00
tmp._y = 1;
tmp._z = _z;
return tmp;
}
function onSettledFulfill(value) {
return { status: "fulfilled", value };
}
function onSettledReject(reason) {
return { status: "rejected", reason };
}
2026-08-04 21:03:28 +00:00
function mapAllSettled(value) {
if (value) {
if (typeof value === "object") {
2026-08-24 06:08:38 +00:00
if (value instanceof noop) {
2026-08-04 21:03:28 +00:00
if (value.then === tmp(177).prototype.then) {
return value.then(onSettledFulfill, onSettledReject);
2026-07-29 08:29:29 +00:00
}
}
2026-08-04 21:03:28 +00:00
const then = value.then;
if (typeof then === "function") {
2026-07-29 08:29:29 +00:00
let tmpResult = tmp(177);
2026-08-04 21:03:28 +00:00
tmpResult = new tmpResult(then.bind(value));
2026-07-29 08:29:29 +00:00
return tmpResult.then(onSettledFulfill, onSettledReject);
}
}
}
2026-08-04 21:03:28 +00:00
return { status: "fulfilled", value };
2026-07-29 08:29:29 +00:00
}
2026-08-24 06:08:38 +00:00
noop = new noop(noop._D);
2026-07-29 08:29:29 +00:00
noop._y = 1;
noop._z = true;
2026-08-24 06:08:38 +00:00
noop = new noop(noop._D);
2026-07-29 08:29:29 +00:00
noop._y = 1;
noop._z = false;
2026-08-24 06:08:38 +00:00
noop = new noop(noop._D);
2026-07-29 08:29:29 +00:00
noop._y = 1;
noop._z = null;
2026-08-24 06:08:38 +00:00
noop = new noop(noop._D);
2026-07-29 08:29:29 +00:00
noop._y = 1;
noop._z = undefined;
2026-08-24 06:08:38 +00:00
noop = new noop(noop._D);
2026-07-29 08:29:29 +00:00
noop._y = 1;
noop._z = 0;
2026-08-24 06:08:38 +00:00
noop = new noop(noop._D);
2026-07-29 08:29:29 +00:00
noop._y = 1;
noop._z = "";
2026-08-24 06:08:38 +00:00
noop.resolve = (self) => {
if (self instanceof noop) {
2026-07-29 08:29:29 +00:00
return self;
} else if (null === self) {
return noop;
} else if (undefined === self) {
return noop;
} else if (true === self) {
return noop;
} else if (false === self) {
return noop;
} else if (0 === self) {
return noop;
} else if ("" === self) {
return noop;
} else {
2026-08-04 21:03:28 +00:00
if (typeof self === "object") {
2026-07-29 08:29:29 +00:00
try {
const then = self.then;
2026-08-04 21:03:28 +00:00
if (typeof then === "function") {
2026-08-24 06:08:38 +00:00
let tmp4Result = noop;
2026-07-29 08:29:29 +00:00
tmp4Result = new tmp4Result(obj.bind(self));
return tmp4Result;
}
obj = then;
} catch (tmp14) {
require = tmp14;
const tmp17 = new tmp2(tmp[0])((arg0, arg1) => {
arg1(closure_0);
});
return tmp17;
}
}
return valuePromise(self);
}
2026-08-24 06:08:38 +00:00
const tmp4 = require;
2026-07-29 08:29:29 +00:00
};
function iterableToArray(arg0) {
2026-08-04 21:03:28 +00:00
if (typeof Array.from === "function") {
2026-07-29 08:29:29 +00:00
const _Array = Array;
2026-08-24 06:08:38 +00:00
iterableToArray = Array.from;
2026-07-29 08:29:29 +00:00
const _Array2 = Array;
let arr = Array.from(arg0);
} else {
iterableToArray = function iterableToArray(arg0) {
const call = slice.call;
return typeof call === "unknown" ? slice() : call(arg0);
};
const _Array3 = Array;
let call = slice.call;
arr = typeof call === "unknown" ? slice() : call(arg0);
}
return arr;
}
2026-08-24 06:08:38 +00:00
noop.all = (arg0) => {
2026-07-29 08:29:29 +00:00
const _require = iterableToArray(arg0);
return new _require(177)((arg0, arg1) => {
2026-08-24 06:08:38 +00:00
closure_0 = arg0;
closure_1 = arg1;
2026-08-04 21:03:28 +00:00
function res(arg0, self) {
let _y;
2026-07-29 08:29:29 +00:00
const callback = arg0;
2026-08-04 21:03:28 +00:00
if (self) {
if (typeof self === "object") {
2026-08-24 06:08:38 +00:00
if (self instanceof callback(closure_2_1[0])) {
2026-08-04 21:03:28 +00:00
if (self.then === tmp(tmp2[0]).prototype.then) {
let tmp13 = self;
let promise2 = self;
if (3 === self._y) {
2026-07-29 08:29:29 +00:00
do {
let _z = tmp13._z;
tmp13 = _z;
promise2 = _z;
_y = _z._y;
} while (3 === _y);
}
if (1 === promise2._y) {
const tmp18 = res(arg0, promise2._z);
} else {
if (2 === promise2._y) {
callback2(promise2._z);
}
promise2.then((arg0) => {
2026-08-24 06:08:38 +00:00
closure_1_3(closure_0, arg0);
2026-07-29 08:29:29 +00:00
}, callback2);
}
return tmp18;
}
}
2026-08-04 21:03:28 +00:00
const then = self.then;
if (typeof then === "function") {
2026-07-29 08:29:29 +00:00
let tmpResult = tmp(tmp2[0]);
2026-08-04 21:03:28 +00:00
tmpResult = new tmpResult(then.bind(self));
2026-07-29 08:29:29 +00:00
tmpResult.then((arg0) => {
2026-08-24 06:08:38 +00:00
closure_1_3(closure_0, arg0);
2026-07-29 08:29:29 +00:00
}, callback2);
}
}
}
2026-08-04 21:03:28 +00:00
callback[arg0] = self;
2026-07-29 08:29:29 +00:00
diff = diff - 1;
if (0 == diff) {
callback(tmp3);
}
}
if (0 === closure_0.length) {
return arg0([]);
} else {
let length = arr.length;
let num2 = 0;
if (0 < arr.length) {
do {
let tmp = closure_0;
let resResult = res(num2, closure_0[num2]);
num2 = num2 + 1;
length = closure_0.length;
} while (num2 < length);
}
}
});
};
2026-08-24 06:08:38 +00:00
noop.allSettled = (arg0) => {
const obj = noop;
2026-07-29 08:29:29 +00:00
return obj.all(iterableToArray(arg0).map(mapAllSettled));
};
2026-08-24 06:08:38 +00:00
noop.reject = (arg0) => {
2026-07-29 08:29:29 +00:00
const _require = arg0;
return new _require(177)((arg0, arg1) => {
arg1(closure_0);
});
};
2026-08-24 06:08:38 +00:00
noop.race = (arg0) => {
2026-07-29 08:29:29 +00:00
const _require = arg0;
return new _require(177)((arg0, arg1) => {
2026-08-24 06:08:38 +00:00
closure_0 = arg0;
closure_1 = arg1;
const item = closure_1_9(closure_0).forEach((arg0) => {
2026-07-29 08:29:29 +00:00
const obj = callback(table[0]);
callback(table[0]).resolve(arg0).then(callback, table);
});
});
};
2026-08-24 06:08:38 +00:00
noop.prototype.catch = function(arg0) {
2026-07-29 08:29:29 +00:00
return this.then(null, arg0);
};
2026-08-24 06:08:38 +00:00
noop.any = function promiseAny(arg0) {
2026-07-29 08:29:29 +00:00
const _require = arg0;
return new _require(177)((arg0, arg1) => {
2026-08-24 06:08:38 +00:00
closure_0 = arg0;
closure_1 = arg1;
2026-07-29 08:29:29 +00:00
function resolveOnce(arg0) {
if (!c3) {
c3 = true;
callback(arg0);
}
}
function rejectionCheck(arg0) {
if (items.length === arr.length) {
let aggregateError = globalThis;
2026-08-04 21:03:28 +00:00
if (typeof globalThis.AggregateError === "function") {
2026-07-29 08:29:29 +00:00
aggregateError = new aggregateError.AggregateError(tmp, "All promises were rejected");
let tmp8 = aggregateError;
} else {
const _Error = Error;
2026-08-24 06:08:38 +00:00
error = new Error("All promises were rejected");
2026-07-29 08:29:29 +00:00
tmp8 = error;
error.name = "AggregateError";
error.errors = tmp;
}
closure_1(tmp8);
const tmp3 = closure_1;
}
}
2026-08-24 06:08:38 +00:00
const arr = closure_1_9(closure_0);
c3 = false;
2026-07-29 08:29:29 +00:00
const items = [];
if (0 === arr.length) {
let aggregateError = globalThis;
2026-08-04 21:03:28 +00:00
if (typeof globalThis.AggregateError === "function") {
2026-07-29 08:29:29 +00:00
aggregateError = new aggregateError.AggregateError(items, "All promises were rejected");
let tmp6 = aggregateError;
} else {
let _Error = Error;
2026-08-24 06:08:38 +00:00
error = new Error("All promises were rejected");
2026-07-29 08:29:29 +00:00
tmp6 = error;
error.name = "AggregateError";
error.errors = items;
}
arg1(tmp6);
} else {
const item = arr.forEach((arg0) => {
const obj = callback(table[0]);
callback(table[0]).resolve(arg0).then(resolveOnce, rejectionCheck);
});
}
});
};
2026-08-24 06:08:38 +00:00
export default noop;