Skip to content

Instantly share code, notes, and snippets.

@dmitry-izmerov
dmitry-izmerov / ObjectsTree.js
Last active June 21, 2016 20:13
Build object tree on array of strings with hierarchy of roles and getting of leaves from this tree.
var data = [
'all', 'all/staff', 'all/staff/developer', 'all/staff/manager', 'all/staff/engineer',
'all', 'all/other', 'all/other/writer', 'all/other/hr'
];
var delimeter = '/';
function getStructure(data) {
var structure = {
isLeave: true