MCPcopy Create free account
hub / github.com/WinterTC55/iter-streams / SmartBuffer

Class SmartBuffer

samples/01-basic-creation.ts:298–311  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

296 // Object can implement both protocols (sync and async)
297 {
298 class SmartBuffer {
299 constructor(private content: string) {}
300
301 // Sync version - used in sync contexts
302 [Stream.toStreamable](): string {
303 return this.content;
304 }
305
306 // Async version - preferred in async contexts, can do async processing
307 async *[Stream.toAsyncStreamable]() {
308 // Could do async compression, transformation, etc.
309 yield `[async] ${this.content}`;
310 }
311 }
312
313 // In async context, toAsyncStreamable is preferred
314 const asyncText = await Stream.text(Stream.from([new SmartBuffer('hello')]));

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected