upsetjs import type { ISet , ISetCombination , ISetLike , IBaseSet } from './model' ; import type { GenerateSetCombinationsOptions } from './data' ; import { UpSetQuery , isElemQuery , isCalcQuery , isSetQuery } from './queries' ; function isBaseSet ( v ) { const vt = v ; return v != null && typeof vt . cardinality === 'number' && typeof v . name === 'string' && Array . isArray ( v . elems ) ; } export function isSet ( v ) { return isBaseSet ( v ) && ( v as ISet < any > ) . type === 'set' ; } export function isSetCombination ( v ) { const vt = v ; return ( isBaseSet ( v ) && [ 'composite' , 'union' , 'intersection' , 'distinctIntersection' ] . includes ( vt . type ) && vt . sets instanceof Set && typeof vt . degree === 'number' ) ; } export function isSetLike ( v ) { return isSet ( v ) || isSetCombination ( v ) ; } export function isGenerateSetCombinationOptions ( v ) { const vt = v ; return v != null && ( vt . type == null || [ 'intersection' , 'union' ] . includes ( vt . type ) ) ; } export function isUpSetQuery ( v ) { const vt = v ; return ( v != null && typeof vt . name === 'string' && typeof vt . color === 'string' && ( isElemQuery ( vt ) || isSetQuery ( vt ) || isCalcQuery ( vt ) ) ) ; }