mirror of
https://github.com/FlipsideCrypto/DefinitelyTyped.git
synced 2026-02-06 10:56:53 +00:00
* Add types for binary-split * Add minimum TS version * Make test fail * Make test faile * Fix test * Update types/binary-split/index.d.ts Co-authored-by: Piotr Błażejewicz (Peter Blazejewicz) <peterblazejewicz@users.noreply.github.com> * Update types/binary-split/index.d.ts Co-authored-by: Piotr Błażejewicz (Peter Blazejewicz) <peterblazejewicz@users.noreply.github.com> * Function parameter is optional Co-authored-by: Piotr Błażejewicz (Peter Blazejewicz) <peterblazejewicz@users.noreply.github.com>
17 lines
445 B
TypeScript
17 lines
445 B
TypeScript
import bsplit = require('binary-split');
|
|
|
|
const output = new Array<Buffer>();
|
|
const splitter = bsplit('*snip*');
|
|
splitter.on('data', (chunk: Buffer) => {
|
|
output.push(chunk);
|
|
});
|
|
splitter.on('end', () => {
|
|
if (output.length !== 2 || output[0].toString('utf8') !== 'A' || output[1].toString('utf8') !== 'B') {
|
|
throw new Error('Test failed');
|
|
}
|
|
});
|
|
|
|
const input = Buffer.from('A*snip*B');
|
|
splitter.write(input);
|
|
splitter.end();
|