Skip to content

Commit cd2bdfe

Browse files
committed
Merge branch 'main' of github.com:dai-shi/proxy-memoize
2 parents 36609b7 + e936cd6 commit cd2bdfe

File tree

1 file changed

+21
-21
lines changed

1 file changed

+21
-21
lines changed

README.md

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -9,26 +9,26 @@ Intuitive magical memoization library with Proxy and WeakMap
99

1010
## Project status
1111

12-
It's stable and production ready.
12+
It's stable and production-ready.
1313
As the technique behind it is a bit tricky with Proxy,
14-
there might still be some bugs especially with nested memoized selectors.
14+
there might still be some bugs, especially with nested memoized selectors.
1515

16-
> Note: Nesting memoized selectors is theoretically less performant.
16+
> Note: Nesting memoized selectors are theoretically less performant.
1717
1818
Our docs and examples are not very comprehensive,
1919
and contributions are welcome.
2020

2121
## Introduction
2222

23-
Immutability is pivotal in more than a few frameworks, like React and Redux. It enables simple-yet-efficient change detection in large nested data structures.
23+
Immutability is pivotal in more than a few frameworks, like React and Redux. It enables simple yet efficient change detection in large nested data structures.
2424

25-
JavaScript is a mutable language by default. Libraries like [immer](https://github.com/immerjs/immer) simplify *updating* immutable data strucutres.
25+
JavaScript is a mutable language by default. Libraries like [immer](https://github.com/immerjs/immer) simplify *updating* immutable data structures.
2626

27-
This library helps *deriving data* from immutable structures (AKA, selectors), efficiantly caching results for faster performance.
27+
This library helps *derive data* from immutable structures (AKA, selectors), efficiently caching results for faster performance.
2828

2929
This library utilizes Proxy and WeakMap, and provides memoization.
3030
The memoized function will re-evaluate the original function
31-
only if the used part of argument (object) is changed.
31+
only if the used part of the argument (object) is changed.
3232
It's intuitive in a sense and magical in another sense.
3333

3434
## How it works
@@ -38,7 +38,7 @@ it will wrap an input object with proxies (recursively, on demand)
3838
and invoke the function.
3939
When it's finished it will check what is "affected".
4040
The "affected" is a list of paths of the input object
41-
that are accessed during the function invocation.
41+
accessed during the function invocation.
4242

4343
Next time when it receives a new input object,
4444
it will check if values in "affected" paths are changed.
@@ -47,8 +47,8 @@ Otherwise, it will return a cached result.
4747

4848
The cache size is `1` by default, but configurable.
4949

50-
We have 2-tier cache mechanism.
51-
What is described so far is the second tier cache.
50+
We have a 2-tier cache mechanism.
51+
What is described so far is the second-tier cache.
5252

5353
The first tier cache is with WeakMap.
5454
It's a WeakMap of the input object and the result of function invocation.
@@ -57,7 +57,7 @@ There's no notion of cache size.
5757
In summary, there are two types of cache:
5858

5959
* tier-1: WeakMap based cache (size=infinity)
60-
* tier-2: Proxy based cache (size=1, configurable)
60+
* tier-2: Proxy-based cache (size=1, configurable)
6161

6262
## Install
6363

@@ -131,7 +131,7 @@ const Component = ({ id }) => {
131131

132132
### Using `size` option
133133

134-
The example above might seem tricky to create memoized selector in component.
134+
The example above might seem tricky to create a memoized selector in a component.
135135
Alternatively, we can use `size` option.
136136

137137
```jsx
@@ -201,7 +201,7 @@ This is to unwrap a proxy object and return an original object.
201201
It returns null if not relevant.
202202

203203
\[Notes]
204-
This function is for debugging purpose.
204+
This function is for debugging purposes.
205205
It's not supposed to be used in production and it's subject to change.
206206

207207
#### Examples
@@ -217,11 +217,11 @@ const fn = memoize(obj => {
217217

218218
### replaceNewProxy
219219

220-
This is to replace newProxy function in upstream library, proxy-compare.
220+
This is to replace newProxy function in an upstream library, proxy-compare.
221221
Use it at your own risk.
222222

223223
\[Notes]
224-
See related discussoin: <https://github.com/dai-shi/proxy-compare/issues/40>
224+
See related discussion: <https://github.com/dai-shi/proxy-compare/issues/40>
225225

226226
### memoize
227227

@@ -302,7 +302,7 @@ const fn = memoize(obj => {
302302

303303
We can't unwrap Set/Map or other non-plain objects.
304304
The problem is when `obj.a` is an object (which will be wrapped with a proxy)
305-
and touching its property will record the usage, which leads
305+
and touching its property will record the usage, which leads to
306306
unexpected behavior.
307307
If `obj.a` is a primitive value, there's no problem.
308308

@@ -325,7 +325,7 @@ const result2 = fn(state); // Ends up unexpected result
325325

326326
The input `obj` or the `state` must be immutable.
327327
The whole concept is built around the immutability.
328-
It's faily common in Redux and React,
328+
It's fairly common in Redux and React,
329329
but be careful if you are not familiar with the concept.
330330

331331
There's no workaround.
@@ -355,7 +355,7 @@ Note: this disables the tier-1 cache with WeakMap.
355355

356356
### Reselect
357357

358-
At a basic level, memoize can be substituted in for `createSelector`. Doing
358+
At a basic level, memoize can be substituted for `createSelector`. Doing
359359
so will return a selector function with proxy-memoize's built-in tracking
360360
of your state object.
361361

@@ -387,8 +387,8 @@ const state = {
387387
};
388388

389389
// reselect
390-
// If the .completed property changes inside state, the selector must be recalculated
391-
// even through none of the properties we care about changed. In react-redux, this
390+
// If the .completed property changes inside the state, the selector must be recalculated
391+
// even though none of the properties we care about changed. In react-redux, this
392392
// selector will result in additional UI re-renders or the developer to implement
393393
// selectorOptions.memoizeOptions.resultEqualityCheck
394394
createSelector(
@@ -400,7 +400,7 @@ createSelector(
400400

401401
// proxy-memozie
402402
// If the .completed property changes inside state, the selector does NOT change
403-
// this is because we track only the accessed property (todos.text) and can ignore
403+
// because we track only the accessed property (todos.text) and can ignore
404404
// the unrelated change
405405
const todoTextsSelector = memoize(state => state.todos.map(todo => todo.text));
406406
```

0 commit comments

Comments
 (0)