New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@saulx/utils

Package Overview
Dependencies
Maintainers
1
Versions
67
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@saulx/utils - npm Package Compare versions

Comparing version 1.2.0 to 1.2.1

25

dist/readStream.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const stream_1 = require("stream");
exports.default = (stream) => new Promise((resolve, reject) => {
stream.on('error', err => {
let pipit = false;
let s = stream;
if (stream instanceof stream_1.Readable || stream instanceof stream_1.PassThrough) {
s = stream;
}
else if (stream instanceof stream_1.Writable || stream instanceof stream_1.Duplex) {
s = new stream_1.PassThrough();
pipit = true;
}
else {
console.warn('not an instance of stream - trying writable');
// @ts-ignore
s = new stream_1.PassThrough(stream);
}
s.on('error', err => {
reject(err);
});
let buffers = [];
stream.on('data', s => {
s.on('data', s => {
buffers.push(s);
});
stream.on('end', () => {
s.on('end', () => {
resolve(Buffer.from(buffers));
});
if (pipit) {
// @ts-ignore
stream.pipe(s);
}
});
//# sourceMappingURL=readStream.js.map

2

package.json
{
"name": "@saulx/utils",
"main": "./dist/index.js",
"version": "1.2.0",
"version": "1.2.1",
"scripts": {

@@ -6,0 +6,0 @@ "build": "tsc",

@@ -1,15 +0,32 @@

import { Stream } from 'stream'
import { Stream, Readable, PassThrough, Writable, Duplex } from 'stream'
export default (stream: Stream): Promise<Buffer> =>
new Promise((resolve, reject) => {
stream.on('error', err => {
let pipit = false
let s = stream
if (stream instanceof Readable || stream instanceof PassThrough) {
s = stream
} else if (stream instanceof Writable || stream instanceof Duplex) {
s = new PassThrough()
pipit = true
} else {
console.warn('not an instance of stream - trying writable')
// @ts-ignore
s = new PassThrough(stream)
}
s.on('error', err => {
reject(err)
})
let buffers = []
stream.on('data', s => {
s.on('data', s => {
buffers.push(s)
})
stream.on('end', () => {
s.on('end', () => {
resolve(Buffer.from(buffers))
})
if (pipit) {
// @ts-ignore
stream.pipe(s)
}
})

@@ -606,16 +606,9 @@ import test from 'ava'

test.cb('readStream', t => {
const { PassThrough, Writable } = require('stream')
const { PassThrough } = require('stream')
const pass = new PassThrough()
const writable = new Writable()
pass.write('ok') // Will not emit 'data'.
readStream(pass).then(v => {
console.log('done!', v.toString())
t.end()
})
pass.pipe(writable)
pass.unpipe(writable)
// readableFlowing is now false.
pass.resume()
setTimeout(() => {
pass.end('x')
}, 100)
pass.end(Buffer.from('flap'))
})

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