UNPKG

@skyrim-platform/jcontainers

Version:

TypeScript library for the JContainers Skyrim modding utility

53 lines (50 loc) 3.46 kB
import { Form } from "skyrimPlatform"; /** creates new container object. returns container's identifier (unique integer number). */ export declare const object: () => number; /** Returns the value associated with the @key. If not, returns @default value */ export declare const getInt: (object: number, key: string, defaultVal?: number) => number; export declare const getFlt: (object: number, key: string, defaultVal?: number) => number; export declare const getStr: (object: number, key: string, defaultVal?: string) => string; export declare const getObj: (object: number, key: string, defaultVal?: number) => number; export declare const getForm: (object: number, key: string, defaultVal?: Form | null | undefined) => Form | null | undefined; /** Inserts @key: @value pair. Replaces existing pair with the same @key */ export declare const setInt: (object: number, key: string, value: number) => void; export declare const setFlt: (object: number, key: string, value: number) => void; export declare const setStr: (object: number, key: string, value: string) => void; export declare const setObj: (object: number, key: string, container: number) => void; export declare const setForm: (object: number, key: string, value: Form | null | undefined) => void; /** Returns true, if the container has @key: value pair */ export declare const hasKey: (object: number, key: string) => boolean; /** Returns type of the value associated with the @key. 0 - no value, 1 - none, 2 - int, 3 - float, 4 - form, 5 - object, 6 - string */ export declare const valueType: (object: number, key: string) => number; /** Returns a new array containing all keys */ export declare const allKeys: (object: number) => number; export declare const allKeysPArray: (object: number) => string[]; /** Returns a new array containing all values */ export declare const allValues: (object: number) => number; /** Removes the pair from the container where the key equals to the @key */ export declare const removeKey: (object: number, key: string) => boolean; /** Returns count of pairs in the conainer */ export declare const count: (object: number) => number; /** Removes all pairs from the container */ export declare const clear: (object: number) => void; /** Inserts key-value pairs from the source container */ export declare const addPairs: (object: number, source: number, overrideDuplicates: boolean) => void; /** Simplifies iteration over container's contents. Accepts the @previousKey, returns the next key. If @previousKey == @endKey the function returns the first key. The function always returns so-called 'valid' keys (the ones != @endKey). The function returns @endKey ('invalid' key) only once to signal that iteration has reached its end. In most cases, if the map doesn't contain an invalid key ("" for JMap, None form-key for JFormMap) it's ok to omit the @endKey. Usage: string key = JMap.nextKey(map, previousKey="", endKey="") while key != "" <retrieve values here> key = JMap.nextKey(map, key, endKey="") endwhile */ export declare const nextKey: (object: number, previousKey?: string, endKey?: string) => string; /** Retrieves N-th key. negative index accesses items from the end of container counting backwards. Worst complexity is O(n/2) */ export declare const getNthKey: (object: number, keyIndex: number) => string;