These are chat archives for ramda/ramda

6th
May 2017
Florian Schrödl
@floscr
May 06 2017 17:04

Can somebody help me, I want to turn an object like this:

{
  key1: [
    { title: 'example' },
    { title: 'example' }
  ],
  key2: [
    { title: 'example2' }
  ]
}

into a flattened list like this:

[
  { title: 'example', type: 'key1' },
  { title: 'example', type: 'key1' },
  { title: 'example2', type: 'key2' },
]
Philipp Wille
@Yord
May 06 2017 18:24
How about:
const f = pipe(
  toPairs,
  chain(([key, list]) => map(assoc('type', key), list))
)
Florian Schrödl
@floscr
May 06 2017 18:36
whoa thanks, that works. I'll dig into it and try to understand :)