### 标准用法
```
const oa = require('object_array')
oa([{a:1,b:2,c:3},{a:4,b:5,d:6}])//{a:5,b:7,c:3,d:6}
oa([{a:{a1:1,b1:2},b:2},{a:{a1:3,a2:4,a3:5}},c:{c:10}}])//{a:{a1:4,b1:2,a2:4,a3:5},b:2,c:{c:10}}
```
---
### 类型冲突情况
```
oa([{a:{a1:1,a2:2},b:2},{a:1,b:{b1:1}}])//{a:{a1:1,a2:2},b:2}
oa([{a:1,b:'bbb'},{a:'aaa',b:2,c:'ccc'}])//{a:1,b:2,c:0}
```
### 类型问题
> 传入的类型不正确,原路返回
```
oa(1)//1
oa({a:1})//{a:1}
```
```
const re = {}
function run (key,_in){
if(_in.length<=1){
return _in
}
return key.map(itm=>{
const e = _in.reduce((l='', r, index)=>{
if(typeof l[itm] === 'object'||typeof r[itm] === 'object'){
if(index!==1&&typeof l !== typeof r[itm]){
return l
}
if(index === 1 && typeof l[itm] !== typeof r[itm]){
return l[itm]
}
if(index === 1){
var re = run(Object.keys(Object.assign({},l[itm],r[itm])),[l[itm]||{},r[itm]||{}])
}else{
var re = run(Object.keys(Object.assign({},l,r[itm])),[l||{},r[itm]||{}])
}
return Object.assign(...re)
}
if(index===1){
const le = Number.isNaN(+l[itm])?0:+l[itm]
const ri = Number.isNaN(+r[itm])?0:+r[itm]
return le+ri
}else{
if(typeof l !== typeof r[itm]){
return l
}
const result = l + +(r[itm]||'')
if(Number.isNaN(result)){
return l
}
return result
}
});
return {
[itm]:e
}
})
}
const object_array = (_in)=>{
if(!Array.isArray(_in)){
return _in
}
const key = Object.keys(Object.assign({},..._in))
return Object.assign(...run(key,_in))
}
```