src/utils.js
// count all, only happen in the initialization phase
count all, only happen in the initialization phase
count all only happen in the initialization phase
function countNodesByType(nodes) {
    let counts = {};
    for (let n of nodes) {
        if (!counts.hasOwnProperty(n.type)) {
            counts[n.type] = 0;
        }
        counts[n.type]++;
    }
    return Object.keys(counts).map((t, i) => ({ id: i, name: t, count: counts[t] }));
}
function countNodesByType ( nodes ) { let counts = { } ; for ( let n of nodes ) { if ( ! counts . hasOwnProperty ( n . type ) ) { counts [ n . type ] = 0 ; } counts [ n . type ] ++ ; } return Object . keys ( counts ) . map ( ( t , i ) => ( { id : i , name : t , count : counts [ t ] } ) ) ; }
count all, only happen in the initialization phase
count all only happen in the initialization phase