UNPKG

sc4

Version:

A command line utility for automating SimCity 4 modding tasks & modifying savegames

29 lines (28 loc) 1.28 kB
import type { uint32, uint16, uint8, sint32, sint64, float } from 'sc4/types'; import type { ExemplarPropertyIdLikeToValueType as Map, kPropertyType, kPropertyId, StringKey } from './exemplar-properties.js'; export type { kPropertyType, kPropertyId }; export type NumberLike<T extends number = number> = T | { [kPropertyId]: T; } | { [Symbol.toPrimitive](...args: any[]): T; }; export type ExtractNumber<N> = N extends NumberLike<infer T> ? T : N; export type Primitive = uint8 | uint16 | uint32 | sint32 | sint64 | float | boolean; export type ValueType = string | Primitive | Primitive[]; /** * Either a string, a number or an object that can be converted to a number * which identifies a certain property. */ export type Key = StringKey | NumberLike; /** * A generic type that figures out the type of a property's value in case it is * a known value. */ export type Value<K extends Key = number> = K extends NumberLike ? Map<ExtractNumber<K>, ValueType> : Map<K, ValueType>; /** * Determines whether the given key can serve as an exemplar property key. * * @{param} key {unknown} */ export declare function isKey(key: unknown): key is Key; export type PropertyValueType = 'Uint8' | 'Uint16' | 'Uint32' | 'Sint32' | 'Sint64' | 'Float32' | 'Bool' | 'String';