| 13 | }); |
| 14 | |
| 15 | function buildContent(content, len) { |
| 16 | let base; |
| 17 | switch (content) { |
| 18 | case 'ascii': base = 'a'; break; |
| 19 | case 'one-byte-string': base = '\xff'; break; |
| 20 | case 'two-byte-string': base = 'ğ'; break; |
| 21 | } |
| 22 | const unitBytes = Buffer.byteLength(base, 'utf8'); |
| 23 | const copies = Math.max(1, Math.floor(len / unitBytes)); |
| 24 | return Buffer.from(base.repeat(copies)); |
| 25 | } |
| 26 | |
| 27 | function main({ encoding, len, n, ignoreBOM, type, fatal, content }) { |
| 28 | const decoder = new TextDecoder(encoding, { ignoreBOM, fatal }); |