Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/anywhichway/little-diff
I tiny string and array diff and apply diff library
https://github.com/anywhichway/little-diff
Last synced: about 4 hours ago
JSON representation
I tiny string and array diff and apply diff library
- Host: GitHub
- URL: https://github.com/anywhichway/little-diff
- Owner: anywhichway
- License: mit
- Created: 2022-12-31T14:49:11.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2023-01-12T16:37:49.000Z (almost 2 years ago)
- Last Synced: 2024-11-09T14:23:37.477Z (6 days ago)
- Language: JavaScript
- Size: 12.7 KB
- Stars: 5
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# little-diff
A tiny module to get a big difference.
Lightning fast string and array get and apply diff library. The module file is less than 350 bytes compressed and gzipped.
# Install
```
npm install little-diff
```# Usage
A browser build is available in the `dist` directory. Otherwise, use the `./index.js` module file which exports `getDelta`, `applyDelta`, and `LittleDiff` (which just has `getDelta`, `applyDelta` as methods).
## getDelta(source:string | Array, target:string | Array)
Returns an array of arrays of the form `[start:number, end:number, items:Array|undefined]`. These are effectively splice operations that when applied in sequence will transfrom the `source` into the `target`. This is what makes the library small and fast. It is very close to native JavaScript.
## applyDelta(source: string | Array, delta: Array)
Applies the delta to return a target. The return type will be the same as the `source` type.
See the file `./exmaple.js`.
# Release History (Reverse Chronological Order)
2023-01-12 v1.0.4 Remove .parcel-cache which was accidentally commited.
2023-01-09 v1.0.3 Added "main": "index.js" to package.json since some dependency processing requires export or main.
2023-01-07 v1.0.2 Updated docs
2023-01-05 v1.0.1 Updated docs
2023-01-04 v1.0.0 Added unit tests. Updated docs.
2022-12-31 v0.0.1 Initial public release