export function deepAssign(to, ...rest) { let updated = false; for (let src of rest) { for (let prop in src) { const value = src[prop]; const oldValue = to[prop]; if (typeof value === 'object' && !Array.isArray(value)) { if (typeof oldValue !== 'object') { to[prop] = {}; updated = true; } updated = deepAssign(to[prop], value) || updated; } else if (value === undefined && to[prop] !== undefined) { delete to[prop]; } else if (value !== oldValue) { updated = true; to[prop] = value; } } } return updated; } export const pouchDocHash = d => (isObject(d) ? `${d._id}:${d._rev}` : d); export const pouchDocArrayHash = arr => Array.isArray(arr) ? arr.map(pouchDocHash).join('?') : arr; export function isObject(obj) { return typeof obj === 'object' && !Array.isArray(obj) && obj !== null; }