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

exec-buffer

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

exec-buffer - npm Package Compare versions

Comparing version

to
1.1.0

114

index.js

@@ -15,8 +15,8 @@ 'use strict';

function ExecBuffer() {
if (!(this instanceof ExecBuffer)) {
return new ExecBuffer();
}
if (!(this instanceof ExecBuffer)) {
return new ExecBuffer();
}
this.src(tempfile());
this.dest(tempfile());
this.src(tempfile());
this.dest(tempfile());
}

@@ -33,5 +33,5 @@

ExecBuffer.prototype.use = function (bin, args) {
this.bin = bin;
this.args = args;
return this;
this.bin = bin;
this.args = args;
return this;
};

@@ -47,8 +47,8 @@

ExecBuffer.prototype.src = function (path) {
if (!arguments.length) {
return this._src;
}
if (!arguments.length) {
return this._src;
}
this._src = path;
return this;
this._src = path;
return this;
};

@@ -64,8 +64,8 @@

ExecBuffer.prototype.dest = function (path) {
if (!arguments.length) {
return this._dest;
}
if (!arguments.length) {
return this._dest;
}
this._dest = path;
return this;
this._dest = path;
return this;
};

@@ -76,3 +76,3 @@

*
* @param {Buffer} buffer
* @param {Buffer} buf
* @param {Function} cb

@@ -83,47 +83,47 @@ * @api public

ExecBuffer.prototype.run = function (buf, cb) {
var self = this;
var src = this.src();
var dest = this.dest();
var self = this;
var src = this.src();
var dest = this.dest();
fs.writeFile(src, buf, function (err) {
if (err) {
cb(err);
return;
}
fs.writeFile(src, buf, function (err) {
if (err) {
cb(err);
return;
}
execFile(self.bin, self.args, function (err, stdout, stderr) {
if (err) {
cb(err);
return;
}
execFile(self.bin, self.args, function (err, stdout, stderr) {
if (err) {
cb(err);
return;
}
if (stderr) {
cb(stderr);
return;
}
if (stderr) {
cb(stderr);
return;
}
fs.readFile(dest, function (err, data) {
if (err) {
cb(err);
return;
}
fs.readFile(dest, function (err, data) {
if (err) {
cb(err);
return;
}
rm(src, function (err) {
if (err) {
cb(err);
return;
}
rm(src, function (err) {
if (err) {
cb(err);
return;
}
rm(dest, function (err) {
if (err) {
cb(err);
return;
}
rm(dest, function (err) {
if (err) {
cb(err);
return;
}
cb(null, data);
});
});
});
});
});
cb(null, data);
});
});
});
});
});
};

@@ -130,0 +130,0 @@

{
"name": "exec-buffer",
"version": "1.0.1",
"version": "1.1.0",
"description": "Run a buffer through a child process",

@@ -5,0 +5,0 @@ "license": "MIT",

@@ -21,11 +21,11 @@ # exec-buffer [![Build Status](https://travis-ci.org/kevva/exec-buffer.svg?branch=master)](https://travis-ci.org/kevva/exec-buffer)

execBuffer
.use(gifsicle, ['-o', execBuffer.dest(), execBuffer.src()])
.run(fs.readFileSync('test.gif'), function (err, data) {
if (err) {
throw err;
}
.use(gifsicle, ['-o', execBuffer.dest(), execBuffer.src()])
.run(fs.readFileSync('test.gif'), function (err, data) {
if (err) {
throw err;
}
console.log(data);
// <Buffer 47 49 46 38 37 61 ...>
});
console.log(data);
// <Buffer 47 49 46 38 37 61 ...>
});
});

@@ -36,3 +36,3 @@ ```

### new ExecBuffer
### new ExecBuffer()

@@ -43,6 +43,18 @@ Creates a new `ExecBuffer` instance.

Accepts a path to a binary and an `Array` of arguments.
#### bin
Type: `String`
Path to the binary.
#### args
Type: `Array`
Arguments to run the binary with.
### .src(path)
Type: `String`
Set or get the temporary source path.

@@ -52,2 +64,4 @@

Type: `String`
Set or get the temporary destination path.

@@ -57,6 +71,16 @@

Run the `Buffer` through the child process.
#### buf
Type: `Buffer`
The `Buffer` to be ran through the child process.
#### cb(err, data)
Type: `Function`
Returns a `Buffer` with the new data.
## License
MIT © [Kevin Mårtensson](https://github.com/kevva)