Skip to content

Instantly share code, notes, and snippets.

@choonkending
Last active June 6, 2017 11:45
Show Gist options
  • Save choonkending/8c0f2a73e86654d4b75d2df73245200a to your computer and use it in GitHub Desktop.
Save choonkending/8c0f2a73e86654d4b75d2df73245200a to your computer and use it in GitHub Desktop.
const getBedrooms = data =>
Option(data.listing)
.flatMap(listing => Option(listing.features))
.flatMap(features => Option(features.bedrooms))
.map(bedrooms => bedrooms.value)
.fold(() => 0, v => v);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment