I need to merge two data arrays of the same shape.
My working code is this:
import * as R from 'ramda'
const expected = [
[
{
"zeroData": false,
"responseCount": [
0,
0,
1,
9
],
"responsePercent": [
0,
0,
0.1,
0.9
],
"index": 9.666666666666666,
"stdDev": 0.9999999999999999,
"expectedStdDev": 1.651740425387243
}
]
]
const t1 = [
[
{
"zeroData": false,
"responseCount": [
0,
0,
1,
9
],
"responsePercent": [
0,
0,
0.1,
0.9
],
"index": 9.666666666666666,
"stdDev": 0.9999999999999999
}
]
]
const t2 = [
[
{
"expectedStdDev": 1.651740425387243
}
]
]
test('merge', () => {
const merged = t1.map((arr1, idx1) => {
return arr1.map((obj, idx2) => ({...obj, ...t2[idx1][idx2]}))
})
expect(merged).toStrictEqual(expected)
})
Is there a simple and elegant Ramda-way to do it? And especially a generic solution that would allow to specify the depth at which the merging should occur.
Tried various combinations of the R functions with no luck