Spaces:
Runtime error
Runtime error
| type Constructor<T> = new (...args: unknown[]) => T; | |
| /* Check whether array is of the specified type */ | |
| export const isArrayOfType = <T>( | |
| arr: unknown[] | unknown, | |
| type: Constructor<T> | string | |
| ): arr is T[] => { | |
| return ( | |
| Array.isArray(arr) && | |
| arr.every((item): item is T => { | |
| if (typeof type === "string") { | |
| return typeof item === type; | |
| } else { | |
| return item instanceof type; | |
| } | |
| }) | |
| ); | |
| }; | |