| 178 | } |
| 179 | |
| 180 | decode(reader: Reader): any { |
| 181 | let count = this.length; |
| 182 | if (count === -1) { |
| 183 | count = reader.readIndex(); |
| 184 | |
| 185 | // Check that there is *roughly* enough data to ensure |
| 186 | // stray random data is not being read as a length. Each |
| 187 | // slot requires at least 32 bytes for their value (or 32 |
| 188 | // bytes as a link to the data). This could use a much |
| 189 | // tighter bound, but we are erroring on the side of safety. |
| 190 | assert(count * WordSize <= reader.dataLength, "insufficient data length", |
| 191 | "BUFFER_OVERRUN", { buffer: reader.bytes, offset: count * WordSize, length: reader.dataLength }); |
| 192 | } |
| 193 | let coders: Array<Coder> = []; |
| 194 | for (let i = 0; i < count; i++) { coders.push(new AnonymousCoder(this.coder)); } |
| 195 | |
| 196 | return unpack(reader, coders); |
| 197 | } |
| 198 | } |
| 199 | |