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

what-the-diff

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

what-the-diff

diff parsing library

  • 0.2.0
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

JavaScript Diff Parser

Credit: @eightballart

Parse unified diffs with JavaScript

Installation

what-the-diff is available via npm

npm install what-the-diff

Usage

let parse = require('what-the-diff')

var str = `diff --git file.txt file.txt
index 83db48f..bf269f4 100644
--- file.txt
+++ file.txt
@@ -1,3 +1,3 @@
line1
-line2
+new line
line3`

parse(diffStr)

// returns
  {
    oldPath: 'file.txt',
    newPath: 'file.txt',
    oldMode: '100644',
    newMode: '100644',
    status: 'modified',
    hunks: [
      {
        oldStartLine: 1,
        oldLineCount: 3,
        newStartLine: 1,
        newLineCount: 3,
        lines: [
          ' line1',
          '-line2',
          '+new line',
          ' line3'
        ]
      }
    ]
  }

Keywords

FAQs

Package last updated on 04 Nov 2016

Did you know?

Socket

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.

Install

Related posts

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