Created
          March 13, 2017 15:57 
        
      - 
      
- 
        Save kaosat-dev/2bfa0702951b9e35f8e239b99ca583f3 to your computer and use it in GitHub Desktop. 
    partial.lenses experiment
  
        
  
    
      This file contains hidden or 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" | |
| /*var sampleTitles = { | |
| titles: [{ language: "en", text: "Title" }, | |
| { language: "sv", text: "Rubrik" }] | |
| } | |
| const sampleTest = L.compose( | |
| L.prop("titles"), | |
| L.index(0), | |
| L.prop("text") | |
| ) | |
| console.log('foo',L.get(sampleTest,sampleTitles))*/ | |
| const activePrinter = {infos:{ | |
| heads:[ | |
| {extruders:[ | |
| {hotend: {temperature:{target:200, current:95}}}, | |
| {hotend: {temperature:{target:185, current:76}}} | |
| ] | |
| } | |
| ] | |
| }} | |
| const extruders = L.compose( | |
| L.prop("infos"), | |
| L.prop("heads"), | |
| L.index(0), | |
| L.prop("extruders"), | |
| ) | |
| const hotend = extruder => L.compose( | |
| extruders, | |
| L.index(extruder), | |
| L.prop('hotend'), | |
| ) | |
| const temperatures = extruder => L.compose( | |
| hotend(extruder), | |
| L.prop('temperature'), | |
| L.props('target','current') | |
| ) | |
| const viewOfSorts = L.pick({ext1: temperatures(0), ext2 : temperatures(1)}) | |
| //const viewOfSorts2 = temperatures(0) | |
| console.log('sampleUseful',L.get(viewOfSorts,activePrinter)) | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment