New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

@vates/stream-reader

Package Overview
Dependencies
Maintainers
9
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@vates/stream-reader

Efficiently reads and skips chunks of a given size in a stream

latest
Source
npmnpm
Version
0.1.0
Version published
Maintainers
9
Created
Source

@vates/stream-reader

Package Version License PackagePhobia Node compatibility

Efficiently reads and skips chunks of a given size in a stream

Install

Installation of the npm package:

npm install --save @vates/stream-reader

Usage

import StreamReader from '@vates/stream-reader'

const reader = new StreamReader(stream)

.read([size])

  • returns the next available chunk of data
  • like stream.read(), a number of bytes can be specified
  • returns with less data than expected if stream has ended
  • returns null if the stream has ended and no data has been read
const chunk = await reader.read(512)

.readStrict([size])

Similar behavior to readChunk but throws if the stream ended before the requested data could be read.

const chunk = await reader.readStrict(512)

.skip(size)

Skips a given number of bytes from a stream.

Returns the number of bytes actually skipped, which may be less than the requested size if the stream has ended.

const bytesSkipped = await reader.skip(2 * 1024 * 1024 * 1024)

.skipStrict(size)

Skips a given number of bytes from a stream and throws if the stream ended before enough stream has been skipped.

await reader.skipStrict(2 * 1024 * 1024 * 1024)

Contributions

Contributions are very welcomed, either on the documentation or on the code.

You may:

  • report any issue you've encountered;
  • fork and create a pull request.

License

ISC © Vates SAS

Keywords

async

FAQs

Package last updated on 26 Apr 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts