This is a pure-javascript implementation of unrar. The code has been ported from Jeff Schiller's bitjs, Thanks :).
synchronous usage:
var unrar = require('unrar.js'),
fs = require('fs'),
unpackedFiles;
unpackedFiles = unrar.unrarSync("ARCHIVE_PATH", {
onProgress: function(data) {
var l_nPercent = Math.round((data.currentBytesUnarchived / data.totalUncompressedBytesInArchive) * 100);
console.log("Progress: ", l_nPercent, "%");
}
});
unpackedFiles.forEach(function(file){
console.log(file.filename, file.fileData.length);
});
asynchronous usage:
var unrar = require('unrar.js'),
fs = require('fs');
unrar.unrar("ARCHIVE_PATH", "OUTPUT_DIRECTORY", {
onProgress: function(data) {
var l_nPercent = Math.round((data.currentBytesUnarchived / data.totalUncompressedBytesInArchive) * 100);
console.log("Progress: ", l_nPercent, "%");
}
}, function(err, unpackedFiles) {
unpackedFiles.forEach(function(file){
console.log(file.filename, file.fileData.length);
});
});
the asynchronous method needs to write to disk because it runs in a child process, and transferring the binaries over a string channel is pretty damn slow. Maybe one day, I'll try using local sockets ;)