Skip to content

Instantly share code, notes, and snippets.

@WaldoJeffers
Created May 22, 2018 21:11
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 WaldoJeffers/bcbe85cdfc2babc5724c0f0be6a5fcba to your computer and use it in GitHub Desktop.
Save WaldoJeffers/bcbe85cdfc2babc5724c0f0be6a5fcba to your computer and use it in GitHub Desktop.
import { compose, equals, filter, get } from 'conductor'
const character_ids = [1, 2, 3, 4, 5]
const fetchCharacter = id => fetch(`https://swapi.co/api/people/${id}`).then(res => res.json())
const hasBlueEyes = compose(equals('blue'), get('eye_color'), fetchCharacter))
await filter(hasBlueEyes, characters_ids) // [{ name: 'Luke Skywalker }, { name: 'Owen Lars' }, ...]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment