refactor the whole damn thing

This commit is contained in:
Kevin Jahns
2017-10-11 03:41:54 +02:00
parent d9ee67d2f3
commit 82015d5a37
43 changed files with 2194 additions and 4848 deletions

32
src/Struct/ItemJSON.js Normal file
View File

@@ -0,0 +1,32 @@
import Item from './Item'
export default class ItemJSON extends Item {
constructor () {
super()
this._content = null
}
get _length () {
return this._content.length
}
_fromBinary (y, decoder) {
let missing = super._fromBinary(y, decoder)
let len = decoder.readVarUint()
this._content = new Array(len)
for (let i = 0; i < len; i++) {
this._content[i] = JSON.parse(decoder.readVarString())
}
return missing
}
_toBinary (y, encoder) {
super._toBinary(y, encoder)
let len = this._content.length
encoder.writeVarUint(len)
for (let i = 0; i < len; i++) {
encoder.writeVarString(JSON.stringify(this._content[i]))
}
}
_logString () {
let s = super._logString()
return 'ItemJSON: ' + s
}
}