Skip to content

Instantly share code, notes, and snippets.

@leonidkuznetsov18
Created July 3, 2019 12:02
Show Gist options
  • Select an option

  • Save leonidkuznetsov18/696f8892af2b7f381b5e6ed989940ae1 to your computer and use it in GitHub Desktop.

Select an option

Save leonidkuznetsov18/696f8892af2b7f381b5e6ed989940ae1 to your computer and use it in GitHub Desktop.
flat deep structure object arrays
const contentToFlatList = ({ content }, accumulator = []) =>
content.reduce((result, item) => {
if (item.content) {
return result.concat(contentToFlatList(item));
}
return result.concat([item]);
}, accumulator);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment