空的gzip,但我不知道为什么

时间:2015-08-28 18:58:12

标签: node.js gzip zlib

我得到一个空的gzip(它只创建.gz文件,但它是空的,我尝试用7zip打开它时出错),所有文件都存在且不为空:

    var zlib = require('zlib');
var gzip = zlib.createGzip();
var fs = require('fs');

var JSinp = fs.createReadStream('public/javascripts/final/end_0.0.0.min.js');
var JSout = fs.createWriteStream('public/javascripts/final/end_0.0.0.min.js.gz');
JSinp.pipe(gzip).pipe(JSout);

所以我不知道为什么?

JSinp看起来像(调试):

    result = ReadStream
 autoClose = true
 domain = null
 end = undefined
 fd = null
 flags = "r"
 mode = 438
 path = "public/javascripts/final/end_0.0.0.min.js"
 pos = undefined
 readable = true
 start = undefined
 _events = Object
 _maxListeners = undefined
 _readableState = ReadableState
  awaitDrain = 0
  buffer = Array[0]
  decoder = null
  defaultEncoding = "utf8"
  emittedReadable = false
  encoding = null
  endEmitted = false
  ended = false
  flowing = null
  highWaterMark = 65536
  length = 0
  needReadable = false
  objectMode = false
  pipes = null
  pipesCount = 0
  ranOut = false
  readableListening = false
  reading = false
  readingMore = false
  sync = true
  __proto__ = ReadableState
 __proto__ = ReadStream

JSout看起来像(调试):

    result = WriteStream
 bytesWritten = 0
 domain = null
 fd = null
 flags = "w"
 mode = 438
 path = "public/javascripts/final/end_0.0.0.min.js.gz"
 pos = undefined
 start = undefined
 writable = true
 _events = Object
 _maxListeners = undefined
 _writableState = WritableState
  bufferProcessing = false
  bufferedRequest = null
  corked = 0
  decodeStrings = true
  defaultEncoding = "utf8"
  ended = false
  ending = false
  errorEmitted = false
  finished = false
  highWaterMark = 16384
  lastBufferedRequest = null
  length = 0
  needDrain = false
  objectMode = false
  onwrite = function (er) {
  pendingcb = 0
  prefinished = false
  sync = true
  writecb = null
  writelen = 0
  writing = false
  __proto__ = WritableState
 __proto__ = WriteStream

调用“JSinp.pipe(gzip).pipe(JSout);”(调试器):

    result = WriteStream
 bytesWritten = 0
 domain = null
 fd = null
 flags = "w"
 mode = 438
 path = "public/javascripts/final/end_0.0.0.min.js.gz"
 pos = undefined
 start = undefined
 writable = true
 _events = Object
 _maxListeners = undefined
 _writableState = WritableState
  bufferProcessing = false
  bufferedRequest = null
  corked = 0
  decodeStrings = true
  defaultEncoding = "utf8"
  ended = false
  ending = false
  errorEmitted = false
  finished = false
  highWaterMark = 16384
  lastBufferedRequest = null
  length = 0
  needDrain = false
  objectMode = false
  onwrite = function (er) {
  pendingcb = 0
  prefinished = false
  sync = true
  writecb = null
  writelen = 0
  writing = false
  __proto__ = WritableState
 __proto__ = WriteStream

0 个答案:

没有答案