refactor(memoizeN): extract support code out of closure (#7805)
This commit is contained in:
@@ -7,13 +7,14 @@ import memoize from "lodash/memoize"
|
||||
* storing the result based on the arguments provided to the memoized function.
|
||||
*/
|
||||
|
||||
const memoizeN = (fn, resolver = ((...args) => args)) => {
|
||||
const shallowArrayEquals = (a) => (b) => {
|
||||
return Array.isArray(a) && Array.isArray(b)
|
||||
&& a.length === b.length
|
||||
&& a.every((val, index) => val === b[index])
|
||||
}
|
||||
|
||||
const list = (...args) => args
|
||||
|
||||
class Cache extends Map {
|
||||
delete(key) {
|
||||
const keys = Array.from(this.keys())
|
||||
@@ -33,6 +34,7 @@ const memoizeN = (fn, resolver = ((...args) => args)) => {
|
||||
}
|
||||
}
|
||||
|
||||
const memoizeN = (fn, resolver = list) => {
|
||||
const { Cache: OriginalCache } = memoize
|
||||
memoize.Cache = Cache
|
||||
|
||||
|
||||
Reference in New Issue
Block a user