Skip to content

Instantly share code, notes, and snippets.

@DanielFGray
Created April 3, 2018 10:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DanielFGray/780565acb964789ec85de20ffd1931d6 to your computer and use it in GitHub Desktop.
Save DanielFGray/780565acb964789ec85de20ffd1931d6 to your computer and use it in GitHub Desktop.
search
const search = curry((pattern, str) => $(
pattern,
match(/!?(".*?"|\S+)/g),
reject(test(/^\W*$/)),
map(replace(/"(.*)"/, '$1')),
partition(startsWith('!')),
over(lensIndex(0), ifElse(isEmpty, T, $(drop(1), map(includesI), complement(anyPass)))),
over(lensIndex(1), $(map(includesI), allPass)),
([n, p]) => and(n, p, str),
))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment