ramda path
by hurtonypeter
HTML
<script src="https://cdnjs.cloudflare.com/ajax/libs/ramda/0.25.0/ramda.min.js"></script>
<pre id="result"></pre>
JavaScript
var menu = [{
title: "Section 1",
items: [{
title: 'Dashboard',
icon: 'tachometer-alt',
route: '/dashboard',
opened: false
},
{
title: 'Appointments',
icon: 'calendar-alt',
route: '/appointments',
opened: true
},
{
title: 'Orders',
icon: 'box',
route: '/orders',
opened: false,
children: [{
title: 'Orders submenu 1',
route: '/orders/sub1',
opened: false,
children: [{
title: 'Orders submenu 1 subsubmenu 1',
route: '/orders/sub1/sub1sub1'
}]
}]
}
]
}];
var indexer = [0, 'items', 2, 'children', 0];
//ramda magic here
// expected: the "Orders submenu 1" has its "opened" property set to "true"
document.getElementById("result").innerHTML = JSON.stringify(menu, undefined, 2);