Created
January 2, 2017 20:42
-
-
Save char0n/007c37277788bd18d1871b4f77e7a53e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { lensPath, view, compose, pipe, defaultTo, curry } = require('ramda'); | |
const reflectObject = { | |
data: { | |
GET: { | |
system: { | |
ntp: 3, | |
}, | |
}, | |
}, | |
}; | |
const dataLens = lensPath(['data']); | |
const GETLens = lensPath(['GET1']); | |
const systemLens = lensPath(['system']); | |
const ntpLens = lensPath(['ntp']); | |
const dataGetSystemNtpLens = compose(dataLens, GETLens, systemLens, ntpLens); | |
const viewOr = curry((defaultValue, lens, obj) => pipe(view(lens), defaultTo(defaultValue))(obj)); | |
console.dir(viewOr(null, dataGetSystemNtpLens, reflectObject)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment