src/highlight-page.js
function groupHighlights(highlights) {
    let order = [],
        chunks = {},
        grouped = [];

    highlights.forEach(function (hl) {
        let timestamp = hl.getAttribute(TIMESTAMP_ATTR);

        if (typeof chunks[timestamp] === 'undefined') {
            chunks[timestamp] = [];
            order.push(timestamp);
        }

        chunks[timestamp].push(hl);
    });

    order.forEach(function (timestamp) {
        let group = chunks[timestamp];

        grouped.push({
            chunks: group,
            timestamp: timestamp,
            toString: function () {
                return group.map(function (h) {
                    return h.textContent;
                }).join('');
            }
        });
    });

    return grouped;
}
function groupHighlights(highlights) {
    let order = [],
        chunks = {},
        grouped = [];

    highlights.forEach(function (hl) {
        let timestamp = hl.getAttribute(TIMESTAMP_ATTR);

        if (typeof chunks[timestamp] === 'undefined') {
            chunks[timestamp] = [];
            order.push(timestamp);
        }

        chunks[timestamp].push(hl);
    });

    order.forEach(function (timestamp) {
        let group = chunks[timestamp];

        grouped.push({
            chunks: group,
            timestamp: timestamp,
            toString: function () {
                return group.map(function (h) {
                    return h.textContent;
                }).join('');
            }
        });
    });

    return grouped;
}
function groupHighlights ( highlights ) { let order = [ ] , chunks = { } , grouped = [ ] ; highlights . forEach ( function ( hl ) { let timestamp = hl . getAttribute ( TIMESTAMP_ATTR ) ; if ( typeof chunks [ timestamp ] === 'undefined' ) { chunks [ timestamp ] = [ ] ; order . push ( timestamp ) ; } chunks [ timestamp ] . push ( hl ) ; } ) ; order . forEach ( function ( timestamp ) { let group = chunks [ timestamp ] ; grouped . push ( { chunks : group , timestamp : timestamp , toString : function ( ) { return group . map ( function ( h ) { return h . textContent ; } ) . join ( '' ) ; } } ) ; } ) ; return grouped ; }
Groups given highlights by timestamp.
@param {Array} highlights
@returns {Array} Grouped highlights.
Groups given highlights by timestamp .