src/operator/data-builder.js
function groupData(data, fieldIndex) {
    const hashMap = new Map();
    const groupedData = [];

    data.forEach((datum) => {
        const fieldVal = datum[fieldIndex];
        if (hashMap.has(fieldVal)) {
            groupedData[hashMap.get(fieldVal)][1].push(datum);
        } else {
            groupedData.push([fieldVal, [datum]]);
            hashMap.set(fieldVal, groupedData.length - 1);
        }
    });

    return groupedData;
}
function groupData(data, fieldIndex) {
    const hashMap = new Map();
    const groupedData = [];

    data.forEach((datum) => {
        const fieldVal = datum[fieldIndex];
        if (hashMap.has(fieldVal)) {
            groupedData[hashMap.get(fieldVal)][1].push(datum);
        } else {
            groupedData.push([fieldVal, [datum]]);
            hashMap.set(fieldVal, groupedData.length - 1);
        }
    });

    return groupedData;
}
function groupData ( data , fieldIndex ) { const hashMap = new Map ( ) ; const groupedData = [ ] ; data . forEach ( ( datum ) => { const fieldVal = datum [ fieldIndex ] ; if ( hashMap . has ( fieldVal ) ) { groupedData [ hashMap . get ( fieldVal ) ] [ 1 ] . push ( datum ) ; } else { groupedData . push ( [ fieldVal , [ datum ] ] ) ; hashMap . set ( fieldVal , groupedData . length - 1 ) ; } } ) ; return groupedData ; }
Groups the data according to the specified target field.

@param {Array} data - The input data array.
@param {number} fieldIndex - The target field index within schema array.
@return {Array} Returns an array containing the grouped data.
Groups the data according to the specified target field .