Skip to content

Commit

Permalink
Map.groupBy type (#660)
Browse files Browse the repository at this point in the history
  • Loading branch information
turbocrime authored Mar 4, 2024
1 parent 4b370de commit 2d68674
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions packages/polyfills/Map.groupBy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/** @see https://tc39.es/proposal-array-grouping/#sec-map.groupby */
// already shipped in chrome, no type definition yet

type MapGroupBy = <T, G>(
items: Iterable<T>,
callbackfn: (value: T, index: number) => G,
) => Map<G, T[]>;

type MapWithGroupBy = typeof Map & { groupBy: MapGroupBy };

export default Map as MapWithGroupBy;

0 comments on commit 2d68674

Please sign in to comment.