
Security News
Crates.io Implements Trusted Publishing Support
Crates.io adds Trusted Publishing support, enabling secure GitHub Actions-based crate releases without long-lived API tokens.
what-the-diff
Advanced tools
Credit: @eightballart
Parse unified diffs with JavaScript
what-the-diff is available via npm
npm install what-the-diff
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'
]
}
]
}
If the diff includes a similarity index line (from a detected copy or rename), the similarity
property will be set, and will be a number.
FAQs
diff parsing library
We found that what-the-diff demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers 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.
Security News
Crates.io adds Trusted Publishing support, enabling secure GitHub Actions-based crate releases without long-lived API tokens.
Research
/Security News
Undocumented protestware found in 28 npm packages disrupts UI for Russian-language users visiting Russian and Belarusian domains.
Research
/Security News
North Korean threat actors deploy 67 malicious npm packages using the newly discovered XORIndex malware loader.