Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@dankreiger/groop

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@dankreiger/groop - npm Package Compare versions

Comparing version 0.1.20 to 0.1.22

2

dist/types/index.d.ts
import { Dict, EntityDict, ObjectKey } from './types';
export declare function createGroup<K extends ObjectKey>(key: K): <T extends Record<K, T[K]>>(items: T[]) => EntityDict<T, keyof T>;
export declare function createGroup<K extends ObjectKey>(key: K): <T extends Record<K, T[K]>>(items: T[]) => EntityDict<T, T[K]>;
export { EntityDict, Dict };
{
"name": "@dankreiger/groop",
"version": "0.1.20",
"version": "0.1.22",
"description": "Normalize an array of objects by a property.",

@@ -55,6 +55,6 @@ "homepage": "https://github.com/dankreiger/groop#readme",

"@babel/runtime": "^7.18.3",
"@commitlint/config-conventional": "^17.0.2",
"@rollup/plugin-babel": "^5.3.1",
"@rollup/plugin-commonjs": "^22.0.0",
"@rollup/plugin-node-resolve": "^13.3.0",
"@commitlint/config-conventional": "^17.0.2",
"@semantic-release/changelog": "6.0.1",

@@ -61,0 +61,0 @@ "@semantic-release/git": "10.0.1",

@@ -8,19 +8,44 @@ # groop

```ts
import { groupBy } from '@dankreiger/groop';
import { createGroup } from '@dankreiger/groop';
groupBy('id', [
{ id: 3, name: 'Dan' },
{ id: 2, name: 'Puppy' },
{ id: 3, name: 'woofer' },
]);
const listGroup = [
{ name: 'Dan', age: 5 },
{ name: 'Puppy', age: 5 },
{ name: 'Woofer', age: 22 },
{ name: 'Dan', age: 20 },
];
/** yields:
const byAge = createGroup('age');
byAge(listGroup);
/** yields **/
{
entities: {
'2': [{ id: 2, name: 'Puppy' }],
'3': [{ id: 3, name: 'woofer' }],
'20': [
{
age: 20,
name: 'Dan',
},
],
'22': [
{
age: 22,
name: 'Woofer',
},
],
'5': [
{
age: 5,
name: 'Dan',
},
{
age: 5,
name: 'Puppy',
},
],
},
ids: [3, 2, 3],
ids: [5, 22, 20],
}
*/
```

@@ -22,3 +22,3 @@ import { Dict, EntityDict, ObjectKey } from './types';

items: T[]
): EntityDict<T> {
): EntityDict<T, T[K]> {
return groupBy(key, items);

@@ -25,0 +25,0 @@ };

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