fork of hey-api/openapi-ts because I need some additional things
at main 854 B view raw
1import { nodeBrand, symbolBrand } from './brands'; 2import type { INode } from './nodes/node'; 3import type { Ref } from './refs/types'; 4import type { Symbol } from './symbols/symbol'; 5 6export function isBrand(value: unknown, brand: string): value is INode { 7 if (!value || typeof value !== 'object') return false; 8 return (value as any)['~brand'] === brand; 9} 10 11export function isNode(value: unknown): value is INode { 12 if (!value || typeof value !== 'object') return false; 13 return isBrand(value, nodeBrand); 14} 15 16export function isNodeRef(value: Ref<unknown>): value is Ref<INode> { 17 return isBrand(value['~ref'], nodeBrand); 18} 19 20export function isSymbol(value: unknown): value is Symbol { 21 return isBrand(value, symbolBrand); 22} 23 24export function isSymbolRef(value: Ref<unknown>): value is Ref<Symbol> { 25 return isBrand(value['~ref'], symbolBrand); 26}