UNPKG

ascii-ui

Version:

Graphic terminal emulator for HTML canvas elements

26 lines 843 B
import { isPlainObject } from 'vanilla-type-check/isPlainObject'; export function deepAssignAndDiff(...args) { const target = args[0]; const diff = {}; for (let i = 1; i < args.length; i++) { const obj = args[i]; Object.keys(obj).forEach((key) => { const val = obj[key]; if (isPlainObject(val)) { if (!target[key]) { target[key] = Object.assign({}, val); diff[key] = target[key]; } else { diff[key] = deepAssignAndDiff(target[key], val); } } else if (target[key] !== val) { diff[key] = val; target[key] = obj[key]; } }); } return diff; } //# sourceMappingURL=deepAssignAndDiff.js.map