Skip to content

Commit 19b4d3e

Browse files
committed
Better README layout
1 parent c99e6bf commit 19b4d3e

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

README.md

+11-5
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,8 @@ const memoized = memoize(fn, {
6060
})
6161
```
6262

63-
The custom cache should be an object containing a `create` method that returns an object implementing the following methods:
63+
The custom cache should be an object containing a `create` method that returns
64+
an object implementing the following methods:
6465
- `get`
6566
- `set`
6667
- `has`
@@ -111,8 +112,9 @@ npm run benchmark:compare 53fa9a62214e816cf8b5b4fa291c38f1d63677b9
111112

112113
#### Spread arguments
113114

114-
We check for `function.length` to get upfront the expected number of arguments in order to use
115-
the fastest strategy. But with spread arguments we don't receive the right number.
115+
We check for `function.length` to get upfront the expected number of arguments
116+
in order to use the fastest strategy. But with spread arguments we don't receive
117+
the right number.
116118

117119
```js
118120
function multiply (multiplier, ...theArgs) {
@@ -133,9 +135,13 @@ const memoizedMultiply = memoize(multiply, {
133135

134136
#### Function Arguments
135137

136-
The default serializer uses `JSON.stringify` which will serialize functions as `null`. This means that if you are passing any functions as arguments you will get the same output regardless of whether you pass in different functions or indeed no function at all. The cache key generated will always be the same. To get around this you can give each function a unique ID and use that.
138+
The default serializer uses `JSON.stringify` which will serialize functions as
139+
`null`. This means that if you are passing any functions as arguments you will
140+
get the same output regardless of whether you pass in different functions or
141+
indeed no function at all. The cache key generated will always be the same. To
142+
get around this you can give each function a unique ID and use that.
137143

138-
```
144+
```js
139145
let id = 0
140146
function memoizedId(x) {
141147
if (!x.__memoizedId) x.__memoizedId = ++id

0 commit comments

Comments
 (0)