Skip to content

It need filter on merge #258

@alexk400

Description

@alexk400

Hi

i was using react-data-table-component package which is uses deep merge to custom merge styles to default styles.
it do not accept anonymous function because merge do not have filter.

Basically every time it replace text it need to check if its a function. Filter passed job is to have a flag to say check for function. Tomorrow filter can be something else. Today just see if its a function and excecute it and replace that value with original value.

This is your method
`function mergeObject(target, source, options) {
var destination = {};
if (options.isMergeableObject(target)) {
getKeys(target).forEach(function(key) {
destination[key] = cloneUnlessOtherwiseSpecified(target[key], options);
});
}
getKeys(source).forEach(function(key) {
if (propertyIsUnsafe(target, key)) {
return
}

	if (propertyIsOnObject(target, key) && options.isMergeableObject(source[key])) {
		destination[key] = getMergeFunction(key, options)(target[key], source[key], options);
	} else {
		destination[key] = cloneUnlessOtherwiseSpecified(source[key], options);
	}

//alexk code begin
var newdest=destination[key];
if(typeof newdest === 'function')
destination[key]=newdest();
//alexk code ends
});

return destination

}`

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions