Skip to content

Add `allowUndefinedOverrides` option + update dependencies

Compare
Choose a tag to compare
@voodoocreation voodoocreation released this 18 Jul 00:34

Changes

This version includes a new option - allowUndefinedOverrides. If you provide it with false it will prevent explicitly-provided properties with a value of undefined from overwriting existing values:

import merge from "ts-deepmerge";

const objA = { value: 1 };
const objB = { value: 2 };
const objC = { value: undefined };

merge.withOptions({ allowUndefinedOverrides: false }, objA, objB, objC);

The result of the above example would be:

{ value: 2 }

Thanks to @norahmaria for raising an issue (#28) asking for this feature🙏