New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

flat-group

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

flat-group - npm Package Compare versions

Comparing version 0.0.1 to 0.0.2

README.md

46

index.ts
export default function flatGroup<T extends Record<any, any>>(
arr: Array<T>,
keys: Array<string>
): Record<string, Record<string, {
// @ts-ignore
keys: string[],
[key: string]: Array<T>
}>> {
const groups: Record<string, any> = {};
arr: Array<T>,
keys: Array<string>
): Record<
string,
Record<
string,
{
// @ts-ignore
keys: string[];
[key: string]: Array<T>;
}
>
> {
const groups: Record<string, any> = {};
for (const k of keys) {
groups[k] = {};
const group = groups[k];
const keyOfGroups: Array<any> = (groups[k]["keys"] = []);
for (const k of keys) {
groups[k] = {};
const group = groups[k];
const keyOfGroups: Array<any> = (groups[k]["keys"] = []);
for (const item of arr) {
const value = item[k];
if (keyOfGroups.indexOf(value) === -1) keyOfGroups.push(value);
for (const item of arr) {
const value = item[k];
if (keyOfGroups.indexOf(value) === -1) keyOfGroups.push(value);
const groupKey: string = String(value);
if (groupKey in group) group[groupKey].push(item);
else group[groupKey] = [item];
const groupKey: string = String(value);
if (groupKey in group) group[groupKey].push(item);
else group[groupKey] = [item];
}
}
}
return groups;
return groups;
}
{
"name": "flat-group",
"version": "0.0.1",
"version": "0.0.2",
"description": "A function for creating flat groups from items in array",
"main": "/dist/index.js",
"types": "/dist/index.d.ts",
"repository": {
"type": "git",
"url": "https://github.com/Jamesbarford/flat-group.git"
},
"scripts": {

@@ -8,0 +12,0 @@ "test": "echo \"Error: no test specified\" && exit 1"

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc