stream-normalize-eol

1.0.1 • Public • Published

stream-normalize-eol

A duplex stream that normalizes the end of line characters.

API

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

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

Package Sidebar

Install

npm i stream-normalize-eol

Weekly Downloads

31

Version

1.0.1

License

MIT

Last publish

Collaborators

  • asyncmax