@qntm-code/utils
Version:
A collection of useful utility functions with associated TypeScript types. All functions have been unit tested.
15 lines (14 loc) • 543 B
JavaScript
import { isReactElement } from './isReactElement.js';
/**
* Figuring out which properties of an object should be recursively iterated over when merging.
*/
export function isMergeableObject(value) {
return isNonNullObject(value) && !isSpecial(value);
}
function isNonNullObject(value) {
return !!value && typeof value === 'object';
}
function isSpecial(value) {
const stringValue = Object.prototype.toString.call(value);
return stringValue === '[object RegExp]' || stringValue === '[object Date]' || isReactElement(value);
}