sanity
Version:
Sanity is a real-time content infrastructure with a scalable, hosted backend featuring a Graph Oriented Query Language (GROQ), asset pipelines and fast edge caches
14 lines (9 loc) • 377 B
text/typescript
import {type SchemaType} from '@sanity/types'
const PRIMITIVES = ['string', 'number', 'boolean']
export function is(typeName: string, type: SchemaType): boolean {
return type.name === typeName || Boolean(type.type && is(typeName, type.type))
}
export {is as type}
export function primitive(type: SchemaType) {
return PRIMITIVES.some((typeName) => is(typeName, type))
}