UNPKG

playwright-performance

Version:

Playwright plugin for analyzing test flow performance

26 lines (25 loc) 678 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); class Group { /** * Group list of objects by properties * @param list * @param getKey e.g. p => [p.name, p.browserName] * @returns */ groupBy(list, getKey) { const map = new Map(); list.forEach((item) => { const key = JSON.stringify(getKey(item)); const collection = map.get(key); if (!collection) { map.set(key, [item]); } else { collection.push(item); } }); return Array.from(map.values()); } } exports.default = new Group();