Question: Is it possible to download images to users local machines directly via Firebase functions? How to do it in case that:

1. Images are stored in Firebase storage.
2. Images are stored on other cloud storage providers (I can access them with url).

I don't want to download those images via url links so that I don't reveal the url the image is located on.

Answer: 
I think this will do what you are trying to do:

```
orderResults.reduce((res, obj, i) => {
    const existingIdx = res.findIndex(r => r.id === obj.id)
    if (existingIdx > -1) {
      res[existingIdx] = { 
        ...res[existingIdx],
        total_amount : res[existingIdx].total_amount ? res[existingIdx].total_amount + obj.payment_amount : res[existingIdx].payment_amount + obj.payment_amount,
        name : obj.name,
        ['sku_' + obj.seq]: obj.sku
      }
    } else {
      res.push({
        id: obj.id,
        name: obj.name,
        total_amount: obj.payment_amount,
        ['sku_' + obj.seq]: obj.sku
      })
    }

    return res;
},[])

```

Notice this line will preserve the original object and overwrite any duplicate keys that are defined afterwards:

`...res[existingIdx],`

Also when your code runs this line:

`res[obj.id] = {` 

it is setting a specific index in the array, which I don't think you want to do. You want to either push (if the object id hasn't been added yet), or overwrite the existing object at the original insertion point when the object with the same id was created.
```js
[{
    id: '1',
    name: 'Maya Mahardhani',
    payment_amount: 100,
    sku: 'ST001802027',
    seq: '1'
},
{
    id: '1',
    name: 'Maya Mahardhani',
    payment_amount: 50,
    sku: 'ST000703044',
    seq: '2'
},
{
    id: '2',
    name: 'Tara Debu Batara',
    payment_amount: 100,
    sku: 'ST005101001',
    seq: '1'
},
{
    id: '3',
    name: 'Nikita Gigir',
    payment_amount: 100,
    sku: 'ST004403030',
    seq: '1'
}].reduce((acc, current) => {
    const { id, name, payment_amount, sku, seq } = current;
    const previousRecord = acc[id];
    if (typeof previousRecord === 'object') {
        return {
            ...acc,
            [id]: {
                ...previousRecord,
                [`sku_${seq}`]: sku,
                total_amount: previousRecord.total_amount + payment_amount
            }
        }
    } else {

        return {
            ...acc,
            [id]: {
                id,
                name,
                [`sku_${seq}`]: sku,
                total_amount: payment_amount
            }
        }
    }
}, {}) // returns an Object; use Object.values to convert to a list

```