feat(deepMerge): only merge plain objects#90
Merged
aprendendofelipe merged 2 commits intomainfrom Jan 5, 2026
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
@barso/forms
@barso/helpers
@barso/hooks
@barso/infra
@barso/ui
commit: |
There was a problem hiding this comment.
Pull request overview
This PR modifies the deepMerge function to only deeply merge plain objects (object literals), while treating built-in objects like Date, Map, Set, and RegExp as atomic values that should be replaced rather than merged.
Key changes:
- Introduced a new
isPlainObjecthelper function that distinguishes plain objects from built-in objects and class instances - Updated
deepMergeto useisPlainObjectinstead ofisObjectfor merge decisions - Added comprehensive test coverage for the new behavior with various built-in object types
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| packages/helpers/src/is.js | Added new isPlainObject function to check if a value is a plain object literal |
| packages/helpers/src/is.test.js | Added comprehensive tests for isPlainObject covering primitives, arrays, built-in objects, and custom prototypes |
| packages/helpers/src/merge.js | Updated deepMerge to use isPlainObject instead of isObject to prevent merging built-in objects |
| packages/helpers/src/merge.test.js | Added tests verifying that RegExp, Map, Set, and Date objects are replaced rather than merged |
Comments suppressed due to low confidence (1)
packages/helpers/src/merge.js:7
- The function documentation should be updated to clarify that it only deeply merges plain objects (object literals). Built-in objects like Date, Map, Set, and RegExp are replaced rather than merged. Consider updating the JSDoc to explain this behavior, for example: "Deeply merges two plain objects. Built-in objects (Date, Map, Set, RegExp, etc.) are replaced by the source value rather than merged."
/**
* Deeply merges two objects.
* @param {*} target - The target object to merge into.
* @param {*} source - The source object to merge from.
* @returns {*} - The merged object.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
ee857e8 to
12c5bf3
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.