Giter Club home page Giter Club logo

node-delta's Introduction

node-delta Build Status Build status

An efficient delta compression algorithm for Node.js, written in C. (see original source code)

Requires NodeJS v4 or higher

Usage

const fossilDelta = require('node-delta');

Creating delta between origin and target buffer:

var origin = new Buffer([1,2,3,4]);
var target = new Buffer([1,2,3,4,5,6]);
var delta = fossilDelta.create(origin, target);

Applying the delta:

var origin = new Buffer([1,2,3,4]);
var target = fossilDelta.apply(origin, delta);

Benchmarks

For creating the patch, node-delta has the best results. (roughly ~2x speed)

(create) node-delta x 313,371 ops/sec ±1.76% (77 runs sampled)
(create) fossil-delta x 238,424 ops/sec ±3.58% (75 runs sampled)

For applying the patch, fossil-delta-js still have the best results.

(apply) node-delta x 664,472 ops/sec ±5.44% (69 runs sampled)
(apply) fossil-delta x 860,541 ops/sec ±1.57% (84 runs sampled)

References

License

MIT

node-delta's People

Contributors

endel avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

node-delta's Issues

Crashes Electron

I'm using node-delta on an electron app I am build, but it seem to crash every time I invoke the 'apply' method. Doesn't matter the file size, it simply crashes the app.
I have tested on a clean node app, and works fine. I'm Having crashes issues only with electron.

Sometimes it do what it have to do, finish everything (I mean, the final file is generated just fine), but after 5 seconds the app goes down. If it doesn't happen, it will surely crash if you open the console.
I don't know if it can make difference, but I had to rebuild node-delta using "electron-rebuild" to make it work.
So, any suggestion with what may cause this issue?

Cannot install it (node 12.16.1, npm 6.13.4)

npm install node-delta

[email protected] install /home/olga/Desktop/kolmofs/delta_analysis/node_modules/node-delta
node-gyp rebuild

make: Entering directory '/home/olga/Desktop/kolmofs/delta_analysis/node_modules/node-delta/build'
CXX(target) Release/obj.target/delta/src/delta.o
../src/delta.cc: In function ‘int delta_create(const char*, unsigned int, const char*, unsigned int, char*)’:
../src/delta.cc:436:29: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(k=1; k<iSrc && k<=i; k++){
~^~~
../src/delta.cc:450:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if( cnt>=sz && cnt>bestCnt ){
~~~^~~~~~~~
../src/delta.cc:482:35: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if( bestOfst + bestCnt -1 > lastRead ){
~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~
../src/delta.cc: In function ‘int delta_apply(const char*, int, const char*, int, char*)’:
../src/delta.cc:600:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if( ofst+cnt > lenSrc ){
~~~~~~~~~^~~~~~~~
../src/delta.cc:616:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if( cnt>lenDelta ){
~~~^~~~~~~~~
../src/delta.cc: In function ‘int delta_analyze(const char*, int, int*, int*)’:
../src/delta.cc:689:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if( cnt>lenDelta ){
~~~^~~~~~~~~
../src/delta.cc: In function ‘void Init(v8::Localv8::Object)’:
../src/delta.cc:742:55: error: no matching function for call to ‘v8::FunctionTemplate::GetFunction()’
Nan::New(Create)->GetFunction());
^
In file included from /home/olga/.cache/node-gyp/12.16.1/include/node/node.h:63:0,
from ../../nan/nan.h:54,
from ../src/delta.cc:713:
/home/olga/.cache/node-gyp/12.16.1/include/node/v8.h:6126:46: note: candidate: v8::MaybeLocalv8::Function v8::FunctionTemplate::GetFunction(v8::Localv8::Context)
V8_WARN_UNUSED_RESULT MaybeLocal GetFunction(
^~~~~~~~~~~
/home/olga/.cache/node-gyp/12.16.1/include/node/v8.h:6126:46: note: candidate expects 1 argument, 0 provided
../src/delta.cc:745:54: error: no matching function for call to ‘v8::FunctionTemplate::GetFunction()’
Nan::New(Apply)->GetFunction());
^
In file included from /home/olga/.cache/node-gyp/12.16.1/include/node/node.h:63:0,
from ../../nan/nan.h:54,
from ../src/delta.cc:713:
/home/olga/.cache/node-gyp/12.16.1/include/node/v8.h:6126:46: note: candidate: v8::MaybeLocalv8::Function v8::FunctionTemplate::GetFunction(v8::Localv8::Context)
V8_WARN_UNUSED_RESULT MaybeLocal GetFunction(
^~~~~~~~~~~
/home/olga/.cache/node-gyp/12.16.1/include/node/v8.h:6126:46: note: candidate expects 1 argument, 0 provided
../src/delta.cc: In function ‘unsigned int checksum(const char*, size_t)’:
../src/delta.cc:270:19: warning: this statement may fall through [-Wimplicit-fallthrough=]
case 3: sum += (z[2] << 8);
~~~~^~~~~~~~~~~~~~
../src/delta.cc:271:5: note: here
case 2: sum += (z[1] << 16);
^~~~
../src/delta.cc:271:19: warning: this statement may fall through [-Wimplicit-fallthrough=]
case 2: sum += (z[1] << 16);
~~~~^~~~~~~~~~~~~~~
../src/delta.cc:272:5: note: here
case 1: sum += (z[0] << 24);
^~~~
delta.target.mk:111: recipe for target 'Release/obj.target/delta/src/delta.o' failed
make: *** [Release/obj.target/delta/src/delta.o] Error 1
make: Leaving directory '/home/olga/Desktop/kolmofs/delta_analysis/node_modules/node-delta/build'
gyp ERR! build error
gyp ERR! stack Error: make failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:194:23)
gyp ERR! stack at ChildProcess.emit (events.js:311:20)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:275:12)
gyp ERR! System Linux 5.3.0-45-generic
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /home/olga/Desktop/kolmofs/delta_analysis/node_modules/node-delta
gyp ERR! node -v v12.16.1
gyp ERR! node-gyp -v v5.0.5
gyp ERR! not ok
npm WARN [email protected] No description
npm WARN [email protected] No repository field.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] install: node-gyp rebuild
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR! /home/olga/.npm/_logs/2020-04-01T17_02_47_640Z-debug.log

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.