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

parse-diff

Package Overview
Dependencies
Maintainers
1
Versions
33
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

parse-diff - npm Package Compare versions

Comparing version 0.4.0 to 0.4.1

index.d.ts

37

index.js

@@ -0,1 +1,3 @@

// parses unified diff
// http://www.gnu.org/software/diffutils/manual/diffutils.html#Unified-Format
var defaultToWhiteSpace, escapeRegExp, ltrim, makeString, parseFile, parseFileFallback, trimLeft;

@@ -43,3 +45,3 @@

restart();
file["new"] = true;
file.new = true;
return file.from = '/dev/null';

@@ -73,6 +75,6 @@ };

changes: [],
oldStart: oldStart,
oldLines: oldLines,
newStart: newStart,
newLines: newLines
oldStart,
oldLines,
newStart,
newLines
};

@@ -109,16 +111,14 @@ return file.chunks.push(current);

eof = function(line) {
var obj, recentChange, ref;
var recentChange, ref;
ref = current.changes, recentChange = ref[ref.length - 1];
return current.changes.push((
obj = {
type: recentChange.type
},
obj["" + recentChange.type] = true,
obj.ln1 = recentChange.ln1,
obj.ln2 = recentChange.ln2,
obj.ln = recentChange.ln,
obj.content = line,
obj
));
return current.changes.push({
type: recentChange.type,
[`${recentChange.type}`]: true,
ln1: recentChange.ln1,
ln2: recentChange.ln2,
ln: recentChange.ln,
content: line
});
};
// todo beter regexp to avoid detect normal line starting with diff
schema = [[/^\s+/, normal], [/^diff\s/, start], [/^new file mode \d+$/, new_file], [/^deleted file mode \d+$/, deleted_file], [/^index\s[\da-zA-Z]+\.\.[\da-zA-Z]+(\s(\d+))?$/, index], [/^---\s/, from_file], [/^\+\+\+\s/, to_file], [/^@@\s+\-(\d+),?(\d+)?\s+\+(\d+),?(\d+)?\s@@/, chunk], [/^-/, del], [/^\+/, add], [/^\\ No newline at end of file$/, eof]];

@@ -156,2 +156,3 @@ parse = function(line) {

// fallback function to overwrite file.from and file.to if executed
parseFileFallback = function(s) {

@@ -162,2 +163,3 @@ var t;

s = s.trim();
// ignore possible time stamp
t = /\t.*|\d{4}-\d\d-\d\d\s\d\d:\d\d:\d\d(.\d+)?\s(\+|-)\d\d\d\d/.exec(s);

@@ -167,2 +169,3 @@ if (t) {

}
// ignore git prefixes a/ or b/
if (s.match(/^(a|b)\//)) {

@@ -169,0 +172,0 @@ return s.substr(2);

{
"name": "parse-diff",
"version": "0.4.0",
"version": "0.4.1",
"description": "Unified diff parser",
"author": "Sergey Todyshev <stodyshev@gmail.com>",
"main": "index.js",
"types": "index.d.ts",
"license": "MIT",

@@ -22,2 +23,3 @@ "repository": {

"DAB0mB <emanor6@gmail.com>",
"Lorens Leon <lorensleon@gmail.com>",
"Quest <quest@lysator.liu.se>",

@@ -28,12 +30,12 @@ "Sung Won Cho <mikeswcho@gmail.com>",

"devDependencies": {
"coffee-script": "^1.11.1",
"coffeelint": "^1.16.0",
"coffeelint": "^2.0.7",
"coffeescript": "^2.1.1",
"expect.js": "^0.3.1",
"grunt": "^1.0.1",
"grunt-auto-release": "^0.0.6",
"grunt-auto-release": "^0.0.7",
"grunt-bump": "^0.8.0",
"grunt-cli": "^1.2.0",
"grunt-coffeelint": "^0.0.16",
"grunt-contrib-coffee": "^1.0.0",
"grunt-contrib-jshint": "^1.0.0",
"grunt-contrib-coffee": "^2.0.0",
"grunt-contrib-jshint": "^1.1.0",
"grunt-npm": "^0.0.2",

@@ -40,0 +42,0 @@ "grunt-simple-mocha": "^0.4.1"

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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