UNPKG

@skyrim-platform/jcontainers

Version:

TypeScript library for the JContainers Skyrim modding utility

94 lines (87 loc) 4.95 kB
/* ============================================== Typescript definitions for v4.2.1 ============================================== This file was automatically generated by Papyrus-2-Typescript.exe https://github.com/CarlosLeyvaAyala/Papyrus-2-Typescript The program has no way to know the intention of the humans that made the scripts, so it's always advisable to manually check all generated files to make sure everything is declared as it should. Take note the program assumes this script exists in some subfolder to the folder where `skyrimPlatform.ts` is found, otherwise you'll get "Cannot find module..." type of errors. If you want to have this script in some other place, just change the relative path of each `import`. */ import * as sp from "skyrimPlatform"; /** Associative key-value container. Inherits JValue functionality */ var sn = sp.JFormMap; /** creates new container object. returns container's identifier (unique integer number). */ export var object = function () { return sn.object(); }; /** Returns the value associated with the @key. If not, returns @default value */ export var getInt = function (object, key, defaultVal) { if (defaultVal === void 0) { defaultVal = 0; } return sn.getInt(object, key, defaultVal); }; export var getFlt = function (object, key, defaultVal) { if (defaultVal === void 0) { defaultVal = 0.0; } return sn.getFlt(object, key, defaultVal); }; export var getStr = function (object, key, defaultVal) { if (defaultVal === void 0) { defaultVal = ""; } return sn.getStr(object, key, defaultVal); }; export var getObj = function (object, key, defaultVal) { if (defaultVal === void 0) { defaultVal = 0; } return sn.getObj(object, key, defaultVal); }; export var getForm = function (object, key, defaultVal) { if (defaultVal === void 0) { defaultVal = null; } return sn.getForm(object, key, defaultVal); }; /** Inserts @key: @value pair. Replaces existing pair with the same @key */ export var setInt = function (object, key, value) { return sn.setInt(object, key, value); }; export var setFlt = function (object, key, value) { return sn.setFlt(object, key, value); }; export var setStr = function (object, key, value) { return sn.setStr(object, key, value); }; export var setObj = function (object, key, container) { return sn.setObj(object, key, container); }; export var setForm = function (object, key, value) { return sn.setForm(object, key, value); }; /** Returns true, if the container has @key: value pair */ export var hasKey = function (object, key) { return sn.hasKey(object, key); }; /** 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 var valueType = function (object, key) { return sn.valueType(object, key); }; /** Returns a new array containing all keys */ export var allKeys = function (object) { return sn.allKeys(object); }; export var allKeysPArray = function (object) { return sn.allKeysPArray(object); }; /** Returns a new array containing all values */ export var allValues = function (object) { return sn.allValues(object); }; /** Removes the pair from the container where the key equals to the @key */ export var removeKey = function (object, key) { return sn.removeKey(object, key); }; /** Returns count of pairs in the conainer */ export var count = function (object) { return sn.count(object); }; /** Removes all pairs from the container */ export var clear = function (object) { return sn.clear(object); }; /** Inserts key-value pairs from the source container */ export var addPairs = function (object, source, overrideDuplicates) { return sn.addPairs(object, source, overrideDuplicates); }; /** 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 var nextKey = function (object, previousKey, endKey) { if (previousKey === void 0) { previousKey = null; } if (endKey === void 0) { endKey = null; } return sn.nextKey(object, previousKey, endKey); }; /** Retrieves N-th key. negative index accesses items from the end of container counting backwards. Worst complexity is O(n/2) */ export var getNthKey = function (object, keyIndex) { return sn.getNthKey(object, keyIndex); };