index.js
function flatten(role) {
        var children = permissions[role] || [];
        var result = [role];

        for (var i in children) {
            result = result.concat(flatten(children[i]));
        }
        return result;
    }
function flatten(role) {
        var children = permissions[role] || [];
        var result = [role];

        for (var i in children) {
            result = result.concat(flatten(children[i]));
        }
        return result;
    }
function flatten ( role ) { var children = permissions [ role ] || [ ] ; var result = [ role ] ; for ( var i in children ) { result = result . concat ( flatten ( children [ i ] ) ) ; } return result ; }
Flatten the map of a role
Flatten the map of a role