deepDeletePropByValue

Function

Recursively deletes properties from an object or array that have a specific value.

Hub commonly applies migrations to entities on load. During those migrations, often we want to delete properties to clean things up. However, during the save process, we typically fetch the entity from it's backing store and spread the migrated entity over the top of the fetched entity. This results in the deleted props being re-added.

To avoid this, instead of deleting the props in the migration, we can set them to a specific value (e.g. remove-this-prop) and then use this function to remove them, after the merge.

  • deepDeletePropByValue(object: any, value: any) : any

Parameters

Parameter Type Default Notes
object Required any

The object or array to delete properties from.

value Required any

The value to match and delete.

Returns

The modified object or array with properties deleted.

any

Function defined in common/src/objects/deepDeletePropByValue.ts:23