| 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')])); |
nothing calls this directly
no outgoing calls
no test coverage detected