Huge News!Announcing our $40M Series B led by Abstract Ventures.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.1 to 1.3.0

32

dist/readStream.js

@@ -5,16 +5,3 @@ "use strict";

exports.default = (stream) => new Promise((resolve, reject) => {
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);
}
const s = new stream_1.PassThrough();
s.on('error', err => {

@@ -25,12 +12,15 @@ reject(err);

s.on('data', s => {
buffers.push(s);
if (typeof s === 'string') {
buffers.push(Buffer.from(s));
}
else {
buffers.push(s);
}
});
s.on('end', () => {
resolve(Buffer.from(buffers));
s.on('end', x => {
resolve(Buffer.concat(buffers));
});
if (pipit) {
// @ts-ignore
stream.pipe(s);
}
// @ts-ignore
stream.pipe(s);
});
//# sourceMappingURL=readStream.js.map
{
"name": "@saulx/utils",
"main": "./dist/index.js",
"version": "1.2.1",
"version": "1.3.0",
"scripts": {

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

@@ -1,17 +0,6 @@

import { Stream, Readable, PassThrough, Writable, Duplex } from 'stream'
import { Stream, PassThrough } from 'stream'
export default (stream: Stream): Promise<Buffer> =>
new Promise((resolve, reject) => {
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)
}
const s = new PassThrough()
s.on('error', err => {

@@ -22,12 +11,13 @@ reject(err)

s.on('data', s => {
buffers.push(s)
if (typeof s === 'string') {
buffers.push(Buffer.from(s))
} else {
buffers.push(s)
}
})
s.on('end', () => {
resolve(Buffer.from(buffers))
s.on('end', x => {
resolve(Buffer.concat(buffers))
})
if (pipit) {
// @ts-ignore
stream.pipe(s)
}
// @ts-ignore
stream.pipe(s)
})

@@ -607,8 +607,10 @@ import test from 'ava'

const { PassThrough } = require('stream')
const pass = new PassThrough()
pass.write('ok') // Will not emit 'data'.
readStream(pass).then(v => {
const { createReadStream } = require('fs')
const { join } = require('path')
readStream(createReadStream(join(__dirname, '../package.json'))).then(v => {
const pkg = JSON.parse(v.toString())
t.is(pkg.name, '@saulx/utils')
t.end()
})
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