I'm currently facing a challenge in combining objects from an array of Objects in typescript.
The structure of the array is as follows:
0: {type: 'FeatureCollection', features: Array(134)}
1: {type: 'FeatureCollection', features: Array(109)}
What I am looking for is to create a single object (not an array) with all "features" combined, like this:
{type: 'FeatureCollection', features: Array(243)}
As I am new to typescript, please excuse me if this seems like a basic question...
Thank you for your help!
EDIT: To clarify, when I mention Array(134), it means there are 134 objects inside. The manual approach for a collection of length 2 is shown below:
const result = [...collection[0].features, ...collection[1].features];
const resultCollection: FeatureCollection = collection[0];
resultCollection.features = result;
I need to generalize this solution to work for any length of collection.