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

child-process-parser

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

child-process-parser - npm Package Compare versions

Comparing version 1.0.0 to 2.0.0

rand.sh

30

lib/child-process-parser.js
var cp = require('child_process');
var async = require('async');

@@ -6,2 +7,4 @@ module.exports = function (command, delimeter, consumer, cb) {

var spawned_process = cp.spawn(cmd.shift(), cmd);
var pauseCount = 0;
var workerQueue = new async.queue(consumer);

@@ -11,10 +14,20 @@ var temp_string = '';

spawned_process.stdout.on('data', (data) => {
if (!pauseCount) spawned_process.stdout.pause();
pauseCount++;
temp_string += `${data}`;
if (temp_string.indexOf(delimeter) > -1) {
var splitEntries = temp_string.split(delimeter);
for (var i = 0; i < splitEntries.length - 1; i++) {
consumer(splitEntries[i]);
var doneCycle = function () {
pauseCount--;
if (!pauseCount);
spawned_process.stdout.resume();
}
if (temp_string.indexOf(delimeter) === -1) return doneCycle();
var splitEntries = temp_string.split(delimeter);
temp_string = splitEntries[splitEntries.length - 1];
if (splitEntries.length > 2) {
for (var i = 0; i < splitEntries.length - 2; i++) {
workerQueue.push(splitEntries[i]);
}
temp_string = splitEntries[splitEntries.length - 1];
}
workerQueue.push(splitEntries[splitEntries.length - 2], doneCycle);
});

@@ -24,6 +37,9 @@

if (temp_string.length > 0) {
consumer(temp_string);
workerQueue.push(temp_string);
}
cb(code)
if (workerQueue.length() === 0) return cb(code);
workerQueue.drain = function () {
cb(code);
}
});
}
{
"name": "child-process-parser",
"version": "1.0.0",
"version": "2.0.0",
"description": "Easier parsing of child process stdout",

@@ -28,6 +28,7 @@ "main": "lib/child-process-parser.js",

"devDependencies": {
"mocha": "^2.3.4"
"filesize": "^3.3.0",
"mocha": "^2.3.4",
"sleep": "^4.0.0"
},
"dependencies": {
}
"dependencies": {}
}
var assert = require('assert');
var cp = require('../lib/child-process-parser');
var sleep = require('sleep');
describe('Basic Tests', function() {
it('Echo Test', function (done) {
var word_list = [];
cp(['echo', 'one', '2', 'three', '4'], ' ', function (word) {
cp(['echo', 'one', '2', 'three', '4'], ' ', function (word, cb) {
word_list.push(word);
cb();
}, function (eCode) {

@@ -15,2 +18,11 @@ assert.equal(eCode, 0);

});
it('Rand Test', function (done) {
var word_list = [];
cp(['bash', './rand.sh', '10'], '\n', function (word, cb) {
setTimeout(cb, 1);
}, function (eCode) {
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