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

promise-readable

Package Overview
Dependencies
Maintainers
1
Versions
41
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

promise-readable - npm Package Compare versions

Comparing version 3.0.0 to 3.0.1

4

CHANGELOG.md
# Changelog
## v3.0.1 2018-02-04
* Minor refactoring.
## v3.0.0 2018-02-03

@@ -4,0 +8,0 @@

85

lib/promise-readable.js

@@ -32,6 +32,3 @@ 'use strict'

if (chunk != null) {
stream.removeListener('close', closeHandler)
stream.removeListener('error', errorHandler)
stream.removeListener('end', endHandler)
stream.removeListener('readable', readableHandler)
removeListeners()
resolve(chunk)

@@ -42,5 +39,3 @@ }

const closeHandler = () => {
stream.removeListener('end', endHandler)
stream.removeListener('error', errorHandler)
stream.removeListener('readable', readableHandler)
removeListeners()
resolve(stream.bytesWritten || 0)

@@ -50,5 +45,3 @@ }

const endHandler = () => {
stream.removeListener('close', closeHandler)
stream.removeListener('error', errorHandler)
stream.removeListener('readable', readableHandler)
removeListeners()
resolve()

@@ -59,11 +52,16 @@ }

delete this._errored
removeListeners()
reject(err)
}
const removeListeners = () => {
stream.removeListener('close', closeHandler)
stream.removeListener('error', errorHandler)
stream.removeListener('end', endHandler)
stream.removeListener('readable', readableHandler)
reject(err)
}
stream.once('close', closeHandler)
stream.once('end', endHandler)
stream.once('error', errorHandler)
stream.on('close', closeHandler)
stream.on('end', endHandler)
stream.on('error', errorHandler)
stream.on('readable', readableHandler)

@@ -95,5 +93,3 @@

const closeHandler = () => {
stream.removeListener('data', dataHandler)
stream.removeListener('end', endHandler)
stream.removeListener('error', errorHandler)
removeListeners()
resolve(stream.bytesWritten || 0)

@@ -103,5 +99,3 @@ }

const endHandler = () => {
stream.removeListener('close', closeHandler)
stream.removeListener('data', dataHandler)
stream.removeListener('error', errorHandler)
removeListeners()
resolve(Buffer.concat(bufferArray))

@@ -112,12 +106,17 @@ }

delete this._errored
removeListeners()
reject(err)
}
const removeListeners = () => {
stream.removeListener('close', closeHandler)
stream.removeListener('data', dataHandler)
stream.removeListener('error', errorHandler)
stream.removeListener('end', endHandler)
reject(err)
}
stream.once('close', closeHandler)
stream.on('close', closeHandler)
stream.on('data', dataHandler)
stream.once('end', endHandler)
stream.once('error', errorHandler)
stream.on('end', endHandler)
stream.on('error', errorHandler)

@@ -153,9 +152,3 @@ stream.resume()

const closeHandler = () => {
if (eventHandler) {
stream.removeListener(event, eventHandler)
}
stream.removeListener('error', errorHandler)
if (endHandler) {
stream.removeListener('end', endHandler)
}
removeListeners()
resolve()

@@ -165,7 +158,3 @@ }

const eventHandler = event !== 'close' && event !== 'end' && event !== 'error' ? (argument) => {
stream.removeListener('close', closeHandler)
stream.removeListener('error', errorHandler)
if (endHandler) {
stream.removeListener('end', endHandler)
}
removeListeners()
resolve(argument)

@@ -175,7 +164,3 @@ } : undefined

const endHandler = event !== 'close' ? () => {
if (eventHandler) {
stream.removeListener(event, eventHandler)
}
stream.removeListener('close', closeHandler)
stream.removeListener('error', errorHandler)
removeListeners()
resolve()

@@ -186,20 +171,25 @@ } : undefined

delete this._errored
removeListeners()
reject(err)
}
const removeListeners = () => {
if (eventHandler) {
stream.removeListener(event, eventHandler)
}
stream.removeListener('close', closeHandler)
stream.removeListener('error', errorHandler)
if (endHandler) {
stream.removeListener('end', endHandler)
}
reject(err)
stream.removeListener('error', errorHandler)
}
if (eventHandler) {
stream.once(event, eventHandler)
stream.on(event, eventHandler)
}
stream.once('close', closeHandler)
stream.on('close', closeHandler)
if (endHandler) {
stream.once('end', endHandler)
stream.on('end', endHandler)
}
stream.once('error', errorHandler)
stream.on('error', errorHandler)
})

@@ -210,2 +200,3 @@ }

this.stream.removeListener('error', this._errorHandler)
delete this._errorHandler
if (typeof this.stream.destroy === 'function') {

@@ -212,0 +203,0 @@ this.stream.destroy()

{
"name": "promise-readable",
"version": "3.0.0",
"version": "3.0.1",
"description": "Return promise for readable stream",

@@ -5,0 +5,0 @@ "main": "lib/promise-readable.js",

@@ -147,2 +147,9 @@ ## promise-readable

### See also
[`PromiseWritable`](https://www.npmjs.com/package/promise-writable),
[`PromiseDuplex`](https://www.npmjs.com/package/promise-duplex),
[`PromiseSocket`](https://www.npmjs.com/package/promise-socket),
[`PromisePiping`](https://www.npmjs.com/package/promise-piping).
### License

@@ -149,0 +156,0 @@

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