firestore-snapshot-utils
Version:
**Utils for testing Firestore DB snapshots**
18 lines (17 loc) • 498 B
JavaScript
// NOTE: Currently only works with props that exist in the top level of the
// object
export const maskProps = (a, collection, maskKeys) => {
if (typeof a !== 'object' || Array.isArray(a) || a === null) {
return a;
}
const keys = maskKeys[collection];
if (keys) {
const obj = a;
for (const key of keys) {
if (typeof obj[key] === 'string') {
obj[key] = obj[key].replace(/./g, '•');
}
}
}
return a;
};