Skip to content

Commit

Permalink
fix: make it support arrays and objects (#157)
Browse files Browse the repository at this point in the history
  • Loading branch information
dankreiger authored Apr 11, 2024
1 parent bc9197b commit 0ba0b2a
Show file tree
Hide file tree
Showing 22 changed files with 4,953 additions and 4,197 deletions.
3 changes: 2 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ dist
coverage
jest.config.ts
rollup.config.ts
docs
docs
tsup.config.ts
2 changes: 1 addition & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
"semi": true,
"singleQuote": true,
"trailingComma": "es5"
}
}
29 changes: 10 additions & 19 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,64 +7,55 @@

## [0.1.30](https://github.com/dankreiger/groop/compare/v0.1.29...v0.1.30) (2024-04-11)


### Bug Fixes

* export entitydict type ([#155](https://github.com/dankreiger/groop/issues/155)) ([e768a25](https://github.com/dankreiger/groop/commit/e768a25d9c5bd0a0918e2ef88905982e6f033e2b))
- export ArrayEntityDict type ([#155](https://github.com/dankreiger/groop/issues/155)) ([e768a25](https://github.com/dankreiger/groop/commit/e768a25d9c5bd0a0918e2ef88905982e6f033e2b))

## [0.1.29](https://github.com/dankreiger/groop/compare/v0.1.28...v0.1.29) (2024-04-11)


### Bug Fixes

* make arrays readonly ([#154](https://github.com/dankreiger/groop/issues/154)) ([a47054a](https://github.com/dankreiger/groop/commit/a47054adc62260e89006d2c3825250da02dc0ea5))
- make arrays readonly ([#154](https://github.com/dankreiger/groop/issues/154)) ([a47054a](https://github.com/dankreiger/groop/commit/a47054adc62260e89006d2c3825250da02dc0ea5))

## [0.1.28](https://github.com/dankreiger/groop/compare/v0.1.27...v0.1.28) (2022-11-27)


### Features

* **types:** export types ([#79](https://github.com/dankreiger/groop/issues/79)) ([eb64699](https://github.com/dankreiger/groop/commit/eb646991e6e979f628209ad4666bd7d15c34cdea))
- **types:** export types ([#79](https://github.com/dankreiger/groop/issues/79)) ([eb64699](https://github.com/dankreiger/groop/commit/eb646991e6e979f628209ad4666bd7d15c34cdea))

## [0.1.27](https://github.com/dankreiger/groop/compare/v0.1.26...v0.1.27) (2022-11-27)


### Features

* **perf:** up performance from quadratic to linear time ([#77](https://github.com/dankreiger/groop/issues/77)) ([6277380](https://github.com/dankreiger/groop/commit/62773806bf307434234319a225610aec9ed84bd1))
- **perf:** up performance from quadratic to linear time ([#77](https://github.com/dankreiger/groop/issues/77)) ([6277380](https://github.com/dankreiger/groop/commit/62773806bf307434234319a225610aec9ed84bd1))

## [0.1.26](https://github.com/dankreiger/groop/compare/v0.1.25...v0.1.26) (2022-11-26)


### Features

* **types:** make type more accurate ([#76](https://github.com/dankreiger/groop/issues/76)) ([62ebebf](https://github.com/dankreiger/groop/commit/62ebebf27993a42acc4c1f4ad7c4230d3fced190))
- **types:** make type more accurate ([#76](https://github.com/dankreiger/groop/issues/76)) ([62ebebf](https://github.com/dankreiger/groop/commit/62ebebf27993a42acc4c1f4ad7c4230d3fced190))

## [0.1.25](https://github.com/dankreiger/groop/compare/v0.1.24...v0.1.25) (2022-11-26)


### Bug Fixes

* update release config ([#75](https://github.com/dankreiger/groop/issues/75)) ([d3104ed](https://github.com/dankreiger/groop/commit/d3104ed6b1d44c68d8d7d93082f7931c9d5901f9))
- update release config ([#75](https://github.com/dankreiger/groop/issues/75)) ([d3104ed](https://github.com/dankreiger/groop/commit/d3104ed6b1d44c68d8d7d93082f7931c9d5901f9))

## [0.1.24](https://github.com/dankreiger/groop/compare/v0.1.23...v0.1.24) (2022-11-26)


### Bug Fixes

* update node for build and other ci scripts ([#64](https://github.com/dankreiger/groop/issues/64)) ([a3ef572](https://github.com/dankreiger/groop/commit/a3ef572f4b8d36f809fe8463894ae3e55037cb81))
- update node for build and other ci scripts ([#64](https://github.com/dankreiger/groop/issues/64)) ([a3ef572](https://github.com/dankreiger/groop/commit/a3ef572f4b8d36f809fe8463894ae3e55037cb81))

## [0.1.23](https://github.com/dankreiger/groop/compare/v0.1.22...v0.1.23) (2022-11-26)


### Bug Fixes

* **ci:** update workflows ([#62](https://github.com/dankreiger/groop/issues/62)) ([78aa62a](https://github.com/dankreiger/groop/commit/78aa62a9c9ddf6e822c3ef5dd08ef7b78f8386eb))
* update node and types ([#59](https://github.com/dankreiger/groop/issues/59)) ([1be1f4e](https://github.com/dankreiger/groop/commit/1be1f4ec183703fe82656bcdd786d8737aa765cd))
- **ci:** update workflows ([#62](https://github.com/dankreiger/groop/issues/62)) ([78aa62a](https://github.com/dankreiger/groop/commit/78aa62a9c9ddf6e822c3ef5dd08ef7b78f8386eb))
- update node and types ([#59](https://github.com/dankreiger/groop/issues/59)) ([1be1f4e](https://github.com/dankreiger/groop/commit/1be1f4ec183703fe82656bcdd786d8737aa765cd))

## [0.1.22](https://github.com/dankreiger/groop/compare/v0.1.21...v0.1.22) (2022-06-06)


### Bug Fixes

* docs: update readme woof ([#25](https://github.com/dankreiger/groop/issues/25)) ([d83dee5](https://github.com/dankreiger/groop/commit/d83dee575c74dd02df9cb708f4d7fa3b5893509a))
- docs: update readme woof ([#25](https://github.com/dankreiger/groop/issues/25)) ([d83dee5](https://github.com/dankreiger/groop/commit/d83dee575c74dd02df9cb708f4d7fa3b5893509a))
40 changes: 37 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@

Normalize an array of objects by a property.

Both lists and single objects can be normalized.

## Usage

```ts
import { createGroup } from '@dankreiger/groop';
import { createArrayGroup } from '@dankreiger/groop';

const listGroup = [
{ name: 'Dan', age: 5 },
Expand All @@ -14,7 +16,7 @@ const listGroup = [
{ name: 'Dan', age: 20 },
];

const byAge = createGroup('age');
const byAge = createArrayGroup('age');

byAge(listGroup);
/**
Expand Down Expand Up @@ -47,7 +49,7 @@ byAge(listGroup);
* }
*/

const byName = createGroup('name');
const byName = createArrayGroup('name');

byName(listGroup);

Expand All @@ -65,3 +67,35 @@ byName(listGroup);
* }
*/
```

```ts
import { createGroup } from '@dankreiger/groop';

const singleGroup = { name: 'Dan', age: 5 };

const byAge = createGroup('age');

byAge(singleGroup);

/**
* {
* entities: {
* '5': { name: 'Dan', age: 5 }
* },
* ids: [5]
* }
*/

const byName = createGroup('name');

byName(singleGroup);

/**
* {
* entities: {
* Dan: { name: 'Dan', age: 5 }
* },
* ids: ['Dan']
* }
*/
```
Loading

0 comments on commit 0ba0b2a

Please sign in to comment.