(length: number)
| 15 | function parsePhpArray(serialized: string) { |
| 16 | const initial = serialized; |
| 17 | const readString = (length: number) => { |
| 18 | const buf = new TextEncoder().encode(serialized).slice(0, length); |
| 19 | const result = new TextDecoder().decode(buf); |
| 20 | serialized = serialized.slice(result.length); |
| 21 | return result; |
| 22 | }; |
| 23 | const readInt = () => { |
| 24 | let val = 0; |
| 25 | if (!'0123456789'.includes(serialized[0])) throw new Error(`Expected number, got "${serialized[0]}", initial "${initial}"`); |