Comparing version 1.2.1 to 1.3.0
12
index.js
@@ -29,3 +29,8 @@ /* jshint node:true */ | ||
args.push(file); | ||
if (file && typeof file.pipe === "function") { | ||
args.push("-"); | ||
options.stdin = file; | ||
} else { | ||
args.push(file); | ||
} | ||
@@ -75,2 +80,7 @@ run(args, options) | ||
// If passed stdin stream, pipe it to the child process | ||
if (options.stdin) { | ||
options.stdin.pipe(cp.stdin); | ||
} | ||
// Pass fpcalc stdout through the stream | ||
@@ -77,0 +87,0 @@ cp.stdout.pipe(stream); |
{ | ||
"name": "fpcalc", | ||
"version": "1.2.1", | ||
"version": "1.3.0", | ||
"description": "Calculate AcoustID audio fingerprint", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -43,4 +43,6 @@ # fpcalc | ||
*File* must be the path to an audio file. | ||
*File* must be the path to an audio file or a readable stream. | ||
If using a stream, note that you will not get `duration` out due to an [fpcalc issue](https://github.com/acoustid/chromaprint/issues/53). | ||
*Options* may be an object with any of the following keys: | ||
@@ -47,0 +49,0 @@ |
@@ -5,2 +5,3 @@ /* jshint node:true */ | ||
var path = require("path"), | ||
fs = require("fs"), | ||
test = require("tape"), | ||
@@ -56,1 +57,26 @@ fpcalc = require("../"); | ||
}); | ||
test("stream input", function(t) { | ||
t.plan(5); | ||
fpcalc(fs.createReadStream(TEST_FILE), {raw: true}, function(err, result) { | ||
t.ok(result.fingerprint); | ||
t.ok(Buffer.isBuffer(result.fingerprint)); | ||
}); | ||
fpcalc(fs.createReadStream(TEST_FILE), function(err, result) { | ||
t.ok(result.fingerprint); | ||
t.equal(typeof result.fingerprint, "string"); | ||
t.ok(/^[-_a-zA-Z0-9]+$/.test(result.fingerprint)); | ||
}); | ||
}); | ||
test("stream fignerprint is the same as file fingerprint", function(t) { | ||
t.plan(1); | ||
fpcalc(fs.createReadStream(TEST_FILE), function(err, streamResult) { | ||
fpcalc(TEST_FILE, function(err, fileResult) { | ||
t.equal(fileResult.fingerprint, streamResult.fingerprint); | ||
}); | ||
}); | ||
}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
206203
179
69
5
1