Socket
Socket
Sign inDemoInstall

stream-shift

Package Overview
Dependencies
0
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    stream-shift

Returns the next buffer/object in a stream's readable queue


Version published
Weekly downloads
16M
increased by1.77%
Maintainers
1
Install size
4.62 kB
Created
Weekly downloads
 

Package description

What is stream-shift?

The stream-shift npm package is designed for shifting the first chunk out of a readable stream. It is particularly useful when you need to process or inspect the first piece of data from a stream before deciding how to handle the rest of the stream. This can be handy in scenarios where the first chunk contains metadata or specific flags that determine the processing logic for the subsequent data.

What are stream-shift's main functionalities?

Shifting the first chunk from a stream

This code demonstrates how to use stream-shift to extract the first chunk of data from a readable stream. The `shift` function is called with the stream as its argument, and it returns the first chunk. This can be useful for inspecting or processing the first part of the stream differently from the rest.

const shift = require('stream-shift');
const stream = getSomeReadableStream();
const firstChunk = shift(stream);
if (firstChunk) {
  console.log('First chunk:', firstChunk.toString());
}

Other packages similar to stream-shift

Readme

Source

stream-shift

Returns the next buffer/object in a stream's readable queue

npm install stream-shift

build status

Usage

var shift = require('stream-shift')

console.log(shift(someStream)) // first item in its buffer

Credit

Thanks @dignifiedquire for making this work on node 6

License

MIT

FAQs

Last updated on 12 Dec 2019

Did you know?

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc