@synstack/resolved
Version:
Type-safe piping of synchronous or asynchronous values
37 lines (35 loc) • 1.1 kB
JavaScript
var __defProp = Object.defineProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
// src/callable/callable.bundle.ts
var callable_bundle_exports = {};
__export(callable_bundle_exports, {
resolveNested: () => resolveNested
});
// src/callable/callable.lib.ts
var resolveNested = (args) => {
if (args.length === 0) return [];
const unresolvedValues = args.map((v) => {
if (typeof v === "function") return v();
if (Array.isArray(v))
return v.map((sv) => typeof sv === "function" ? sv() : sv);
return v;
});
const isPromise = unresolvedValues.some((v) => {
if (v instanceof Promise) return true;
if (Array.isArray(v)) return v.some((v2) => v2 instanceof Promise);
return false;
});
if (!isPromise) return unresolvedValues;
return Promise.all(
unresolvedValues.map((v) => Array.isArray(v) ? Promise.all(v) : v)
);
};
export {
callable_bundle_exports as callable,
callable_bundle_exports as default,
resolveNested
};
//# sourceMappingURL=callable.index.js.map