Skip to content
This repository has been archived by the owner on Jul 25, 2024. It is now read-only.

Commit

Permalink
feat!: version 2
Browse files Browse the repository at this point in the history
BREAKING CHANGE: use `reducersMap` instead of `reducerMap` in your `eggs`.
BREAKING CHANGE: use `StoreCreatorOptions` instead of `StoreCreatorSettings`.
BREAKING CHANGE: `ExtensionEventHandlers` was removed.
BREAKING CHANGE: use `keep` instead of `eternal` in `egg` object.
BREAKING CHANGE: use `CounterItem` instead of `CountedItem` for item of `counter`.
Another changes:
* refactor examples
* refactor tests
* remove `@ts-ignore`
* improve `jest-config`
* improve `rollup-plugin-filesize`
* add some info to `package.json`
* update `yarn`
  • Loading branch information
fostyfost committed Dec 4, 2021
1 parent 7ce290c commit 9b96c3d
Show file tree
Hide file tree
Showing 431 changed files with 5,641 additions and 6,280 deletions.
3 changes: 2 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ node_modules
.husky
.vercel
.yarn
.pnp.cjs
.pnp.js
.pnp.cjs
.pnp.loader.mjs
dist
coverage
file-size-cache
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ module.exports = {
extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended', 'prettier'],
plugins: ['@typescript-eslint', 'simple-import-sort', 'unicorn'],
rules: {
'unicorn/filename-case': 'error',
'no-use-before-define': 'off',
'@typescript-eslint/no-use-before-define': 'error',
'@typescript-eslint/consistent-type-imports': 'error',
Expand Down
5,038 changes: 1,983 additions & 3,055 deletions .pnp.cjs

Large diffs are not rendered by default.

249 changes: 249 additions & 0 deletions .pnp.loader.mjs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ yarn.lock
/.pnp
.pnp.cjs
.pnp.js
.pnp.loader.mjs

# testing
coverage
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
631 changes: 0 additions & 631 deletions .yarn/releases/yarn-3.0.2.cjs

This file was deleted.

768 changes: 768 additions & 0 deletions .yarn/releases/yarn-3.1.1.cjs

Large diffs are not rendered by default.

6 changes: 4 additions & 2 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ defaultSemverRangePrefix: ""

nodeLinker: pnp

# pnpEnableEsmLoader: false

packageExtensions:
"@endemolshinegroup/cosmiconfig-typescript-loader@3.0.2":
peerDependencies:
"typescript": "^4.3.5"
typescript: ^4.3.5

yarnPath: .yarn/releases/yarn-3.0.2.cjs
yarnPath: .yarn/releases/yarn-3.1.1.cjs
2 changes: 1 addition & 1 deletion LICENCE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2020 Fosty Fost
Copyright (c) 2021 Fosty Fost

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion SECURITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@

| Version | Supported |
| ------- | ------------------ |
| 1.x.x | :white_check_mark: |
| 2.x.x | :white_check_mark: |
31 changes: 25 additions & 6 deletions docs/core-counter.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,26 @@
# `getCounter([equalityCheck], [checkIsEternal])`
# `getCounter([equalityCheck], [keepCheck])`

This function allows you to create `counter` to count the additions of values.

```typescript
declare const getCounter: <T = unknown>(
equalityCheck?: (left: T, right: T) => boolean,
keepCheck?: (value: T) => boolean,
) => Counter<T>

interface Counter<T = unknown> {
getCount(item: T): number
getItems(): CounterItem<T>[]
add(item: T): void
remove(item: T): void
}

interface CounterItem<T> {
value: T
count: number
}
```

## Arguments

### `equalityCheck(left, right)`
Expand Down Expand Up @@ -41,13 +60,13 @@ myCounter.add(obj1) // count of obj1 is 2, count of obj2 is 1
myCounter.add(obj2) // count of obj1 is 2, count of obj2 is 2
```

### `checkIsEternal(value)`
### `keepCheck(value)`

Optional. This is a function that checks if `value` should be in `counter` forever. It is useful for cases when `value`
cannot be removed from `counter` for some reason. By default, it returns `false`.

```typescript
const defaultCheckIsEternal = () => false
const defaultKeepCheck = () => false
```

It accepts `value` of any type and returns `true` if the `value` should be in `counter` forever, otherwise, it
Expand All @@ -58,13 +77,13 @@ Example:
```typescript
import { getCounter } from '@redux-eggs/core'

const myCheckIsEternal = value => value.isEternal === true
const myKeepCheck = value => value.keep === true

const myCounter = getCounter(undefined, myCheckIsEternal)
const myCounter = getCounter(undefined, myKeepCheck)

const obj1 = {
id: 'aaa',
isEternal: true,
keep: true,
// ...
}

Expand Down
Loading

0 comments on commit 9b96c3d

Please sign in to comment.