🎨 Replace increment operator

This commit is contained in:
C-3PO 2018-06-22 16:42:26 +02:00
parent 1653455ec0
commit 96139d2305
Signed by: c3po
GPG key ID: 62993C4BB4D86F24

View file

@ -10,7 +10,7 @@ const Decoder = new TextDecoder('utf-8');
export default function bpParse(dv: DataView, posIn: number = 0): { obj: any, pos: number } {
let pos = posIn;
let obj;
const header = dv.getUint8(pos++);
const header = dv.getUint8(pos); pos += 1;
switch (header) {
case 0x64: { //'d' - dictionary (key-value object)
obj = [];
@ -23,7 +23,7 @@ export default function bpParse(dv: DataView, posIn: number = 0): { obj: any, po
pos = out2.pos;
obj[out1.obj] = out2.obj;
} while (dv.getUint8(pos) !== 0x65); //'e' - end
pos++;
pos += 1;
break;
}
case 0x6C: { //'l' - list (array)
@ -34,11 +34,11 @@ export default function bpParse(dv: DataView, posIn: number = 0): { obj: any, po
pos = out.pos;
obj.push(out.obj);
} while (dv.getUint8(pos) !== 0x65); //'e' - end
pos++;
pos += 1;
break;
}
case 0x69: { //'i' - integer
let curChar = dv.getUint8(pos++);
let curChar = dv.getUint8(pos); pos += 1;
let curNumber = 0;
while (curChar !== 0x65) { //'e' - end
if (curChar < 0x30 || curChar > 0x39) {
@ -46,7 +46,7 @@ export default function bpParse(dv: DataView, posIn: number = 0): { obj: any, po
}
curNumber *= 10;
curNumber += curChar - 0x30;
curChar = dv.getUint8(pos++);
curChar = dv.getUint8(pos); pos += 1;
}
obj = curNumber;
break;
@ -59,7 +59,7 @@ export default function bpParse(dv: DataView, posIn: number = 0): { obj: any, po
while (curChar !== 0x3A) { //':' - integer delimiter, beginning of string
strLen *= 10;
strLen += curChar - 0x30;
curChar = dv.getUint8(pos++);
curChar = dv.getUint8(pos); pos += 1;
}
//read string
obj = Decoder.decode(new DataView(dv.buffer, pos, strLen));