stream-normalize-eol

A duplex stream that normalizes the end of line characters

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
stream-normalize-eol
301.0.18 years ago8 years agoMinified + gzip package size for stream-normalize-eol in KB

Readme

stream-normalize-eol
A duplex stream that normalizes the end of line characters.
API
```js var normalize = require("stream-normalize-eol"); var stream = normalize("\n"); // pipe input and output streams to stream. ```

normalize(format)

Returns a duplex stream that normalizes the end of line characters to the desired format. format is a string that can be one of the following:
  • "\n": Unix format (LF) / default
  • "\r\n": Windows format (CR/LF)
  • "\r": Old Mac format (CR)
Example
```js var fs = require("fs"); var normalize = require("stream-normalize-eol"); fs.writeFileSync("hello.txt", "Hello\nWorld", "utf8"); var input = fs.createReadStream("hello.txt"); var stream = normalize("\r\n"); stream.on("data", function(chunk) { console.log(JSON.stringify(chunk.toString())); }); input.pipe(stream); // prints "Hello\r\nWorld" ```
License
MIT