/** * Copyright (c) 2018-2021 mol* contributors, licensed under MIT, See LICENSE file for more info. * * @author Alexander Rose * @author David Sehnal */ export type Mutable = { -readonly [P in keyof T]: T[P] } export type PartialBy = Omit & Partial> export type PickRequired = T & Required> export type TypedIntArray = Int8Array | Int16Array | Int32Array | Uint8Array | Uint16Array | Uint32Array export type TypedFloatArray = Float32Array | Float64Array export type TypedArray = TypedIntArray | TypedFloatArray export type NumberArray = TypedArray | number[] export type UintArray = Uint8Array | Uint16Array | Uint32Array | number[] export type ValueOf = T[keyof T] export type ArrayCtor = { new(size: number): { [i: number]: T, length: number } } /** assignable ArrayLike version */ export type AssignableArrayLike = { [i: number]: T, length: number } export type NonNullableArray> = T extends any[] ? NonNullable[] : ReadonlyArray> export function ObjectKeys(o: T) { return Object.keys(o) as (keyof T)[]; } export interface FiniteArray extends ReadonlyArray { length: L }; export function assertUnreachable(x: never): never { throw new Error('unreachable'); } export function isPromiseLike(x: any): x is Promise { return typeof x?.then === 'function'; }