MCPcopy Index your code
hub / github.com/apache/echarts / groupData

Function groupData

src/util/model.ts:1057–1078  ·  view source on GitHub ↗
(
    array: T[],
    getKey: (item: T) => R // return key
)

Source from the content-addressed store, hash-verified

1055 * Group a list by key.
1056 */
1057export function groupData<T, R extends string | number>(
1058 array: T[],
1059 getKey: (item: T) => R // return key
1060): {
1061 keys: R[],
1062 buckets: HashMap<T[], R> // hasmap key: the key returned by `getKey`.
1063} {
1064 const buckets = createHashMap<T[], R>();
1065 const keys: R[] = [];
1066
1067 each(array, function (item) {
1068 const key = getKey(item);
1069 (buckets.get(key)
1070 || (keys.push(key), buckets.set(key, []))
1071 ).push(item);
1072 });
1073
1074 return {
1075 keys: keys,
1076 buckets: buckets
1077 };
1078}
1079
1080
1081/**

Callers 3

prepareNodesByBreadthFunction · 0.90
fixDataMethod · 0.90
getLayerSeriesMethod · 0.90

Calls 3

getKeyFunction · 0.85
eachFunction · 0.50
getMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…