use-memo-map 0.0.0-main.e5a419d → 0.0.0-main.ec78c8b
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +12 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@ Memoizes calls to array map function similar to `React.useMemo`. Memoized result
|
|
|
4
4
|
|
|
5
5
|
## Background
|
|
6
6
|
|
|
7
|
-
tl;dr, `React.useMemo()`
|
|
7
|
+
tl;dr, `React.useMemo()` cache a single call. `useMemoAll()` cache multiple calls.
|
|
8
8
|
|
|
9
9
|
If you have a variable-length array and would like to cache `Array.map` like `useMemo`, you can use `useMemoAll` to cache all calls.
|
|
10
10
|
|
|
@@ -24,7 +24,9 @@ function useMemoMap<T = unknown, R = unknown>(
|
|
|
24
24
|
For example, converting a `number` array into a `string` array.
|
|
25
25
|
|
|
26
26
|
```ts
|
|
27
|
-
function useMemoMap(
|
|
27
|
+
function useMemoMap(
|
|
28
|
+
mapper: (item: number, index: -1, array: readonly number[]) => string
|
|
29
|
+
): (array: readonly number[]) => readonly string[];
|
|
28
30
|
```
|
|
29
31
|
|
|
30
32
|
## How to use
|
|
@@ -108,3 +110,11 @@ If you prefer mutable array, call `[...result]` to clone the array.
|
|
|
108
110
|
### Custom equality function
|
|
109
111
|
|
|
110
112
|
We use `Object.is` for equality check. You can provide a different equality check via `options.itemEquality`.
|
|
113
|
+
|
|
114
|
+
## Contributions
|
|
115
|
+
|
|
116
|
+
Like us? [Star](https://github.com/compulim/use-memo-map/stargazers) us.
|
|
117
|
+
|
|
118
|
+
Want to make it better? [File](https://github.com/compulim/use-memo-map/issues) us an issue.
|
|
119
|
+
|
|
120
|
+
Don't like something you see? [Submit](https://github.com/compulim/use-memo-map/pulls) a pull request.
|