2

How do you define the flush method when compressing a buffer using Node.js's built-in zlib module? Specifically, I need Z_SYNC_FLUSH. There doesn't seem to be a place in the options to set this flag.

http://nodejs.org/api/zlib.html

4

1 回答 1

1

啊,我想通了。这有点骇人听闻,但您必须修改 flush 属性。这有点相当于修改其他语言的公共类属性,所以有点脏。我不知道这是否会一直有效,但它得到了我想要的。

compressor = zlib.createDeflate();
compressor._flush = zlib.Z_SYNC_FLUSH;
于 2012-09-20T01:24:03.503 回答