mirror of
https://github.com/directus/directus.git
synced 2026-01-13 16:18:05 -05:00
13 lines
374 B
TypeScript
13 lines
374 B
TypeScript
export function isIn<T extends readonly string[]>(value: string, array: T): value is T[number] {
|
|
return array.includes(value);
|
|
}
|
|
|
|
export function isTypeIn<T extends { type?: string }, E extends string>(
|
|
object: T,
|
|
array: readonly E[],
|
|
): object is Extract<T, { type?: E }> {
|
|
if (!object.type) return false;
|
|
|
|
return (array as readonly string[]).includes(object.type);
|
|
}
|