Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

peek-readable

Package Overview
Dependencies
Maintainers
0
Versions
24
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

  • 5.3.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
4.2M
decreased by-14.57%
Maintainers
0
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 13 Oct 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