discrepances
v0.2.8
Published
show discrepances in several flavors
Downloads
42
Keywords
Readme
discrepances
Shows differences between different values
Use
var discrepances = require('discrepances');
var a={x:1, y:2, z:[3], d:4, e:[{j:3, k:4, m:['a', 'b']}]};
var b={x:1, y:2, z:[3], d:44, e:[{j:3, k:4, m:['a'] }]};
var detectedDiscrepances = discrepances.nestedObject(a,b)
if(detectedDiscrepances){
console.dir(detectedDiscrepances, {depth:9});
}
/*
{
object:{
d:{ difference: -40, values: [ 4, 44 ] },
e:{
array:{
'0':{
object:{
m:{
array:{ length:{ difference: 1, values: [ 2, 1 ] } }
}
}
}
}
}
}
}
*/
var detectedDiscrepances = discrepances.flatten(a,b)
if(detectedDiscrepances){
console.log(detectedDiscrepances);
}
/*
{
'.d': { difference: -40, values: [ 4, 44 ] },
'.e[0].m[length]': { difference: 1, values: [ 2, 1 ] }
}
*/
API
discrepances.nestedObject(a,b[, opts])
(see spanish)
discrepances.flatten(a,b[, opts])
(see spanish)
discrepances.showAndThrow(a, b[, opts])
(see spanish)
var discrepances = require('discrepances');
var a={x:1, y:2, z:[3], d:4, e:[{j:3, k:4, m:['a', 'b']}]};
var b={x:1, y:2, z:[3], d:44, e:[{j:3, k:4, m:['a'] }]};
it("compares a with b", function(){
discrepances.showAndThrow(a,b,{context:'this message'})
});
Install
$ npm install discrepances