Created
April 18, 2019 18:43
-
-
Save Millsky/8d965a8582fa605caa966f9f983e316a 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
import * as L from 'partial.lenses'; | |
import * as R from 'ramda'; | |
const classA = { | |
p: 2, | |
d: 2, | |
c: true, | |
classB: null, | |
}; | |
const classAOptic = ['classB']; | |
const classB = { | |
r: 4, | |
f: 'f', | |
k: '', | |
} | |
const classBOptic = ['r']; | |
const data1 = { | |
p: 2, | |
d: 2, | |
c: true, | |
classB: { | |
r: 4, | |
f: 'f', | |
k: '', | |
}, | |
}; | |
const composedOptic = [classAOptic, classBOptic]; | |
console.log(L.get(composedOptic, data1)); | |
const data = { | |
d: { | |
1: { | |
a: { | |
a: 2, | |
}, | |
b: 2, | |
}, | |
2: { | |
a: { | |
a: 3, | |
}, | |
c: 3, | |
}, | |
3: { | |
a: { | |
a: 100, | |
}, | |
}, | |
} | |
}; | |
const myATraversal = ['d', L.values, 'a']; | |
console.log(L.collect(myATraversal, data)); | |
console.log(L.disperse( | |
[myATraversal, 'a'], | |
[1,2], | |
data | |
) | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment