shallow-differs
v1.0.0
Published
compare two objects in a shallow way to check if they differ with support white list of properties
Downloads
2
Readme
shallow-differs (with whitelist)
This module is quite standard implementation of shallow compare of two objects. It iterates through object properties comparing them in a shallow way and returns a boolean, whether this two object are different (true) or they're the same in a shallow way (false).
One extra improvement over most basic implementation is support for a whitelist of keys, which are to be ignored during comparison. It might be useful in scenarios that we're sure that given key is not really important (think of e.g. shouldComponentUpdate and one key of props, which doesn't influence rendering but still might change and trigger unnecessary re-render).
Installation
npm install --save shallow-differs
Usage
import { shallowDiffers } from "shallow-differs";
shallowDiffers(a, b, ["keys", "to", "ignore"]);
- arguments
a
andb
are two object, which keys we want to compare- whitelist is an array of keys, which will be ignored during comparison