/** * Sigma.js Utils * =============== * * Various helper functions & classes used throughout the library. */ /** * Checks whether the given value is a plain object. * * @param {mixed} value - Target value. * @return {boolean} */ export function isPlainObject(value: any): boolean { return typeof value === "object" && value !== null && value.constructor === Object; } /** * Very simple recursive Object.assign-like function. * * @param {object} target - First object. * @param {object} [...objects] - Objects to merge. * @return {object} */ export function assign(target: object, ...objects): object { target = target || {}; for (let i = 0, l = objects.length; i < l; i++) { const o = objects[i]; if (!o) continue; for (const k in o) { if (isPlainObject(o[k])) { target[k] = assign(target[k], o[k]); } else { target[k] = o[k]; } } } return target; }