similar-to
v0.0.1
Published
A deepEqual a like that doesn't checks values. It's all about similarity :)
Downloads
5
Readme
Similar To
Verifies if two objects are similar.
Full Similarity
Two objects are meant to be fully similar if ALL of its fields are present in the other object. As similarity is different from equality, this module won't check for the values of the fields (this differs from deepEqual
).
var fullySimilar = require('similar-to');
var a = {a: {b: "c"}, b: "c"};
var b = {a: {b: "d"}, b: "e"};
fullySimilar(a,b);
// true
Partial Similarity
Partial similarity is meant to be the same case as the one stated above but for only a part of the second object being passed through.
var partiallySimilar = require('similar-to');
var a = {a: {b: "c"}, b: "c"};
var b = {a: {b: "d"}};
// the last argument specifies that the check will be for partial similarity
partiallySimilar(b, a, true);
// true