File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -15,7 +15,29 @@ npm install @scottypoi/ts-snappy-stream
1515### Input
1616
1717``` typescript
18- // ./example.ts
18+ import { createCompressStream , createUncompressStream } from ' ./src/index.ts' ;
19+
20+ // Create streams with proper type annotations
21+ const compressStream = createCompressStream ();
22+ const uncompressStream = createUncompressStream ({
23+ asBuffer: false // Optional: emit strings instead of buffers
24+ });
25+
26+ // Set up event handlers with proper types
27+ compressStream .on (' data' , (chunk : Uint8Array ) => {
28+ console .log (' Some data from the compressed stream:' , chunk );
29+ uncompressStream .write (chunk );
30+ });
31+
32+ uncompressStream .on (' data' , (chunk : string ) => {
33+ console .log (' The data that was originally written:' );
34+ console .log (chunk );
35+ });
36+
37+ // Write some data
38+ compressStream .write (' hello' );
39+ compressStream .write (' world' );
40+ compressStream .end ();
1941```
2042
2143### Output
You can’t perform that action at this time.
0 commit comments