File tree Expand file tree Collapse file tree 9 files changed +197
-1
lines changed
Expand file tree Collapse file tree 9 files changed +197
-1
lines changed Original file line number Diff line number Diff line change @@ -36,6 +36,7 @@ bower_components
3636
3737# Compiled binary addons (https://nodejs.org/api/addons.html)
3838build /Release
39+ build /Debug
3940
4041# Dependency directories
4142node_modules /
102103
103104# TernJS port file
104105.tern-port
106+ .idea
Original file line number Diff line number Diff line change 1+ .idea
2+ build
Original file line number Diff line number Diff line change 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.
Original file line number Diff line number Diff line change 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/file_for_patch.c" ,
10+ "HDiffPatch/libHDiffPatch/HDiff/diff.cpp" ,
11+ "HDiffPatch/libHDiffPatch/HDiff/private_diff/bytes_rle.cpp" ,
12+ "HDiffPatch/libHDiffPatch/HDiff/private_diff/suffix_string.cpp" ,
13+ "HDiffPatch/libHDiffPatch/HDiff/private_diff/compress_detect.cpp" ,
14+ "HDiffPatch/libHDiffPatch/HDiff/private_diff/limit_mem_diff/digest_matcher.cpp" ,
15+ "HDiffPatch/libHDiffPatch/HDiff/private_diff/limit_mem_diff/stream_serialize.cpp" ,
16+ "HDiffPatch/libHDiffPatch/HDiff/private_diff/libdivsufsort/divsufsort64.cpp" ,
17+ "HDiffPatch/libHDiffPatch/HDiff/private_diff/libdivsufsort/divsufsort.cpp" ,
18+ "HDiffPatch/libHDiffPatch/HDiff/private_diff/limit_mem_diff/adler_roll.cpp" ,
19+ "lzma/C/LzFind.c" ,
20+ "lzma/C/LzmaDec.c" ,
21+ "lzma/C/LzmaEnc.c" ,
22+ "lzma/C/Lzma2Dec.c" ,
23+ "lzma/C/Lzma2Enc.c"
24+ ],
25+ "defines" : [
26+ "_IS_NEED_DIR_DIFF_PATCH=0" ,
27+ "_7ZIP_ST" ,
28+ "_IS_USED_MULTITHREAD=0"
29+ ],
30+ "include_dirs" : [
31+ "<!(node -e \" require('nan')\" )"
32+ ]
33+ }
34+ ]
35+ }
Original file line number Diff line number Diff line change 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+ }
Original file line number Diff line number Diff line change 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+ }
Original file line number Diff line number Diff line change 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+ }
Original file line number Diff line number Diff line change 1+ var hdiffpatch = require ( "../index" ) ;
2+ var test_hdiffpatch = require ( "../index_test" ) ;
3+ var crypto = require ( "crypto" ) ;
4+ var md5 = require ( "md5" ) ;
5+ var assert = require ( "assert" ) . strict ;
6+
7+ var cur = crypto . randomBytes ( 40960 ) ;
8+
9+ var ref = Buffer . concat ( [
10+ Buffer . from ( "fdsa" ) ,
11+ cur . slice ( 0 , 4096 ) ,
12+ Buffer . from ( "asdf" ) ,
13+ cur . slice ( 4096 ) ,
14+ Buffer . from ( "asdf" )
15+ ] ) ;
16+
17+ assert . deepStrictEqual (
18+ md5 ( hdiffpatch . diff ( cur , ref ) ) ,
19+ md5 ( test_hdiffpatch . diff ( cur , ref ) )
20+ ) ;
21+ console . log ( "pass" ) ;
Original file line number Diff line number Diff line change 1+ # THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
2+ # yarn lockfile v1
3+
4+
5+ amdefine@~1.0.0 :
6+ version "1.0.1"
7+ resolved "https://registry.yarnpkg.com/amdefine/-/amdefine-1.0.1.tgz#4a5282ac164729e93619bcfd3ad151f817ce91f5"
8+ integrity sha1-SlKCrBZHKek2Gbz9OtFR+BfOkfU=
9+
10+ charenc@~0.0.1 :
11+ version "0.0.2"
12+ resolved "https://registry.yarnpkg.com/charenc/-/charenc-0.0.2.tgz#c0a1d2f3a7092e03774bfa83f14c0fc5790a8667"
13+ integrity sha1-wKHS86cJLgN3S/qD8UwPxXkKhmc=
14+
15+ commander@~2.8.1 :
16+ version "2.8.1"
17+ resolved "https://registry.yarnpkg.com/commander/-/commander-2.8.1.tgz#06be367febfda0c330aa1e2a072d3dc9762425d4"
18+ integrity sha1-Br42f+v9oMMwqh4qBy09yXYkJdQ=
19+ dependencies :
20+ graceful-readlink ">= 1.0.0"
21+
22+ crypt@~0.0.1 :
23+ version "0.0.2"
24+ resolved "https://registry.yarnpkg.com/crypt/-/crypt-0.0.2.tgz#88d7ff7ec0dfb86f713dc87bbb42d044d3e6c41b"
25+ integrity sha1-iNf/fsDfuG9xPch7u0LQRNPmxBs=
26+
27+ " graceful-readlink@>= 1.0.0 " :
28+ version "1.0.1"
29+ resolved "https://registry.yarnpkg.com/graceful-readlink/-/graceful-readlink-1.0.1.tgz#4cafad76bc62f02fa039b2f94e9a3dd3a391a725"
30+ integrity sha1-TK+tdrxi8C+gObL5Tpo906ORpyU=
31+
32+ is-buffer@~1.1.1 :
33+ version "1.1.6"
34+ resolved "https://registry.yarnpkg.com/is-buffer/-/is-buffer-1.1.6.tgz#efaa2ea9daa0d7ab2ea13a97b2b8ad51fefbe8be"
35+ integrity sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==
36+
37+ md5@^2.2.1 :
38+ version "2.2.1"
39+ resolved "https://registry.yarnpkg.com/md5/-/md5-2.2.1.tgz#53ab38d5fe3c8891ba465329ea23fac0540126f9"
40+ integrity sha1-U6s41f48iJG6RlMp6iP6wFQBJvk=
41+ dependencies :
42+ charenc "~0.0.1"
43+ crypt "~0.0.1"
44+ is-buffer "~1.1.1"
45+
46+ nan@^2.14.0 :
47+ version "2.14.0"
48+ resolved "https://registry.yarnpkg.com/nan/-/nan-2.14.0.tgz#7818f722027b2459a86f0295d434d1fc2336c52c"
49+ integrity sha512-INOFj37C7k3AfaNTtX8RhsTw7qRy7eLET14cROi9+5HAVbbHuIWUHEauBv5qT4Av2tWasiTY1Jw6puUNqRJXQg==
You can’t perform that action at this time.
0 commit comments