Research
Security News
Kill Switch Hidden in npm Packages Typosquatting Chalk and Chokidar
Socket researchers found several malicious npm packages typosquatting Chalk and Chokidar, targeting Node.js developers with kill switches and data theft.
convert-newline
Advanced tools
Unify newline characters to either \n
,\r\n
, or \r
.
var convertNewline = require("convert-newline");
var converter = convertNewline("lf").string();
converter("AAA\rBBB\r\nCCC\n"); // -> "AAA\nBBB\nCCC\n"
var convertNewline = require("convert-newline");
var buffer = new Buffer("AAA\rBBB\r\nCCC\n");
var converter = convertNewline("lf").buffer();
var newBuffer = converter(buffer);
newBuffer.toString(); // -> "AAA\nBBB\nCCC\n"
Converting non-utf8 encoded buffers is supported.
var iconv = require("iconv-lite");
var convertNewline = require("convert-newline");
var buffer = iconv.encode(new Buffer("あ\rい\r\nう\n"), "shift_jis");
var converter = convertNewline("lf", "shift_jis").buffer();
var newBuffer = converter(buffer);
iconv.decode(newBuffer, "shift_jis"); // -> "あ\nい\nう\n"
var fs = require("fs");
var convertNewline = require("convert-newline");
var reader = fs.createReadStream("foo.txt", { encoding: "utf8" });
var writer = fs.createWriteStream("bar.txt");
var converter = convertNewline("lf").stream();
reader
.pipe(converter)
.pipe(writer);
To convert non-utf8 encoded streams, you can use iconv-lite.
var fs = require("fs");
var iconv = require("iconv-lite");
var convertNewline = require("convert-newline");
var reader = fs.createReadStream("foo.txt");
var writer = fs.createWriteStream("bar.txt");
var converter = convertNewline("lf").stream();
reader
.pipe(iconv.decodeStream("shift_jis"))
.pipe(converter)
.pipe(iconv.encodeStream("shift_jis"))
.pipe(writer);
Target newline characters. Either "lf"
, "crlf"
, or "cr"
.
Optional. The encoding of the buffer.
Supported encodings are listed on the iconv-lite wiki.
FAQs
Unify newline characters to either \n, \r\n, or \r.
The npm package convert-newline receives a total of 3,578 weekly downloads. As such, convert-newline popularity was classified as popular.
We found that convert-newline demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket researchers found several malicious npm packages typosquatting Chalk and Chokidar, targeting Node.js developers with kill switches and data theft.
Security News
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
Product
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.