Skip to content

Instantly share code, notes, and snippets.

@char0n
Created August 19, 2017 08:08
Show Gist options
  • Save char0n/0a812a917c56f3bb6878f6ee4c5ea67d to your computer and use it in GitHub Desktop.
Save char0n/0a812a917c56f3bb6878f6ee4c5ea67d to your computer and use it in GitHub Desktop.
Composing lenses in Ramda
import { lensPath, view } from 'ramda';
const complexObject = { level1: { level2: { prop1: 1, prop2: 2 } } };
const prop1Lens = lensPath(['level1', 'level2', 'prop1']);
console.assert(view(prop1Lens, complexObject) === 1);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment