UNPKG

favoritos

Version:

Favoritos is a JavaScript plugin that adds some HTML5 canvas magic to your favicon. With just a wee bit of code, we can make some really cool effects.

25 lines (20 loc) 691 B
export const getObjectKeys = Object.keys as <T>(o: T) => Extract<keyof T, string>[]; export const isObject = (item: object): boolean => { return item && typeof item === 'object' && !Array.isArray(item) && true; }; export const mergeDeep = (target: object, source: object): object => { const sourceKeys = getObjectKeys(source); if (isObject(target) && isObject(source)) { for (const key of sourceKeys) { if (isObject(source[key])) { if (!target[key]) { Object.assign(target, { [key]: {} }); } mergeDeep(target[key], source[key]); } else { Object.assign(target, { [key]: source[key] }); } } } return target; };