Skip to content

Commit 0fa530e

Browse files
authored
Update README.md
1 parent 27f8f76 commit 0fa530e

1 file changed

Lines changed: 23 additions & 1 deletion

File tree

README.md

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff 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

0 commit comments

Comments
 (0)