Created
August 20, 2018 08:30
-
-
Save angeloashmore/070419d3e972fe46718b5f1be63ce1e2 to your computer and use it in GitHub Desktop.
Returns all deeply nested values of the supplied object.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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