UNPKG

xcom2charpool

Version:

Library for reading, manipulating, and managing XCOM 2 character pool binary files, supporting both browser and Node.js environments.

26 lines (25 loc) 770 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ArrayProperty = void 0; class ArrayProperty { constructor(length, reader) { this.length = length; this.reader = reader; } static from(reader, name, size) { const length = reader.int32(); return new this(length, reader.subarray(size - 4)); } static to(target, value, packer) { // Write the length of the array target.int32(value.length); // If the array is empty, nothing more to write if (value.length === 0) { return; } for (let i = 0; i < value.length; i++) { packer.writeProperty('', value[i], true); } } } exports.ArrayProperty = ArrayProperty;