https://github.com/kryo2k/js-buffer-diff
Typescript utility functions to create, commit and revert a diff of two buffer objects.
https://github.com/kryo2k/js-buffer-diff
buffers diff javascript libraries revert typescript
Last synced: about 1 month ago
JSON representation
Typescript utility functions to create, commit and revert a diff of two buffer objects.
- Host: GitHub
- URL: https://github.com/kryo2k/js-buffer-diff
- Owner: kryo2k
- Created: 2018-04-21T16:33:17.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2018-04-24T23:04:18.000Z (about 8 years ago)
- Last Synced: 2024-08-10T11:26:51.731Z (almost 2 years ago)
- Topics: buffers, diff, javascript, libraries, revert, typescript
- Language: TypeScript
- Size: 14.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# js-buffer-diff
Typescript utility functions to create, commit and revert a diff of two buffer objects.
While I add more docs here, take a look at the unit test cases in src/*.spec.ts.
This module is still in development, so please don't use in a production environment yet.
#### Example Usage:
```typescript
import { diff, commit, revert } from 'js-buffer-diff';
const
bufferA = new Buffer([83,29,19,49,59,20,1,49,95,30,99,33,19,92,5,11,129,95,28,94,205]),
bufferB = new Buffer([83,29,21,4,72,9,20,1,49,95,36,99,33,19,92,25,5,11,95,28,94,225]);
const changes = diff(bufferA, bufferB);
console.log('changes:', changes);
const committed = commit(bufferA, ... changes); // committed should eq bufferB
console.log('committed:', committed, committed.equals(bufferB));
const reverted = revert(committed, ... changes); // reverted should eq bufferA
console.log('reverted:', reverted, reverted.equals(bufferA));
```