UNPKG

@tobes31415/console-logger

Version:

Formats console logs while preserving stack trace info

28 lines (27 loc) 795 B
function deepAssign(target, ...others) { others.forEach((obj) => { obj && Object.keys(obj).forEach((key) => { const value = obj[key]; const origValue = target[key]; const bothAreObjects = typeof value === "object" && typeof origValue === "object" && value && origValue; const eitherIsArray = Array.isArray(value) || Array.isArray(origValue); if (bothAreObjects && !eitherIsArray) { deepAssign(origValue, value); } else { target[key] = value; } }); }); return target; } function isNullorUndefined(value) { return value === null || value === void 0; } function nullishCoalesce(value, replacement) { return isNullorUndefined(value) ? replacement : value; } export { deepAssign, isNullorUndefined, nullishCoalesce };