https://github.com/icflorescu/textdiff-patch
Apply lean text diff delta patches created by textdiff-create.
https://github.com/icflorescu/textdiff-patch
diff javascript nodejs text-diff
Last synced: 6 months ago
JSON representation
Apply lean text diff delta patches created by textdiff-create.
- Host: GitHub
- URL: https://github.com/icflorescu/textdiff-patch
- Owner: icflorescu
- License: isc
- Created: 2016-01-19T00:37:45.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2024-04-20T08:00:54.000Z (over 1 year ago)
- Last Synced: 2024-11-01T01:04:56.782Z (about 1 year ago)
- Topics: diff, javascript, nodejs, text-diff
- Language: JavaScript
- Size: 210 KB
- Stars: 17
- Watchers: 3
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# textdiff-patch
[![NPM version][npm-image]][npm-url]
[![License][license-image]][license-url]
[![Downloads][downloads-image]][downloads-url]
[![Sponsor the author][sponsor-image]][sponsor-url]

This is a simple module for applying **lean text diff delta patches** created by [textdiff-create](https://github.com/icflorescu/textdiff-create).
## β€οΈπΊπ¦
See [below](#stand-with-ukraine).
## Usage
Assuming you've correctly installed the `npm` module with `npm i textdiff-patch [--save|--save-dev]`:
const applyPatch = require('textdiff-patch');
const v1 = 'The sleepy brown fox';
const delta = [
[0, 4],
[-1, 6],
[1, 'quick'],
[0, 10],
[1, ' jumps over the lazy dog']
];
const v2 = applyPatch(v1, delta);
console.log(v2);
The script will produce the following output:
The quick brown fox jumps over the lazy dog
## Additional info
Have a look at [textdiff-create](https://github.com/icflorescu/textdiff-create) for more info.
## Credits & support
If you find this piece of software useful, please star the repo, [spread the word](http://twitter.com/share?text=Apply%20lean%20text%20diff%20patches%20in%20JavaScript&url=https%3A%2F%2Fgithub.com%2Ficflorescu%2Ftextdiff-patch&hashtags=javascript%2Cnodejs%2Cnpm&via=icflorescu), [sponsor my work](https://github.com/sponsors/icflorescu) and feel free to endorse me on LinkedIn:
[](https://www.linkedin.com/in/icflorescu)
## Stand with Ukraine
On 24th of February 2022 [Russia unlawfully invaded Ukraine](https://en.wikipedia.org/wiki/Russo-Ukrainian_War). This is an unjustified, unprovoked attack on the sovereignty of a neighboring country, but also an open affront to international peace and stability that has the potential to degenerate into a nuclear event threatening the very existence of humanity. I am a Romanian (EU) citizen, but I stand with Ukraine and I am doing everything in my power to stop this madness. Here's [how you can show your support](https://www.stopputin.net/).
## LICENSE
Released under [ISC](https://github.com/icflorescu/textdiff-patch/blob/master/LICENSE).
[npm-image]: https://img.shields.io/npm/v/textdiff-patch.svg?style=flat-square
[npm-url]: https://npmjs.org/package/textdiff-patch
[license-image]: http://img.shields.io/npm/l/textdiff-patch.svg?style=flat-square
[license-url]: LICENSE
[downloads-image]: http://img.shields.io/npm/dm/textdiff-patch.svg?style=flat-square
[downloads-url]: https://npmjs.org/package/textdiff-patch
[sponsor-image]: https://img.shields.io/badge/sponsor-violet?style=flat-square
[sponsor-url]: https://github.com/sponsors/icflorescu