UNPKG

@awesome-ecs/abstract

Version:

A comprehensive Entity-Component-System (ECS) Architecture implementation. Abstract components.

69 lines 2.88 kB
//#region src/utils/types.d.ts /** * Creates a type that maps all properties of T to boolean. * * @template T - The type to map properties to boolean. * @returns A type with all properties of T mapped to boolean. */ type BooleanProps<T> = { [Property in keyof T]: boolean }; /** * Creates a type that makes all properties of T mutable. * * @template T - The type to make properties mutable. * @returns A type with all properties of T made mutable. */ type Mutable<T> = { -readonly [K in keyof T]: T[K] }; /** * Creates a type that makes all properties of T mutable recursively. * * @template T - The type to make properties mutable recursively. * @returns A type with all properties of T made mutable recursively. */ type MutableDeep<T> = { -readonly [K in keyof T]: Mutable<T[K]> }; type ImmutablePrimitive = undefined | null | boolean | string | number | Function; /** * Creates a type that makes all properties of T immutable. * * @template T - The type to make properties immutable. * @returns A type with all properties of T made immutable. */ type Immutable<T> = T extends ImmutablePrimitive ? T : T extends Array<infer U> ? ImmutableArray<U> : T extends Map<infer K, infer V> ? ImmutableMap<K, V> : T extends Set<infer M> ? ImmutableSet<M> : ImmutableObject<T>; /** * Creates a type that makes all properties of T immutable in an array. * * @template T - The type to make properties immutable in an array. * @returns A type with all properties of T made immutable in an array. */ type ImmutableArray<T> = ReadonlyArray<Immutable<T>>; /** * Creates a type that makes all properties of T immutable in a map. * * @template K - The key type of the map. * @template V - The value type of the map. * @returns A type with all properties of T made immutable in a map. */ type ImmutableMap<K, V> = ReadonlyMap<Immutable<K>, Immutable<V>>; /** * Creates a type that makes all properties of T immutable in a set. * * @template T - The type to make properties immutable in a set. * @returns A type with all properties of T made immutable in a set. */ type ImmutableSet<T> = ReadonlySet<Immutable<T>>; /** * Creates a type that makes all properties of T immutable. * * @template T - The type to make properties immutable. * @returns A type with all properties of T made immutable. */ type ImmutableObject<T> = { readonly [K in keyof T]: T[K] }; /** * Creates a type that makes all properties of T immutable recursively. * * @template T - The type to make properties immutable recursively. * @returns A type with all properties of T made immutable recursively. */ type ImmutableObjectDeep<T> = { readonly [K in keyof T]: Immutable<T[K]> }; //#endregion export { BooleanProps, Immutable, ImmutableArray, ImmutableMap, ImmutableObject, ImmutableObjectDeep, ImmutableSet, Mutable, MutableDeep }; //# sourceMappingURL=types-yh4pOGEm.d.ts.map