Socket
Socket
Sign inDemoInstall

cancelable-pipeline

Package Overview
Dependencies
0
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    cancelable-pipeline

Cancelable `stream.pipeline()`


Version published
Weekly downloads
23
increased by43.75%
Maintainers
1
Install size
4.45 kB
Created
Weekly downloads
 

Readme

Source

cancelable-pipeline

npm version Build Status codecov

Cancelable stream.pipeline()

const {createReadStream, createWriteStream, promises: {stat}} = require('fs');
const cancelablePipeline = require('cancelable-pipeline');

cancelablePipeline(createReadStream('1GB-file.txt'), createWriteStream('dest0'), async () => {
  (await stat('dest0')).size; //=> 1000000000;
});

const cancel = cancelablePipeline(createReadStream('1GB-file.txt'), createWriteStream('dest1'), async () => {
  (await stat('dest1')).size; //=> 263192576, or something else smaller than 1000000000
});

setTimeout(() => cancel(), 1000);

Installation

Use npm.

npm install cancelable-pipeline

API

const cancelablePipeline = require('cancelable-pipeline');

cancelablePipeline(stream0 [, stream1, stream2, ...] [, callback])

stream0, stream1, stream2, ...: Stream
callback: Function
Return: Function

cancelablePipeline(streams [, callback])

streams: Stream[]
callback: Function
Return: Function

The API is almost the same as stream.pipeline(). The only difference is cancelable-pipeline returns a Function which destroys all the piped Streams without passing any errors to the callback.

const cancel = cancelablePipeline([src, transform, anotherTransform, dest], err => {
  err; //=> undefined
});

cancel();

License

ISC License © 2017 - 2019 Shinnosuke Watanabe

Keywords

FAQs

Last updated on 08 Apr 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