summaryrefslogtreecommitdiff
path: root/deps/npm/node_modules/tar/old/test/test-parser.js
blob: ffc87a13f4449eecdc9be93d63af87284075f41f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
var p = require("../tar").createParser()
  , fs = require("fs")
  , tar = require("../tar")

p.on("file", function (file) {
  console.error("file start", file.name, file.size, file.extended)
  console.error(file)
  Object.keys(file._raw).forEach(function (f) {
    console.log(f, file._raw[f].toString().replace(/\0+$/, ""))
  })
  file.on("data", function (c) {
    console.error("data", c.toString().replace(/\0+$/, ""))
  })
  file.on("end", function () {
    console.error("end", file.name)
  })
})


var s = fs.createReadStream(__dirname + "/test-generator.tar")
s.on("data", function (c) {
  console.error("stream data", c.toString())
})
s.on("end", function () { console.error("stream end") })
s.on("close", function () { console.error("stream close") })
p.on("end", function () { console.error("parser end") })

s.pipe(p)