UNPKG

xcom2charpool

Version:

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

31 lines (30 loc) 1 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ByteProperty = void 0; /** Enum */ class ByteProperty { constructor(type, value) { this.type = type; this.value = value; } static from(reader, name, size) { const type = reader.string(); reader.padding(); const value = reader.string(); reader.padding(); return new this(type, value); } static to(target, value) { // Write the enum type name (not included in size) target.string(value.type).padding(); // Record the start position for size calculation const startPosition = target.position; // Write the enum value name (included in size) target.string(value.value).padding(); // Record the end position const endPosition = target.position; // Return the size for the size field return endPosition - startPosition; } } exports.ByteProperty = ByteProperty;