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,EAAG,GAAG,SAAS,SAAS,GACV,IAAT,GACH,EAAO,KAAK,QAAS,IAAI,MAAM,kBAGhC,EAAO,MAAM,KACd,IAEO,CACR,CAIA,SAAS,QACR,OAAO,GAAG,SAET,GAAG,QAEH,OAAO,SAEP,GAAG,QAAQ,WAEX,QAAO,SAAS,EAAQ,GAEvB,OADA,EAAO,EAAK,MAAQ,EAAK,MAClB,CACR,GAAG,CAAC,GAEN,CAIA,SAAS,UAAU,GAClB,IAAI,EAAQ,EAAK,QAAQ,KACzB,MAAO,CACN,KAAM,EAAK,MAAM,EAAG,GAAO,cAC3B,MAAO,EAAK,MAAM,EAAQ,GAE5B","file":"/npm/fpcalc@1.3.0/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.37.0.\n * Original file: /npm/fpcalc@1.3.0/index.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","/* jshint node:true */\n\"use strict\";\n\nvar once = require(\"once\");\n\nmodule.exports = function(file, options, callback) {\n\t// Handle `options` parameter being optional\n\tif ( ! callback) {\n\t\tcallback = options;\n\t\toptions = {};\n\t}\n\n\t// Make sure the callback is called only once\n\tcallback = once(callback);\n\n\t// Command-line arguments to pass to fpcalc\n\tvar args = [];\n\n\t// `-length` command-line argument\n\tif (options.length) {\n\t\targs.push(\"-length\", options.length);\n\t}\n\n\t// `-raw` command-line argument\n\tif (options.raw) {\n\t\targs.push(\"-raw\");\n\t}\n\n\tif (file && typeof file.pipe === \"function\") {\n\t\targs.push(\"-\");\n\t\toptions.stdin = file;\n\t} else {\n\t\targs.push(file);\n\t}\n\n\trun(args, options)\n\t\t.on(\"error\", callback)\n\t\t.pipe(parse())\n\t\t.on(\"data\", function(results) {\n\t\t\tif (options.raw) {\n\t\t\t\tvar fingerprint = results.fingerprint\n\t\t\t\t\t.split(\",\")\n\t\t\t\t\t.map(function(value) {\n\t\t\t\t\t\treturn parseInt(value);\n\t\t\t\t\t});\n\t\t\t\tresults.fingerprintRaw = results.fingerprint;\n\t\t\t\tresults.fingerprint = new Buffer(fingerprint.length * 4);\n\t\t\t\tfor (var i = 0; i < fingerprint.length; i ++) {\n\t\t\t\t\tresults.fingerprint.writeInt32BE(fingerprint[i], i * 4, true);\n\t\t\t\t}\n\t\t\t}\n\t\t\tcallback(null, results);\n\t\t});\n};\n\n// -- Run fpcalc command\n\nvar spawn = require(\"child_process\").spawn,\n\tes = require(\"event-stream\"),\n\tconcat = require(\"concat-stream\"),\n\tfilter = require(\"stream-filter\"),\n\treduce = require(\"stream-reduce\");\n\n// Runs the fpcalc tool and returns a readable stream that will emit stdout\n// or an error event if an error occurs\nfunction run(args, options) {\n\tvar\n\t\t// The command to run\n\t\tcommand = options.command || \"fpcalc\",\n\n\t\t// Start the  fpcalc child process\n\t\tcp = spawn(command, args),\n\n\t\t// Create the stream that we will eventually return. This stream\n\t\t// passes through any data (cp's stdout) but does not emit an end\n\t\t// event so that we can make sure the process exited without error.\n\t\tstream = es.through(null, function() {});\n\n\t// If passed stdin stream, pipe it to the child process\n\tif (options.stdin) {\n\t\toptions.stdin.pipe(cp.stdin);\n\t}\n\n\t// Pass fpcalc stdout through the stream\n\tcp.stdout.pipe(stream);\n\n\t// Catch fpcalc stderr errors even when exit code is 0\n\t// See https://bitbucket.org/acoustid/chromaprint/issue/2/fpcalc-return-non-zero-exit-code-if\n\tcp.stderr.pipe(concat(function(data) {\n\t\tif (data &&\n\t\t\t(data = data.toString()) &&\n\t\t\tdata.slice(0, 6) === \"ERROR:\") {\n\t\t\tstream.emit(\"error\", new Error(data));\n\t\t}\n\t}));\n\n\t// Check process exit code and end the stream\n\tcp.on(\"close\", function(code) {\n\t\tif (code !== 0) {\n\t\t\tstream.emit(\"error\", new Error(\"fpcalc failed\"));\n\t\t}\n\n\t\tstream.queue(null);\n\t});\n\n\treturn stream;\n}\n\n// -- fpcalc stdout stream parsing\n\nfunction parse() {\n\treturn es.pipeline(\n\t\t// Parse one complete line at a time\n\t\tes.split(),\n\t\t// Only use non-empty lines\n\t\tfilter(Boolean),\n\t\t// Parse each line into name/value pair\n\t\tes.mapSync(parseData),\n\t\t// Reduce data into single result object to pass to callback\n\t\treduce(function(result, data) {\n\t\t\tresult[data.name] = data.value;\n\t\t\treturn result;\n\t\t}, {})\n\t);\n}\n\n// Data is given as lines like `FILE=path/to/file`, so we split the\n// parts out to a name/value pair\nfunction parseData(data) {\n\tvar index = data.indexOf(\"=\");\n\treturn {\n\t\tname: data.slice(0, index).toLowerCase(),\n\t\tvalue: data.slice(index + 1),\n\t};\n}\n"]}