Socket
Socket
Sign inDemoInstall

peek-readable

Package Overview
Dependencies
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

peek-readable

Read and peek from a readable stream


Version published
Weekly downloads
4.8M
decreased by-0.67%
Maintainers
1
Weekly downloads
 
Created

What is peek-readable?

The peek-readable npm package provides utilities for reading from streams and buffers without consuming the data, allowing you to 'peek' at the data before deciding how to process it. This is particularly useful in scenarios where the type of processing depends on the content of the data itself.

What are peek-readable's main functionalities?

Peeking data from a stream

This feature allows you to peek at the first few bytes of a stream to determine its content without consuming those bytes, enabling further processing based on the peeked data.

const {ReadableStreamPeeker} = require('peek-readable');
const fs = require('fs');

const stream = fs.createReadStream('example.txt');
const peeker = new ReadableStreamPeeker(stream);

peeker.peek(10).then(buffer => {
  console.log('Peeked data:', buffer.toString());
});

Peeking data from a buffer

This feature enables peeking at data within a buffer, which can be useful for preliminary checks before processing the entire buffer.

const {BufferPeeker} = require('peek-readable');

const buffer = Buffer.from('Hello, world!');
const peeker = new BufferPeeker(buffer);

const peekedData = peeker.peek(5);
console.log('Peeked data:', peekedData.toString());

Other packages similar to peek-readable

Keywords

FAQs

Package last updated on 08 Aug 2024

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

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc