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

lazystream

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lazystream

Open Node Streams on demand.

  • 1.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
9.6M
increased by9.9%
Maintainers
1
Weekly downloads
 
Created

What is lazystream?

The lazystream npm package provides a way to lazily create streams, meaning the stream is not created until it is actually needed. This can be useful for optimizing performance and resource usage in applications that deal with streams.

What are lazystream's main functionalities?

Lazy Stream Creation

This feature allows you to create a stream that is only instantiated when it is actually used. In this example, a read stream for 'example.txt' is created lazily, meaning the file is not opened until data is actually read from the stream.

const LazyStream = require('lazystream');
const fs = require('fs');

const lazyStream = new LazyStream(() => fs.createReadStream('example.txt'));

lazyStream.on('data', (chunk) => {
  console.log(chunk.toString());
});

Lazy Stream with Options

This feature allows you to pass options to the stream creation function. In this example, the read stream is created with the 'utf8' encoding option, and the file is read as a UTF-8 encoded string.

const LazyStream = require('lazystream');
const fs = require('fs');

const lazyStream = new LazyStream(() => fs.createReadStream('example.txt', { encoding: 'utf8' }));

lazyStream.on('data', (chunk) => {
  console.log(chunk);
});

Other packages similar to lazystream

Keywords

FAQs

Package last updated on 23 Oct 2021

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