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

44

index.js

@@ -12,7 +12,47 @@ var _ = require('highland');

return function(stream) {
stream.pipe(process.stdin);
return exports.from(process);
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() {

@@ -19,0 +59,0 @@ var message = '';

2

package.json
{
"name": "highland-process",
"version": "1.0.0",
"version": "1.0.1",
"description": "Utility that lets you turn a process into a highland stream.",

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

@@ -19,2 +19,25 @@ var _ = require('highland'),

});
it('passes through errors', function(done) {
var isErrorPassed = false,
stream = _(function(push, next) {
push(null, 'hello');
push(new Error('find me!'));
push(null, ' bye');
push(null, _.nil);
next();
}),
tee = spawn('tee');
stream
.through(through(tee))
.errors(function(error, push) {
isErrorPassed = error.message === 'find me!';
})
.toArray(function(results) {
assert.equal(results[0].toString('utf8'), 'hello bye');
assert.isTrue(isErrorPassed);
done();
});
});
});
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