| 137 | return pack(writer, coders, value); |
| 138 | } |
| 139 | decode(reader) { |
| 140 | let count = this.length; |
| 141 | if (count === -1) { |
| 142 | count = reader.readIndex(); |
| 143 | // Check that there is *roughly* enough data to ensure |
| 144 | // stray random data is not being read as a length. Each |
| 145 | // slot requires at least 32 bytes for their value (or 32 |
| 146 | // bytes as a link to the data). This could use a much |
| 147 | // tighter bound, but we are erroring on the side of safety. |
| 148 | assert(count * WordSize <= reader.dataLength, "insufficient data length", "BUFFER_OVERRUN", { buffer: reader.bytes, offset: count * WordSize, length: reader.dataLength }); |
| 149 | } |
| 150 | let coders = []; |
| 151 | for (let i = 0; i < count; i++) { |
| 152 | coders.push(new AnonymousCoder(this.coder)); |
| 153 | } |
| 154 | return unpack(reader, coders); |
| 155 | } |
| 156 | } |