Files
NapCatQQ/.pnpm-store/v3/files/cf/401cf0950af979fe4484071d4744d643304d4da6cc8c47ad455ef669c353039035dd642c6b41ed85e19e0016bb373c05f2c410ae925c56b9a00d59ee7f2fa7
T
TanTan e311ca3275
Build NapCat Artifacts / Type Check & Test (push) Waiting to run
docs: 仓库链接指向本镜像仓库
2026-11-13 09:25:58 +08:00

38 lines
1.4 KiB
Plaintext

import { CreateType } from '../create/type.mjs';
import { Computed } from '../computed/index.mjs';
import { Intersect } from '../intersect/index.mjs';
import { Union } from '../union/index.mjs';
import { Ref } from '../ref/index.mjs';
// ------------------------------------------------------------------
// TypeGuard
// ------------------------------------------------------------------
import { IsIntersect, IsUnion, IsPromise, IsRef, IsComputed } from '../guard/kind.mjs';
// prettier-ignore
function FromComputed(target, parameters) {
return Computed('Awaited', [Computed(target, parameters)]);
}
// prettier-ignore
function FromRef($ref) {
return Computed('Awaited', [Ref($ref)]);
}
// prettier-ignore
function FromIntersect(types) {
return Intersect(FromRest(types));
}
// prettier-ignore
function FromUnion(types) {
return Union(FromRest(types));
}
// prettier-ignore
function FromPromise(type) {
return Awaited(type);
}
// prettier-ignore
function FromRest(types) {
return types.map(type => Awaited(type));
}
/** `[JavaScript]` Constructs a type by recursively unwrapping Promise types */
export function Awaited(type, options) {
return CreateType(IsComputed(type) ? FromComputed(type.target, type.parameters) : IsIntersect(type) ? FromIntersect(type.allOf) : IsUnion(type) ? FromUnion(type.anyOf) : IsPromise(type) ? FromPromise(type.item) : IsRef(type) ? FromRef(type.$ref) : type, options);
}