Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
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 1,768 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 uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.