Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

It need filter on merge #258

Open
alexk400 opened this issue Mar 15, 2023 · 0 comments
Open

It need filter on merge #258

alexk400 opened this issue Mar 15, 2023 · 0 comments

Comments

@alexk400
Copy link

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

}`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant