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

highland-process

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

highland-process - npm Package Compare versions

Comparing version 1.0.1 to 1.0.2

lib/process.js

78

index.js

@@ -1,77 +0,1 @@

var _ = require('highland');
exports.from = function from(process) {
return _.sequence([
_(process.stdout),
_(process.stderr).consume(errorConsumer())
]);
};
exports.through = function through(process) {
return function(stream) {
var out,
pipe;
out = exports.from(process);
// like `_.pipe` but separate errors
pipe = stream.consume(function(error, value, push, next) {
if (error) {
// send errors to the out directly
out.write(new StreamError(error));
return next();
}
if (value === nil) {
return process.stdin.end();
}
if (process.stdin.write(value) !== false) {
next();
}
});
process.stdin.on('drain', onConsumerDrain);
stream._destructors.push(function () {
process.stdin.removeListener('drain', onConsumerDrain);
});
function onConsumerDrain() {
pipe.resume();
}
pipe.resume();
return out;
};
};
// TODO(ibash) remove this in favor of using the actual StreamError from highland
// ref: https://github.com/Datahero/datahero-node/issues/9676
function StreamError(err) {
this.__HighlandStreamError__ = true;
this.error = err;
}
function errorConsumer() {
var message = '';
return function consumer(error, value, push, next) {
if (error) {
push(error);
return next();
}
if (value === _.nil) {
if (message) {
push(new Error(message));
}
push(null, _.nil);
return next();
}
message += value;
next();
};
}
module.exports = require('./lib/process');
{
"name": "highland-process",
"version": "1.0.1",
"version": "1.0.2",
"description": "Utility that lets you turn a process into a highland stream.",

@@ -29,4 +29,5 @@ "main": "index.js",

"dependencies": {
"highland": "^2.2.0"
"highland": "^2.2.0",
"highland-errors-to": "^1.0.0"
}
}
var _ = require('highland'),
assert = require('chai').assert,
exec = require('child_process').exec,
spawn = require('child_process').spawn,

@@ -34,2 +35,21 @@ from = require('../index').from;

});
it('splits errors by newline', function(done) {
var errors = exec('>&2 printf "error\\nerror2"');
errorCalled = 0;
from(errors)
.errors(function(error, push) {
errorCalled++;
if (errorCalled === 1) {
assert.equal(error.message, 'error');
} else {
assert.equal(error.message, 'error2');
}
})
.apply(function() {
assert.equal(errorCalled, 2);
done();
});
});
});

@@ -27,3 +27,2 @@ var _ = require('highland'),

push(null, _.nil);
next();
}),

@@ -30,0 +29,0 @@ tee = spawn('tee');

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