wikibase-edit
Version:
Edit Wikibase from NodeJS
15 lines (12 loc) • 493 B
text/typescript
import { newError } from '../error.js'
export interface SpecialSnak {
snaktype: 'novalue' | 'somevalue'
}
export function hasSpecialSnaktype (value: unknown): value is SpecialSnak {
if (typeof value !== 'object') return false
if (!('snaktype' in value)) return false
const { snaktype } = value
if (snaktype == null || snaktype === 'value') return false
if (snaktype === 'novalue' || snaktype === 'somevalue') return true
else throw newError('invalid snaktype', { snaktype })
}