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

minipass

Package Overview
Dependencies
Maintainers
1
Versions
94
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

minipass - npm Package Compare versions

Comparing version 1.1.4 to 1.1.5

.nyc_output/748a26bb08f32195a101e573767e03c9.json

29

index.js

@@ -11,2 +11,4 @@ 'use strict'

const SD = require('string_decoder').StringDecoder
const ENCODING = Symbol('encoding')
const DECODER = Symbol('decoder')

@@ -19,6 +21,6 @@ class MiniPass extends EE {

this.buffer = new Yallist()
this.encoding = options && options.encoding || null
if (this.encoding === 'buffer')
this.encoding = null
this.decoder = this.encoding ? new SD(this.encoding) : null
this[ENCODING] = options && options.encoding || null
if (this[ENCODING] === 'buffer')
this[ENCODING] = null
this[DECODER] = this[ENCODING] ? new SD(this[ENCODING]) : null
this[EOF] = false

@@ -28,2 +30,13 @@ this[EMITTED_END] = false

get encoding () { return this[ENCODING] }
set encoding (enc) {
if (enc !== this[ENCODING])
this[DECODER] = enc ? new SD(enc) : null
this[ENCODING] = enc
}
setEncoding (enc) {
this.encoding = enc
}
get writable () { return true }

@@ -152,4 +165,4 @@ get readable () { return true }

if (ev === 'data') {
if (this.decoder)
data = this.decoder.write(data)
if (this[DECODER])
data = this[DECODER].write(data)

@@ -162,4 +175,4 @@ if (!data)

} else if (ev === 'end') {
if (this.decoder) {
data = this.decoder.end()
if (this[DECODER]) {
data = this[DECODER].end()
if (data) {

@@ -166,0 +179,0 @@ this.pipes.forEach(dest => dest.write(data))

{
"name": "minipass",
"version": "1.1.4",
"version": "1.1.5",
"description": "minimal implementation of a PassThrough stream",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -5,3 +5,6 @@ const MiniPass = require('../')

t.test('some basic piping and writing', async t => {
let mp = new MiniPass()
let mp = new MiniPass({ encoding: 'base64' })
t.equal(mp.encoding, 'base64')
mp.encoding = null
t.equal(mp.encoding, null)
t.equal(mp.readable, true)

@@ -32,3 +35,4 @@ t.equal(mp.writable, true)

const mp = new MiniPass({ encoding: 'utf8' })
t.plan(1)
t.plan(2)
t.equal(mp.encoding, 'utf8')
mp.on('data', chunk => {

@@ -45,2 +49,22 @@ t.equal(chunk, butterfly)

t.test('unicode splitting with setEncoding', async t => {
const butterfly = '🦋'
const mp = new MiniPass({ encoding: 'hex' })
t.plan(4)
t.equal(mp.encoding, 'hex')
mp.setEncoding('hex')
t.equal(mp.encoding, 'hex')
mp.setEncoding('utf8')
t.equal(mp.encoding, 'utf8')
mp.on('data', chunk => {
t.equal(chunk, butterfly)
})
const butterbuf = new Buffer([0xf0, 0x9f, 0xa6, 0x8b])
mp.write(butterbuf.slice(0, 1))
mp.write(butterbuf.slice(1, 2))
mp.write(butterbuf.slice(2, 3))
mp.write(butterbuf.slice(3, 4))
mp.end()
})
t.test('base64 -> utf8 piping', t => {

@@ -47,0 +71,0 @@ t.plan(1)

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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