EdgeAIG's picture
download
raw
1.28 kB
import { memoize } from "../../Function.ts"
import type * as Schema from "../../Schema.ts"
import type * as SchemaAST from "../../SchemaAST.ts"
/** @internal */
export function resolve(ast: SchemaAST.AST): Schema.Annotations.Annotations | undefined {
return ast.checks ? ast.checks[ast.checks.length - 1].annotations : ast.annotations
}
/** @internal */
export function resolveAt<A>(key: string) {
return (ast: SchemaAST.AST): A | undefined => resolve(ast)?.[key] as A | undefined
}
/** @internal */
export const resolveIdentifier = resolveAt<string>("identifier")
/** @internal */
export const resolveTitle = resolveAt<string>("title")
/** @internal */
export const resolveDescription = resolveAt<string>("description")
/** @internal */
export const resolveBrands = resolveAt<ReadonlyArray<string>>("brands")
/** @internal */
export const getExpected = memoize((ast: SchemaAST.AST): string => {
const identifier = resolveIdentifier(ast)
if (typeof identifier === "string") return identifier
return ast.getExpected(getExpected)
})
/** @internal */
export function collectBrands(annotations: Schema.Annotations.Annotations | undefined): ReadonlyArray<string> {
return annotations !== undefined && Array.isArray(annotations.brands) ? annotations.brands : []
}

Xet Storage Details

Size:
1.28 kB
·
Xet hash:
ac0d75d4d27dae634a10acbbb0f9690c8fa0f04d668bbc161ac556e4e50f1fe3

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.