Last active
April 18, 2020 11:04
-
-
Save evilsoft/914505ae8d65369b494bae625a3b7e51 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 curry from 'crocks/helpers/curry' | |
import or from 'crocks/logic/or' | |
import pathSatisfies from 'crocks/predicates/pathSatisfies' | |
import propSatisfies from 'crocks/predicates/propSatisfies' | |
const list = [ | |
'nice', 'bad', 'super bad' | |
] | |
const data = [ | |
{ fields: { risk: 'good' }, caption: 'bubbles' }, | |
{ fields: { risk: 'good' }, caption: 'nice' }, | |
{ fields: { risk: 'good' }, caption: 'bubbles' }, | |
{ fields: { risk: 'good' }, caption: 'bubbles' }, | |
{ fields: { risk: 'bad' }, caption: 'super bad' }, | |
{ fields: { risk: 'good' }, caption: 'bubbles' }, | |
{ fields: { risk: 'good' }, caption: 'bubbles' }, | |
] | |
const includes = curry( | |
(arr, value) => arr.includes(value) | |
) | |
const isInList = list => or( | |
pathSatisfies([ 'fields', 'risk' ], includes(list)), | |
propSatisfies('caption', includes(list)), | |
) | |
data.filter(isInList(list)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment