normalize style for #57

This commit is contained in:
Mathias Buus 2016-05-07 17:04:02 +02:00
parent 6fa71636de
commit f50e71b53a

View file

@ -131,34 +131,30 @@ pack.pipe(newTarballStream)
``` js ``` js
var fs = require('fs'); var fs = require('fs')
var tar = require('tar-stream'); var tar = require('tar-stream')
var pack = tar.pack(); // pack is a streams2 stream var pack = tar.pack() // pack is a streams2 stream
var path = 'YourTarBall.tar'; var path = 'YourTarBall.tar'
var yourTarball = fs.createWriteStream(path); var yourTarball = fs.createWriteStream(path)
// add a file called YourFile.txt with the content "Hello World!" // add a file called YourFile.txt with the content "Hello World!"
pack.entry({ pack.entry({name: 'YourFile.txt'}, 'Hello World!', function (err) {
name: 'YourFile.txt' if (err) throw err
}, 'Hello World!', () => { pack.finalize()
pack.finalize(); })
});
// pipe the pack stream to your file // pipe the pack stream to your file
pack.pipe(yourTarball); pack.pipe(yourTarball)
yourTarball.on('close', () => { yourTarball.on('close', function () {
console.log(path + ' has been written'); console.log(path + ' has been written')
fs.stat(path, function(err, stats) { fs.stat(path, function(err, stats) {
if (err) { if (err) throw err
return console.error(err); console.log(stats)
} console.log('Got file info successfully!')
console.log(stats); })
console.log("Got file info successfully!"); })
});
});
``` ```
## Performance ## Performance