Skip to content

Instantly share code, notes, and snippets.

@phpsmarter
Forked from char0n/sample_code1.js
Created January 16, 2018 09:10
Show Gist options
  • Save phpsmarter/a20b12da9f29fa11d186e5ffb47add52 to your computer and use it in GitHub Desktop.
Save phpsmarter/a20b12da9f29fa11d186e5ffb47add52 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