fshost / node-dir

Recursive asynchronous file and directory operations for Node.js
MIT License
221 stars 44 forks source link

Don't call stream.setEncoding() if options.encoding is strictly null #29

Closed apazzolini closed 8 years ago

apazzolini commented 8 years ago

When stream.setEncoding is called, it additionally sets the decoder in the underlying stream. Unfortunately, despite what the official documentation says, calling setEncoding(null) sets the underlying decoder to UTF-8.

This causes problems when you need the raw buffer data of a file to pipe elsewhere, such as a zlib.gunzip stream for gunzipping files.

This pull request allows specifying { encoding: null } to disable that call.