Skip to content

Commit

Permalink
updated build
Browse files Browse the repository at this point in the history
  • Loading branch information
nielsgl committed May 18, 2016
1 parent 86cb94a commit a992aad
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 7 deletions.
20 changes: 14 additions & 6 deletions lib/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ exports.default = {
test: function test() {
return true;
},
calcDelta: function calcDelta(current, next, exclude) {
calcDelta: function calcDelta(current, next, exclude, strict) {
var DEBUG = false;
if (DEBUG) {
console.log('current', current);
Expand Down Expand Up @@ -48,11 +48,19 @@ exports.default = {
var diffs = di ? di.map(function (i) {
var str = JSON.stringify(i).replace("\"__data\",", "");
return JSON.parse(str);
})
// .filter(function(i: any){
// return i.path.join(",").indexOf("_") === -1;
// })
.filter(function (i) {
}).filter(function (i) {
// return i.path.join(",").indexOf("_") === -1;
// console.log('i', i)
if (!strict && i.kind === 'E') {
// console.log('str & num', i.lhs == i.rhs)
// console.log('str & num (strict)', i.lhs === i.rhs)
if (i.lhs != i.rhs) {
return i;
}
} else {
return i;
}
}).filter(function (i) {
// console.log('i', i);
return exclude.every(function (x) {
return i.path.indexOf(x) === -1;
Expand Down
10 changes: 9 additions & 1 deletion lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,14 @@ exports.default = function (sequelize, options) {
options.enableMigration = false;
}

// enable strict diff
// when true: 10 !== '10'
// when false: 10 == '10'
// default: true
if (!options.enableStrictDiff) {
options.enableStrictDiff = true;
}

if (debug) {
log('parsed options:');
log(options);
Expand Down Expand Up @@ -208,7 +216,7 @@ exports.default = function (sequelize, options) {
instance.set(options.revisionAttribute, instance._previousDataValues[options.revisionAttribute]);

// Get diffs
var delta = helpers.calcDelta(previousVersion, currentVersion, options.exclude);
var delta = helpers.calcDelta(previousVersion, currentVersion, options.exclude, options.enableStrictDiff);

if (debug) {
log('delta:');
Expand Down

0 comments on commit a992aad

Please sign in to comment.