xcom2charpool
Version:
Library for reading, manipulating, and managing XCOM 2 character pool binary files, supporting both browser and Node.js environments.
29 lines (28 loc) • 842 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.BoolProperty = void 0;
const BaseCodec_1 = require("../BaseCodec");
const CodecError_1 = require("../Errors/CodecError");
/**
* Codec for UE BoolProperty values.
*/
class BoolProperty extends BaseCodec_1.BaseCodec {
constructor() {
super(...arguments);
this.type = 'BoolProperty';
}
read(reader, length, ctx) {
if (length !== 0) {
throw new CodecError_1.CodecError(`BoolProperty should have length 0, got ${length} instead`, this.fullPath(ctx));
}
return reader.byte() !== 0x00;
}
write(writer, value) {
writer.byte(value ? 0x01 : 0x00);
return 0;
}
isSupported(value) {
return typeof value === 'boolean';
}
}
exports.BoolProperty = BoolProperty;