Update dependency memoize-one to v6 #352
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR contains the following updates:
^5.2.1
->^6.0.0
Release Notes
alexreardon/memoize-one
v6.0.0
Compare Source
At a glance
🧹 New
.clear()
function to remove the current memoization cache🏋️♀️ Stronger types
🥰 Improved documentation
This release is a
major
, but there are no behaviour or API changes. Themajor
is to reflect that some of theTypeScript
types have been tightened which might cause some peoplesTypeScript
builds to break.New: Cache releasing with
.clear()
🧹A
.clear()
property is now added to memoized functions to allow you to clear it's memoization cacheThis is helpful if you want to:
Improved: memoized function
type
Our previous
type
for a memoized function was simple:Previous
A memoized function claimed to be the same type (
ResultFn
) as the original function. This was not true, asmemoize-one
does not copy of any existing object properties on the original function (TFunc
)Updated
A memoized function returns the same callable signature as the original function (
TFunc
→ wasResultFn
), but it makes it clear that no function object properties on the original function (TFunc
) are being carried forward. The memoized function also now includes a.clear()
function object propertyIf you want to continue to use the old types where the memoized function is the same type as the function being memoized, you can achieve this by casting the type of your memoized function:
Improved: equality function
type
Previous
Current
This looks a little scary, but it is pretty neat! It means that you can dramatically improve the type safety of your custom equality functions if you want to.
If you are not using a custom equality function
No changes for you!
If you are using a custom equality function
Most people will not be impacted!
This type tightening allows you to be a lot stricter with the shape of your functions passed in as equality functions. If you are using generic equality functions such as
lodash.isequal
their types are loose and there is nothing you will need to do. But if you want to write more efficient and typesafe equality functions, you are in for a treat.An example of what things looked like in 5.x
→ You can play with this example on codesandbox.io
The same example in 6.x
→ You can play with this example on codesandbox.io
Improved: Documentation
.clear()
.length
propertyInternal code health
[email protected]
devDependencies
Thanks ❤️
Thanks so much to the following people who helped make this release possible:
Catch you next time,
Configuration
📅 Schedule: "before 7am on Tuesday" in timezone Australia/Sydney.
🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.
♻ Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.
🔕 Ignore: Close this PR and you won't be reminded about this update again.
This PR has been generated by WhiteSource Renovate. View repository job log here.