forked from ChainSafe/node-snappy-stream
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.ts
More file actions
23 lines (19 loc) · 722 Bytes
/
example.ts
File metadata and controls
23 lines (19 loc) · 722 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import { createCompressStream, createUncompressStream } from './src/index.ts';
// Create streams with proper type annotations
const compressStream = createCompressStream();
const uncompressStream = createUncompressStream({
asBuffer: false // Optional: emit strings instead of buffers
});
// Set up event handlers with proper types
compressStream.on('data', (chunk: Uint8Array) => {
console.log('Some data from the compressed stream:', chunk);
uncompressStream.write(chunk);
});
uncompressStream.on('data', (chunk: string) => {
console.log('The data that was originally written:');
console.log(chunk);
});
// Write some data
compressStream.write('hello');
compressStream.write('world');
compressStream.end();