1.0.1 • Published 3 years ago

deep-merge-update-clone v1.0.1

Weekly downloads
5
License
ISC
Repository
-
Last release
3 years ago

Simple set of util functions written VanillaJS to make life easier

Usage

npm i deep-merge-update-clone

const { mergeObjects, updateObjects, cloneObject } = require('deep-merge-update-clone');


mergeObjects(target: object, source: object) - > retuns merged object


Accepts two objects (target and source) and merge them recursively and retuns the merged object


updateObjects(propertyPath: string, value: any, sourceObj: object, replaceData: boolean) updates the passed source object


propertyPath - specific path to the property that needs to be updated, can specify deeply nested properties ex- single level property - 'property1' multiple level nested property - 'property1.property2.property3'

value - The new value that needs to be updated in the specified propertyPath, accepts all types of variables including objects sourceObj - The Source object replaceData - if specified true will replace the value in the propertyPath with the provided new value, if not function will merge the existing value in the property path with the new value


cloneObject(target: object) -> returns deep cloned object

This Function will colone the entire object recursively so that inner objects are also cloned