preserves/implementations/javascript/packages/core/src/compound.ts

13 lines
497 B
TypeScript
Raw Permalink Normal View History

2021-03-17 13:24:41 +00:00
import type { Compound, Value } from "./values";
2024-03-12 16:47:38 +00:00
import type { Embeddable, GenericEmbedded } from "./embedded";
2021-03-17 13:24:41 +00:00
import { Dictionary, Set } from "./dictionary";
2024-03-12 16:47:38 +00:00
export function isCompound<T extends Embeddable = GenericEmbedded>(x: Value<T>): x is Compound<T>
2021-03-17 13:24:41 +00:00
{
return (Array.isArray(x) || Set.isSet(x) || Dictionary.isDictionary(x));
}
2023-01-05 14:13:23 +00:00
2024-03-12 16:47:38 +00:00
export function isSequence<T extends Embeddable = GenericEmbedded>(x: Value<T>): x is Array<Value<T>> {
2023-01-05 14:13:23 +00:00
return (Array.isArray(x) && !('label' in x));
}