Skip to content

Commit 6d4ef17

Browse files
committed
Merge branch 'master' of https://github.com/reduxjs/reselect into codemod
2 parents 619f3f8 + 2d17a06 commit 6d4ef17

File tree

3 files changed

+34
-2
lines changed

3 files changed

+34
-2
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "reselect",
3-
"version": "5.1.0",
3+
"version": "5.1.1",
44
"description": "Selectors for Redux.",
55
"main": "./dist/cjs/reselect.cjs",
66
"module": "./dist/reselect.legacy-esm.js",

src/utils.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import type {
99
DevModeChecksExecutionInfo
1010
} from './types'
1111

12-
export const NOT_FOUND = 'NOT_FOUND'
12+
export const NOT_FOUND = /* @__PURE__ */ Symbol('NOT_FOUND')
1313
export type NOT_FOUND_TYPE = typeof NOT_FOUND
1414

1515
/**

test/lruMemoize.test.ts

+32
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,38 @@ describe(lruMemoize, () => {
421421
expect(selector.resultFunc.clearCache).toBeUndefined()
422422
})
423423

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+
424456
localTest(
425457
'maxSize should default to 1 when set to a number that is less than 1',
426458
({ state, store }) => {

0 commit comments

Comments
 (0)