@@ -37,12 +37,10 @@ function getDependencies(funcs) {
37
37
const dependencies = Array . isArray ( funcs [ 0 ] ) ? funcs [ 0 ] : funcs
38
38
39
39
if ( ! dependencies . every ( dep => typeof dep === 'function' ) ) {
40
- const dependencyTypes = dependencies . map (
41
- dep => typeof dep
42
- ) . join ( ', ' )
40
+ const dependencyTypes = dependencies . map ( dep => typeof dep ) . join ( ', ' )
43
41
throw new Error (
44
42
'Selector creators expect all input-selectors to be functions, ' +
45
- `instead received the following types: [${ dependencyTypes } ]`
43
+ `instead received the following types: [${ dependencyTypes } ]`
46
44
)
47
45
}
48
46
@@ -55,14 +53,11 @@ export function createSelectorCreator(memoize, ...memoizeOptions) {
55
53
const resultFunc = funcs . pop ( )
56
54
const dependencies = getDependencies ( funcs )
57
55
58
- const memoizedResultFunc = memoize (
59
- function ( ) {
60
- recomputations ++
61
- // apply arguments instead of spreading for performance.
62
- return resultFunc . apply ( null , arguments )
63
- } ,
64
- ...memoizeOptions
65
- )
56
+ const memoizedResultFunc = memoize ( function ( ) {
57
+ recomputations ++
58
+ // apply arguments instead of spreading for performance.
59
+ return resultFunc . apply ( null , arguments )
60
+ } , ...memoizeOptions )
66
61
67
62
// If a selector is called with the exact same arguments we don't need to traverse our dependencies again.
68
63
const selector = memoize ( function ( ) {
@@ -81,18 +76,22 @@ export function createSelectorCreator(memoize, ...memoizeOptions) {
81
76
selector . resultFunc = resultFunc
82
77
selector . dependencies = dependencies
83
78
selector . recomputations = ( ) => recomputations
84
- selector . resetRecomputations = ( ) => recomputations = 0
79
+ selector . resetRecomputations = ( ) => ( recomputations = 0 )
85
80
return selector
86
81
}
87
82
}
88
83
89
- export const createSelector = /* #__PURE__ */ createSelectorCreator ( defaultMemoize )
84
+ export const createSelector =
85
+ /* #__PURE__ */ createSelectorCreator ( defaultMemoize )
90
86
91
- export function createStructuredSelector ( selectors , selectorCreator = createSelector ) {
87
+ export function createStructuredSelector (
88
+ selectors ,
89
+ selectorCreator = createSelector
90
+ ) {
92
91
if ( typeof selectors !== 'object' ) {
93
92
throw new Error (
94
93
'createStructuredSelector expects first argument to be an object ' +
95
- `where each property is a selector, instead received a ${ typeof selectors } `
94
+ `where each property is a selector, instead received a ${ typeof selectors } `
96
95
)
97
96
}
98
97
const objectKeys = Object . keys ( selectors )
0 commit comments