@polkadot/react-api
Version:
A collection of RxJs React components the Polkadot JS API
40 lines (32 loc) • 779 B
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = isEqual;
// Copyright 2017-2020 @polkadot/react-api authors & contributors
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
function flatten(key, value) {
if (!value) {
return value;
}
if (value.$$typeof) {
return '';
}
if (Array.isArray(value)) {
return value.map(item => flatten(null, item));
}
return value;
}
function isEqual(a, b, debug = false) {
const jsonA = JSON.stringify({
test: a
}, flatten);
const jsonB = JSON.stringify({
test: b
}, flatten);
if (debug) {
console.log('jsonA', jsonA, 'jsonB', jsonB);
}
return jsonA === jsonB;
}