5.0.7 • Published 8 months ago

@guanghechen/helper-stream v5.0.7

Weekly downloads
-
License
MIT
Repository
github
Last release
8 months ago

Utilities for handing node streams.

Install

  • npm

    npm install --save @guanghechen/helper-stream
  • yarn

    yarn add @guanghechen/helper-stream

Usage

NameDescription
concatStreamsConcatenate readable streams to async iterator.
consumeStreamConsume readable stream.
consumeStreamsConsume Consume multiple streams serially.
mergeStreamsMerge multiple readable streams into one readable streams.
stream2bufferConsume read stream and encode the contents into buffer.

Example

  • Basic.

    import { consumeStreams } from '@guanghechen/helper-stream'
    import fs from 'node:fs'
    
    const filepaths = ['a.txt', 'b.txt', 'c.txt']
    const readers: NodeJS.ReadableStream[] = plainFilepaths.map(fp => fs.createReadStream(fp))
    const writer: NodeJS.WritableStream = fs.createWriteStream('out.txt')
    await consumeStreams(readers, writer)
  • Middlewares, i.e., cipher data before output.

    import { consumeStreams } from '@guanghechen/helper-stream'
    import crypto from 'crypto'
    import fs from 'node:fs'
    
    const filepaths = ['a.txt', 'b.txt', 'c.txt']
    const readers: NodeJS.ReadableStream[] = plainFilepaths.map(fp => fs.createReadStream(fp))
    const writer: NodeJS.WritableStream = fs.createWriteStream('out.txt')
    
    const iv: Buffer = crypto.randomBytes(32)
    const key: Buffer = crypto.randomBytes(32)
    const cipher: crypto.Cipher = crypto.createCipheriv('aes-256-gcm', key, iv)
    await consumeStreams(readers, writer, cipher)
5.0.7

8 months ago

5.0.6

8 months ago

5.0.5

9 months ago

5.0.4

9 months ago

5.0.3

10 months ago

5.0.2

10 months ago

5.0.0-alpha.3

12 months ago

5.0.0-alpha.2

1 year ago

5.0.1

12 months ago

5.0.0

12 months ago

4.7.2

1 year ago

4.7.1

1 year ago

4.7.4

1 year ago

4.7.3

1 year ago

5.0.0-alpha.1

1 year ago

5.0.0-alpha.0

1 year ago

4.0.0-alpha.7

1 year ago

4.0.0-alpha.8

1 year ago

4.0.0-alpha.5

1 year ago

4.0.0-alpha.6

1 year ago

4.0.0-alpha.3

1 year ago

4.0.0-alpha.4

1 year ago

4.0.0-alpha.1

1 year ago

4.0.0-alpha.2

1 year ago

4.0.0-alpha.0

1 year ago

4.4.1

1 year ago

4.4.0

1 year ago

4.2.2

1 year ago

4.6.1

1 year ago

4.4.3

1 year ago

4.6.0

1 year ago

4.4.2

1 year ago

4.0.0

1 year ago

4.2.1

1 year ago

4.2.0

1 year ago

4.6.3

1 year ago

4.6.2

1 year ago

4.6.5

1 year ago

4.6.4

1 year ago

4.5.0

1 year ago

4.1.3

1 year ago

4.7.0

1 year ago

4.1.0

1 year ago

4.3.0

1 year ago

4.1.2

1 year ago

4.1.1

1 year ago

3.0.2

1 year ago

3.0.1

1 year ago

3.0.0

1 year ago

3.0.0-alpha.1

1 year ago

3.0.0-alpha.0

1 year ago

3.0.0-alpha.3

1 year ago

3.0.0-alpha.2

1 year ago

3.0.0-alpha.5

1 year ago

3.0.0-alpha.4

1 year ago

2.1.2

2 years ago

2.1.1

2 years ago

2.1.4

2 years ago

2.1.3

2 years ago

2.0.0-alpha.3

2 years ago

2.0.0-alpha.2

2 years ago

2.1.0

2 years ago

2.0.0

2 years ago

2.0.0-alpha.1

2 years ago

2.0.0-alpha.0

2 years ago