File tree 3 files changed +34
-2
lines changed
3 files changed +34
-2
lines changed Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " reselect" ,
3
- "version" : " 5.1.0 " ,
3
+ "version" : " 5.1.1 " ,
4
4
"description" : " Selectors for Redux." ,
5
5
"main" : " ./dist/cjs/reselect.cjs" ,
6
6
"module" : " ./dist/reselect.legacy-esm.js" ,
Original file line number Diff line number Diff line change @@ -9,7 +9,7 @@ import type {
9
9
DevModeChecksExecutionInfo
10
10
} from './types'
11
11
12
- export const NOT_FOUND = 'NOT_FOUND'
12
+ export const NOT_FOUND = /* @__PURE__ */ Symbol ( 'NOT_FOUND' )
13
13
export type NOT_FOUND_TYPE = typeof NOT_FOUND
14
14
15
15
/**
Original file line number Diff line number Diff line change @@ -421,6 +421,38 @@ describe(lruMemoize, () => {
421
421
expect ( selector . resultFunc . clearCache ) . toBeUndefined ( )
422
422
} )
423
423
424
+ test ( 'cache miss identifier does not collide with state values' , ( ) => {
425
+ const state = [ 'NOT_FOUND' , 'FOUND' ]
426
+
427
+ type State = typeof state
428
+
429
+ const createSelector = createSelectorCreator ( {
430
+ memoize : lruMemoize ,
431
+ argsMemoize : lruMemoize
432
+ } ) . withTypes < State > ( )
433
+
434
+ const selector = createSelector (
435
+ [ ( state , id : number ) => state [ id ] ] ,
436
+ state => state ,
437
+ {
438
+ argsMemoizeOptions : { maxSize : 10 } ,
439
+ memoizeOptions : { maxSize : 10 }
440
+ }
441
+ )
442
+
443
+ const firstResult = selector ( state , 0 )
444
+
445
+ expect ( selector ( state , 1 ) ) . toBe ( selector ( state , 1 ) )
446
+
447
+ const secondResult = selector ( state , 0 )
448
+
449
+ expect ( secondResult ) . toBe ( 'NOT_FOUND' )
450
+
451
+ expect ( firstResult ) . toBe ( secondResult )
452
+
453
+ expect ( selector . recomputations ( ) ) . toBe ( 2 )
454
+ } )
455
+
424
456
localTest (
425
457
'maxSize should default to 1 when set to a number that is less than 1' ,
426
458
( { state, store } ) => {
You can’t perform that action at this time.
0 commit comments