UNPKG

647 BJavaScriptView Raw
1/**
2 * Assign properties from `props` to `obj`
3 * @template O, P The obj and props types
4 * @param {O} obj The object to copy properties to
5 * @param {P} props The object to copy properties from
6 * @returns {O & P}
7 */
8export function assign(obj, props) {
9 for (let i in props) obj[i] = props[i];
10 return /** @type {O & P} */ (obj);
11}
12
13/**
14 * Check if two objects have a different shape
15 * @param {object} a
16 * @param {object} b
17 * @returns {boolean}
18 */
19export function shallowDiffers(a, b) {
20 for (let i in a) if (i !== '__source' && !(i in b)) return true;
21 for (let i in b) if (i !== '__source' && a[i] !== b[i]) return true;
22 return false;
23}