Product
Introducing Socket Optimize
We're excited to introduce Socket Optimize, a powerful CLI command to secure open source dependencies with tested, optimized package overrides.
ts-group-by
Advanced tools
This package allows you to group an array by one or more levels while maintaining type safety.
npm install ts-group-by
import { groupBy } from "ts-group-by";
const data = [
{ agency: "Agency A", patient: "Carol baskin", gender: "F" },
{ agency: "Agency A", patient: "Carol baskin", gender: "F" },
{ agency: "Agency A", patient: "Esther Friedman", gender: "M" },
{ agency: "Agency A", patient: "Zaritskaia Raia", gender: "M" },
{ agency: "Agency B", patient: "Judy Gottesman", gender: "F" },
];
const groupedByAgency = groupBy(data, "agency");
// : Map<string, { agency: string; patient: string; gender: string; }[]>
// = Map {
// 'Agency A' => [
// { agency: 'Agency A', patient: 'Carol baskin', gender: 'F' },
// { agency: 'Agency A', patient: 'Carol baskin', gender: 'F' },
// { agency: 'Agency A', patient: 'Esther Friedman', gender: 'M' },
// { agency: 'Agency A', patient: 'Zaritskaia Raia', gender: 'M' }
// ],
// 'Agency B' => [
// { agency: 'Agency B', patient: 'Judy Gottesman', gender: 'F' }
// ]
// }
const groupedByAgencyAndGender = groupBy(data, "agency", "gender");
// : Map<string, Map<string, { agency: string; patient: string; gender: string; }[]>>
// = Map {
// 'Agency A' => Map {
// 'F' => [
// { agency: 'Agency A', patient: 'Carol baskin', gender: 'F' },
// { agency: 'Agency A', patient: 'Carol baskin', gender: 'F' }
// ],
// 'M' => [
// { agency: 'Agency A', patient: 'Esther Friedman', gender: 'M' },
// { agency: 'Agency A', patient: 'Zaritskaia Raia', gender: 'M' }
// ]
// }
// 'Agency B' => Map {
// 'F' => [
// { agency: 'Agency B', patient: 'Judy Gottesman', gender: 'F' }
// ]
// }
// }
FAQs
group by one or more levels while maintaining type safety.
The npm package ts-group-by receives a total of 1 weekly downloads. As such, ts-group-by popularity was classified as not popular.
We found that ts-group-by demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
We're excited to introduce Socket Optimize, a powerful CLI command to secure open source dependencies with tested, optimized package overrides.
Product
We're excited to announce that Socket now supports the Java programming language.
Security News
Socket detected a malicious Python package impersonating a popular browser cookie library to steal passwords, screenshots, webcam images, and Discord tokens.