-
-
Notifications
You must be signed in to change notification settings - Fork 11
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
Combine arrays of object #25
Comments
@syuilo did you see this section of the readme? |
Yes. But I do not want to concat. |
@syuilo I see!! something like this? import { isArray } from 'is-what'
import { merge } from 'merge-anything'
export function concatArrays (originVal: any, newVal: any): any | any[] {
if (isArray(originVal) && isArray(newVal)) {
// concat & merge logic
const overlappingPart = originVal.slice(0, newVal.length)
return overlappingPart
.map((p, i) => newVal[i] ? merge(p, newVal[i]) : p)
.concat(newVal.length > originVal.length ? originVal.slice(newVal.length) : newVal.slice(originVal.length))
}
return newVal // always return newVal as fallback!!
} if this is ok, greatly appreciate a PR with this fn exported similarly to |
@syuilo did this solve your issue? |
Thanks for creating this library, there are several libraries that do deep merge, but this is the only one I've seen written in TypeScript.
I would like to see a default function for deep merging arrays of objects, such as the one introduced in the deepmerge library.
This means that I want to use the following strategy for merging:
Or please provide a sample that uses mergeAndCompare to achieve the same process.
Thanks!
The text was updated successfully, but these errors were encountered: