uesavetool
Version:
A Node.js implementation for deserializing and converting GVAS/.sav files to JSON and vice-versa.
38 lines (36 loc) • 1.09 kB
JavaScript
import { Serializer } from '../../utils/Serializer.js';
import { SerializationError } from '../PropertyErrors.js';
import { Property } from './index.js'
export class ObjectProperty extends Property {
constructor() {
super();
this.Property = "";
}
get Size() {
return this.Name.length + 4
+ this.Type.length + 4
+ this.Property.length + 4
+ 9;
}
deserialize(serial) {
serial.seek(5);
this.Property = serial.readString();
return this;
}
serialize() {
let serial = Serializer.alloc(this.Size);
serial.writeString(this.Name);
serial.writeString(this.Type);
serial.writeInt32(this.Property.length + 4);
serial.seek(5);
serial.writeString(this.Property);
if (serial.tell !== this.Size)
throw new SerializationError(this);
return serial.Data;
}
static from(obj) {
let prop = new ObjectProperty();
Object.assign(prop, obj);
return prop;
}
}