es-toolkit
Version:
A state-of-the-art, high-performance JavaScript utility library with a small bundle size and strong type annotations.
18 lines (17 loc) • 680 B
JavaScript
import { isPlainObject } from "../predicate/isPlainObject.mjs";
//#region src/_internal/isMergeableValue.ts
/**
* Checks if a value can be deeply merged into, i.e. it is a plain object or an array.
*
* This function is used in `merge`, `mergeWith`, and `toMerged` to decide whether
* the source value should be merged into the existing target value recursively,
* preserving the target's structure, instead of replacing it.
*
* @param value - The value to check.
* @returns `true` if the value is a plain object or an array, otherwise `false`.
*/
function isMergeableValue(value) {
return isPlainObject(value) || Array.isArray(value);
}
//#endregion
export { isMergeableValue };