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

it-goodbye

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

it-goodbye - npm Package Compare versions

Comparing version 2.0.0 to 2.0.1

.travis.yml

34

index.js
const endable = require('./endable')
module.exports = (stream, goodbye) => {
goodbye = Buffer.from(goodbye || 'GOODBYE')
goodbye = goodbye || Buffer.from('GOODBYE')
const e = endable(goodbye)
const isBufferCompatible = Buffer.isBuffer(goodbye) || typeof goodbye === 'string'
const token = isBufferCompatible ? Buffer.from(goodbye) : goodbye

@@ -14,14 +16,24 @@ return {

// when the goodbye is received, allow the source to end.
for await (const chunk of source) {
const buff = Buffer.from(chunk)
const done = buff.slice(-goodbye.length).equals(goodbye)
if (done) {
const remaining = buff.length - goodbye.length
if (remaining > 0) {
yield buff.slice(0, remaining)
if (isBufferCompatible) {
for await (const chunk of source) {
const buff = Buffer.from(chunk)
const done = buff.slice(-token.length).equals(token)
if (done) {
const remaining = buff.length - token.length
if (remaining > 0) {
yield buff.slice(0, remaining)
}
e.end()
} else {
yield buff
}
e.end()
} else {
yield buff
}
} else {
for await (const chunk of source) {
if (chunk === goodbye) {
e.end()
} else {
yield chunk
}
}
}

@@ -28,0 +40,0 @@ })())

{
"name": "it-goodbye",
"description": "Add a goodbye handshake to a duplex async iterable",
"version": "2.0.0",
"version": "2.0.1",
"homepage": "https://github.com/alanshaw/it-goodbye",

@@ -13,3 +13,3 @@ "repository": {

"async-iterator-to-pull-stream": "^1.3.0",
"muxrpc": "^2.1.0",
"muxrpc": "^6.4.2",
"pull-stream": "^3.6.9",

@@ -20,3 +20,4 @@ "streaming-iterables": "^4.0.2",

"scripts": {
"test": "set -e; for t in test/*.js; do node $t; done"
"test": "set -e; for t in test/*.js; do node $t; done",
"lint": "standard"
},

@@ -23,0 +24,0 @@ "author": "Alan Shaw",

# it-goodbye
[![Build Status](https://travis-ci.org/alanshaw/it-pipe.svg?branch=master)](https://travis-ci.org/alanshaw/it-goodbye)
[![dependencies Status](https://david-dm.org/alanshaw/it-pipe/status.svg)](https://david-dm.org/alanshaw/it-goodbye)
[![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)
Add a goodbye handshake to a [duplex async iterable](https://gist.github.com/alanshaw/591dc7dd54e4f99338a347ef568d6ee9#duplex-it).

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

@@ -8,6 +8,8 @@ var tape = require('tape')

var client = {
async: ['hello', 'goodbye'],
source: ['stuff', 'bstuff'],
sink: ['things'],
duplex: ['suchstreamwow']
hello: 'async',
goodbye: 'async',
stuff: 'source',
bstuff: 'source',
things: 'sink',
suchstreamwow: 'duplex'
}

@@ -32,3 +34,3 @@

}
}))
}, 6))
}

@@ -35,0 +37,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