Skip to content

Commit 0ef0869

Browse files
authored
Merge pull request #1 from reactnativecn/dev
node-hdiffpatch ok
2 parents eb75c35 + eedead3 commit 0ef0869

File tree

15 files changed

+340
-1
lines changed

15 files changed

+340
-1
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ bower_components
3636

3737
# Compiled binary addons (https://nodejs.org/api/addons.html)
3838
build/Release
39+
build/Debug
3940

4041
# Dependency directories
4142
node_modules/
@@ -102,3 +103,5 @@ dist
102103

103104
# TernJS port file
104105
.tern-port
106+
.idea
107+
.vscode/

.gitmodules

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[submodule "HDiffPatch"]
2+
path = HDiffPatch
3+
url = https://github.com/sisong/HDiffPatch.git
4+
[submodule "lzma"]
5+
path = lzma
6+
url = https://github.com/sisong/lzma.git

.npmignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.idea
2+
build

HDiffPatch

Submodule HDiffPatch added at eb959d6

README.md

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,17 @@
1-
# node-hdiffpatch
1+
# node-hdiffpatch
2+
3+
Create patch buffer with origin buffer with [HDiffPatch](https://github.com/sisong/HDiffPatch)
4+
5+
Patch compatible with HDiffPatch -SD
6+
7+
## Installation
8+
9+
```bash
10+
npm install --save node-hdiffpatch
11+
```
12+
13+
## Usage
14+
15+
### diff(originBuf, newBuf)
16+
17+
Compare two buffers and return a new hdiffpatch patch as return value.

binding.gyp

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{
2+
"targets": [
3+
{
4+
"target_name": "hdiffpatch",
5+
"sources": [
6+
"src/main.cc",
7+
"src/hdiff.cpp",
8+
"HDiffPatch/libHDiffPatch/HPatch/patch.c",
9+
"HDiffPatch/libHDiffPatch/HDiff/diff.cpp",
10+
"HDiffPatch/libHDiffPatch/HDiff/private_diff/bytes_rle.cpp",
11+
"HDiffPatch/libHDiffPatch/HDiff/private_diff/suffix_string.cpp",
12+
"HDiffPatch/libHDiffPatch/HDiff/private_diff/compress_detect.cpp",
13+
"HDiffPatch/libHDiffPatch/HDiff/private_diff/libdivsufsort/divsufsort64.cpp",
14+
"HDiffPatch/libHDiffPatch/HDiff/private_diff/libdivsufsort/divsufsort.cpp",
15+
"HDiffPatch/libHDiffPatch/HDiff/private_diff/limit_mem_diff/digest_matcher.cpp",
16+
"HDiffPatch/libHDiffPatch/HDiff/private_diff/limit_mem_diff/stream_serialize.cpp",
17+
"HDiffPatch/libHDiffPatch/HDiff/private_diff/limit_mem_diff/adler_roll.cpp",
18+
"lzma/C/LzFind.c",
19+
"lzma/C/LzmaDec.c",
20+
"lzma/C/LzmaEnc.c",
21+
"lzma/C/Lzma2Dec.c",
22+
"lzma/C/Lzma2Enc.c"
23+
],
24+
"defines": [
25+
"_IS_NEED_DIR_DIFF_PATCH=0",
26+
"_7ZIP_ST",
27+
"_IS_USED_MULTITHREAD=0"
28+
],
29+
"include_dirs" : [
30+
"<!(node -e \"require('nan')\")"
31+
]
32+
}
33+
]
34+
}

index.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/**
2+
* Created by housisong on 2021.04.06.
3+
*/
4+
5+
var native;
6+
try {
7+
native = require('./build/Release/hdiffpatch');
8+
} catch(e) {
9+
console.error(e);
10+
native = require('./build/Debug/hdiffpatch');
11+
}
12+
exports.native = native;
13+
14+
exports.diff = function(oldBuf, newBuf) {
15+
var buffers = [];
16+
native.diff(oldBuf, newBuf, function(output){
17+
buffers.push(output);
18+
});
19+
20+
return Buffer.concat(buffers);
21+
}

index_test.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/**
2+
* Created by housisong on 2021.04.06.
3+
*/
4+
5+
var native;
6+
try {
7+
native = require('./build/Release/hdiffpatch');
8+
} catch(e) {
9+
console.error(e);
10+
native = require('./build/Debug/hdiffpatch');
11+
}
12+
exports.native = native;
13+
14+
exports.diff = function(oldBuf, newBuf) {
15+
var buffers = [];
16+
native.diff(oldBuf, newBuf, function(output){
17+
buffers.push(output);
18+
});
19+
20+
return Buffer.concat(buffers);
21+
}

lzma

Submodule lzma added at c80bb80

package.json

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"name": "node-hdiffpatch",
3+
"version": "0.1.5",
4+
"description": "hdiffpatch port to node.js",
5+
"main": "index.js",
6+
"scripts": {
7+
"test": "node test/test.js"
8+
},
9+
"gypfile": true,
10+
"author": "housisong",
11+
"license": "MIT",
12+
"dependencies": {
13+
"nan": "^2.14.0"
14+
},
15+
"devDependencies": {
16+
"md5": "^2.2.1"
17+
},
18+
"repository": {
19+
"type": "git",
20+
"url": "git+https://github.com/reactnativecn/node-hdiffpatch"
21+
},
22+
"keywords": [
23+
"hdiffpatch"
24+
],
25+
"bugs": {
26+
"url": "https://github.com/reactnativecn/node-hdiffpatch/issues"
27+
},
28+
"homepage": "https://github.com/reactnativecn/node-hdiffpatch#readme"
29+
}

0 commit comments

Comments
 (0)