browserify-json-bundle-diff
v0.0.2
Published
Generates a diff between two [browserify-json-bundles](https://github.com/Magnetme/browserify-json-bundler). This is part of the browserify-diff toolchain.
Downloads
3
Readme
Generates a diff between two browserify-json-bundles. This is part of the browserify-diff toolchain.
Example
From:
{
"version" : 1,
"modules" : {
"./foo" : ["console.log('foo');",{}],
"./bar" : ["console.log('bar');",{}]
},
"entry" : ["./foo"]
}
To:
{
"version" : 2,
"modules" : {
"./foo" : ["console.log('now I print something else');",{}],
"./baz" : ["console.log('baz');",{}]
},
"entry" : ["./baz"]
}
Resulting diff:
{
"from" : 1,
"to" : 2,
"modules" : {
"./foo" : ["console.log('now I print something else');",{}],
"./bar" : null,
"./baz" : ["console.log('baz');",{}]
},
"entry" : ["./baz"]
}
Methods
var diff = require('browserify-json-bundle-diff');
create(from, to)
Generates a diff between two browserify-json-bundles. It will:
- Put the version of
from
as the value for thefrom
key in the diff - Put the version of
to
as the value for theto
key in the diff - Add any module in
to
that is not present infrom
to themodules
hash - Add any module in
to
that is not equal to the same module infrom
to themodules
hash - Add any module that is present in
from
but not into
to themodules
hash with a value ofnull
- Adds the
entry
fromto
if it is not equal to theentry
fromfrom
.
merge(first, second)
Merges two diffs together. It is required that the second diff is a direct successor of the first diff, that is first.to === second.from
.