Reputation: 7030
I have a Buffer with tar contents and I would like to parse this with tar node.js package, but all examples of use of this package are using .pipe() and streams - how can I pass buffer to tar package?
I get Buffer from AWS SDK.
Upvotes: 0
Views: 707
Reputation: 161477
Streams have a standard API, so you can just use write
and end
directly instead of using pipe
.
var data = ... // Buffer
var parser = tar.Parse();
// Bind whatever handlers you would normally bind
parser.on('entry', function(e){
});
// Write the data into the parser, which will parse it and trigger your event handlers
parser.end(data);
Upvotes: 1