Skip to content

Instantly share code, notes, and snippets.

@KristofferTolboll2
Created April 7, 2023 16:30
Show Gist options
  • Select an option

  • Save KristofferTolboll2/84aaedb6e91a63aa1c4efbbf2b2b23fc to your computer and use it in GitHub Desktop.

Select an option

Save KristofferTolboll2/84aaedb6e91a63aa1c4efbbf2b2b23fc to your computer and use it in GitHub Desktop.
function mergeSeedResults(...seedResults: Array<Partial<SeedResult>>): SeedResult {
const mergedSeedResult = new SeedResult();
Object.keys(mergedSeedResult).forEach((key) => {
if (Array.isArray(mergedSeedResult[key])) {
const mergedArray: any[] = [];
seedResults.forEach((seedResult) => {
if (seedResult && Array.isArray(seedResult[key])) {
mergedArray.push(...seedResult[key]);
}
});
mergedSeedResult[key] = mergedArray;
}
});
return mergedSeedResult;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment