0.1.3 • Published 4 years ago

node-typestream v0.1.3

Weekly downloads
3
License
MIT
Repository
github
Last release
4 years ago

typestream

A typescript wrapper around Node streams which manages the type of data flowing through the stream.

Example

import * as tstream from 'node-typestream'
const readStream = new tstream.Readable<Buffer>(...)

Piping

const readStream = new tstream.Readable<string>(...)
const writeStream = new tstream.Writable<string>(...)
// Valid pipe
readStream.pipe(writeStream)

const bufferWriteStream = new tstream.Writable<Buffer>(...)
// Invalid pipe
readStream.pipe(bufferWriteStream)

Pipelines

// Valid pipeline
tstream.pipeline(
  new tstream.Readable<Buffer>(...)
  new tstream.Transform<Buffer, string>(...)
  new tstream.Writable<string>(...)
).then(() => console.log('complete'))

// Invalid pipeline
tstream.pipeline(
  new tstream.Readable<Buffer>(...)
  new tstream.Transform<Buffer, string>(...)
  new tstream.Writable<Buffer>(...)
).then(() => console.log('complete'))
// Produces: Argument of type '[Readable<Buffer>, Duplex<Buffer, string>, Writable<Buffer>]' is not assignable to parameter of type 'never'.
0.1.3

4 years ago

0.1.2

4 years ago

0.1.1

4 years ago

0.1.0

4 years ago