@dankreiger/groop
Advanced tools
Comparing version 0.1.22 to 0.1.23
@@ -1,1 +0,1 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.createGroup=function(e){return function(t){return((e,t)=>t.reduce(((t,i)=>({...t,entities:{...t.entities,[i[e]]:[...t.entities[i[e]]||[],i]},ids:[...new Set((t.ids||[]).concat([i[e]]))]})),{entities:{},ids:[]}))(e,t)}}; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.createGroup=function(e){return function(t){return((e,t)=>t.reduce(((t,i)=>({...t,entities:{...t.entities,[i[e]]:[t.entities[i[e]]||[],i].flat()},ids:[...new Set((t.ids||[]).concat([i[e]]))]})),{entities:{},ids:[]}))(e,t)}}; |
@@ -1,1 +0,1 @@ | ||
function e(e){return function(t){return((e,t)=>t.reduce(((t,i)=>({...t,entities:{...t.entities,[i[e]]:[...t.entities[i[e]]||[],i]},ids:[...new Set((t.ids||[]).concat([i[e]]))]})),{entities:{},ids:[]}))(e,t)}}export{e as createGroup}; | ||
function t(t){return function(e){return((t,e)=>e.reduce(((e,i)=>({...e,entities:{...e.entities,[i[t]]:[e.entities[i[t]]||[],i].flat()},ids:[...new Set((e.ids||[]).concat([i[t]]))]})),{entities:{},ids:[]}))(t,e)}}export{t as createGroup}; |
@@ -1,3 +0,3 @@ | ||
import { Dict, EntityDict, ObjectKey } from './types'; | ||
import { EntityDict, ObjectKey } from './types'; | ||
export declare function createGroup<K extends ObjectKey>(key: K): <T extends Record<K, T[K]>>(items: T[]) => EntityDict<T, T[K]>; | ||
export { EntityDict, Dict }; | ||
export { EntityDict }; |
@@ -1,8 +0,5 @@ | ||
export declare type ObjectKey = string | number | symbol; | ||
export declare type EntityDict<E, Key = keyof E> = { | ||
entities: Record<keyof E, E> | Record<never, undefined>; | ||
export type ObjectKey = string | number | symbol; | ||
export type EntityDict<E, Key extends ObjectKey> = { | ||
entities: Record<Key, E>; | ||
ids: Key[]; | ||
}; | ||
export declare type Dict<T> = keyof T extends string ? Partial<{ | ||
[K in `by${Capitalize<keyof T>}`]: EntityDict<T>; | ||
}> : never; |
{ | ||
"name": "@dankreiger/groop", | ||
"version": "0.1.22", | ||
"version": "0.1.23", | ||
"description": "Normalize an array of objects by a property.", | ||
@@ -27,68 +27,65 @@ "homepage": "https://github.com/dankreiger/groop#readme", | ||
"scripts": { | ||
"analyze": "size-limit --why", | ||
"analyze": "scripty", | ||
"build": "scripty", | ||
"clean": "scripty", | ||
"commit": "scripty", | ||
"format": "scripty", | ||
"lint": "scripty", | ||
"prepare": "scripty", | ||
"semantic-release": "semantic-release", | ||
"protect": "scripty", | ||
"release": "scripty", | ||
"size": "scripty", | ||
"test": "jest" | ||
"test": "scripty" | ||
}, | ||
"husky": { | ||
"hooks": { | ||
"pre-commit": "npx lint-staged" | ||
"config": { | ||
"commitizen": { | ||
"path": "./node_modules/cz-conventional-changelog" | ||
} | ||
}, | ||
"lint-staged": { | ||
"packages/**/src/*.{js,ts,tsx,jsx,json,css}": [ | ||
"yarn sort-package-json && prettier --single-quote --write" | ||
], | ||
"*.{md,mdx,yml}": [ | ||
"yarn sort && prettier --write" | ||
] | ||
}, | ||
"devDependencies": { | ||
"@babel/core": "^7.18.2", | ||
"@babel/plugin-transform-runtime": "^7.18.2", | ||
"@babel/preset-env": "^7.18.2", | ||
"@babel/preset-typescript": "^7.17.12", | ||
"@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", | ||
"@babel/core": "7.18.6", | ||
"@babel/plugin-transform-runtime": "7.18.6", | ||
"@babel/preset-env": "7.18.6", | ||
"@babel/preset-typescript": "7.18.6", | ||
"@babel/runtime": "7.18.6", | ||
"@commitlint/cli": "17.3.0", | ||
"@commitlint/config-conventional": "17.0.3", | ||
"@commitlint/prompt-cli": "17.3.0", | ||
"@rollup/plugin-babel": "5.3.1", | ||
"@rollup/plugin-commonjs": "22.0.1", | ||
"@rollup/plugin-node-resolve": "13.3.0", | ||
"@semantic-release/changelog": "6.0.1", | ||
"@semantic-release/git": "10.0.1", | ||
"@semantic-release/github": "8.0.4", | ||
"@semantic-release/github": "8.0.6", | ||
"@semantic-release/npm": "9.0.1", | ||
"@size-limit/preset-small-lib": "7.0.8", | ||
"@size-limit/webpack-why": "7.0.8", | ||
"@types/jest": "^28.1.0", | ||
"@types/node": "^17.0.38", | ||
"@typescript-eslint/eslint-plugin": "^5.27.0", | ||
"@typescript-eslint/parser": "^5.27.0", | ||
"eslint": "^8.16.0", | ||
"eslint-config-prettier": "^8.5.0", | ||
"eslint-plugin-jest": "^26.4.6", | ||
"eslint-plugin-prettier": "^4.0.0", | ||
"husky": "8.0.1", | ||
"jest": "^28.1.0", | ||
"lint-staged": "^13.0.0", | ||
"prettier": "^2.6.2", | ||
"rimraf": "^3.0.2", | ||
"rollup": "^2.75.5", | ||
"rollup-plugin-terser": "^7.0.2", | ||
"rollup-plugin-typescript2": "^0.32.0", | ||
"scripty": "^2.1.0", | ||
"semantic-release": "19.0.2", | ||
"@types/jest": "28.1.8", | ||
"@types/node": "18.11.9", | ||
"@typescript-eslint/eslint-plugin": "5.44.0", | ||
"@typescript-eslint/parser": "5.44.0", | ||
"commitizen": "4.2.5", | ||
"cz-conventional-changelog": "3.3.0", | ||
"eslint": "8.19.0", | ||
"eslint-config-prettier": "8.5.0", | ||
"eslint-plugin-jest": "26.5.3", | ||
"eslint-plugin-prettier": "4.2.1", | ||
"jest": "28.1.3", | ||
"lefthook": "1.2.2", | ||
"prettier": "2.7.1", | ||
"rimraf": "3.0.2", | ||
"rollup": "2.79.1", | ||
"rollup-plugin-terser": "7.0.2", | ||
"rollup-plugin-typescript2": "0.32.1", | ||
"scripty": "2.1.0", | ||
"semantic-release": "19.0.5", | ||
"size-limit": "7.0.8", | ||
"sort-package-json": "^1.57.0", | ||
"ts-jest": "^28.0.3", | ||
"ts-node": "^10.8.0", | ||
"sort-package-json": "1.57.0", | ||
"ts-jest": "28.0.5", | ||
"ts-node": "10.9.1", | ||
"tslib": "2.4.0", | ||
"typescript": "4.7.2" | ||
"typescript": "4.9.3" | ||
}, | ||
"peerDependencies": {}, | ||
"engines": { | ||
"node": ">=16" | ||
"node": ">=18" | ||
}, | ||
@@ -95,0 +92,0 @@ "publishConfig": { |
@@ -1,2 +0,2 @@ | ||
import { Dict, EntityDict, ObjectKey } from './types'; | ||
import { EntityDict, ObjectKey } from './types'; | ||
@@ -12,3 +12,3 @@ const groupBy = <K extends keyof T, T extends Record<K, T[K]>>( | ||
...result.entities, | ||
[item[key]]: [...(result.entities[item[key]] || []), item], | ||
[item[key]]: [result.entities[item[key]] || [], item].flat(), | ||
}, | ||
@@ -28,2 +28,2 @@ ids: [...new Set((result.ids || []).concat([item[key]]))], | ||
export { EntityDict, Dict }; | ||
export { EntityDict }; |
export type ObjectKey = string | number | symbol; | ||
export type EntityDict<E, Key = keyof E> = { | ||
entities: Record<keyof E, E> | Record<never, undefined>; | ||
export type EntityDict<E, Key extends ObjectKey> = { | ||
entities: Record<Key, E>; | ||
ids: Key[]; | ||
}; | ||
export type Dict<T> = keyof T extends string | ||
? Partial<{ | ||
[K in `by${Capitalize<keyof T>}`]: EntityDict<T>; | ||
}> | ||
: never; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
7586
42
110