Skip to content

Instantly share code, notes, and snippets.

@angeloashmore
Created August 20, 2018 08:30
Show Gist options
  • Save angeloashmore/070419d3e972fe46718b5f1be63ce1e2 to your computer and use it in GitHub Desktop.
Save angeloashmore/070419d3e972fe46718b5f1be63ce1e2 to your computer and use it in GitHub Desktop.
Returns all deeply nested values of the supplied object.
import * as R from 'ramda'
import * as RA from 'ramda-adjunct'
export const valuesDeep =
R.cond([
[
RA.isPlainObj,
R.pipe(
R.values,
R.map(x => valuesDeep(x)),
),
],
[RA.isArray, R.map(x => valuesDeep(x))],
[R.T, R.of],
])
export const flatValuesDeep = R.pipe(
valuesDeep,
R.flatten,
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment