Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

crlf

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

crlf - npm Package Compare versions

Comparing version 1.1.0 to 1.1.1

file.txt

14

lib/index.js

@@ -15,5 +15,8 @@ var fs = require('fs');

var ran = false;
var tentativePreviousString;
var tentativeEndingType;
reader.on('data', function(buffer) {
if (!ran) {
var matched = buffer.toString().match(/\r\n|\r|\n/);
var str = (tentativePreviousString || '') + buffer.toString();
var matched = str.match(/\r\n|\r|\n/);
var returned = {

@@ -24,2 +27,9 @@ '\r': 'CR',

}[matched];
if (matched && returned === 'CR') { // handle case where current buffer ends between CR and LF of CRLF
if (!str.match(/\r./)) { // make sure CR is followed by something other than end of string
tentativePreviousString = str;
tentativeEndingType = 'CR';
return;
}
}
if (matched) {

@@ -35,3 +45,3 @@ ran = true;

ran = true;
callback(null, 'NA');
callback(null, tentativeEndingType || 'NA');
}

@@ -38,0 +48,0 @@ });

3

package.json
{
"name": "crlf",
"version": "1.1.0",
"version": "1.1.1",
"description": "detect and change newline endings",

@@ -16,2 +16,3 @@ "main": "index.js",

"license": "MIT",
"repository": "kolodny/crlf",
"devDependencies": {

@@ -18,0 +19,0 @@ "coveralls": "^2.11.2",

@@ -13,4 +13,4 @@ crlf

The cli is probably the one your looking for, first `npm install -g crlf`
usage is something like this:
The cli is probably the one you're looking for, first `npm install -g crlf`.
Usage is something like this:

@@ -17,0 +17,0 @@ ```bash

@@ -16,2 +16,8 @@ var crlf = require('..');

afterEach(cleanup);
var longLine = "";
var bufferLength = 1024 * 64; // fs.createReadStream buffer length
while (longLine.length < bufferLength) {
longLine += "LongLine";
}
longLine = longLine.substr(0, bufferLength - 1);

@@ -50,2 +56,19 @@ describe('get()', function() {

});
it('can handle files where buffer ends between \\r and \\n of \\r\\n', function(done) {
var betweenLines = [longLine, longLine.substr(0, -1)].concat(lines); // this will cause two buffers ending between CR and LF in a row
fs.writeFileSync(fileLocation, betweenLines.join('\r\n'));
crlf.get(fileLocation, null, function(err, ending) {
assert.equal(ending, 'CRLF');
done();
});
});
it('can handle files where buffer ends between \\r and EOF', function(done) {
fs.writeFileSync(fileLocation, [longLine, ''].join('\r'));
crlf.get(fileLocation, null, function(err, ending) {
assert.equal(ending, 'CR');
done();
});
});
});

@@ -52,0 +75,0 @@

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc