Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/reduxjs/reselect into git…
Browse files Browse the repository at this point in the history
…attributes
  • Loading branch information
aryaemami59 committed Jun 1, 2024
2 parents 546ef85 + 2d17a06 commit 92671f0
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "reselect",
"version": "5.1.0",
"version": "5.1.1",
"description": "Selectors for Redux.",
"main": "./dist/cjs/reselect.cjs",
"module": "./dist/reselect.legacy-esm.js",
Expand Down
2 changes: 1 addition & 1 deletion src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import type {
DevModeChecksExecutionInfo
} from './types'

export const NOT_FOUND = 'NOT_FOUND'
export const NOT_FOUND = /* @__PURE__ */ Symbol('NOT_FOUND')
export type NOT_FOUND_TYPE = typeof NOT_FOUND

/**
Expand Down
32 changes: 32 additions & 0 deletions test/lruMemoize.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,38 @@ describe(lruMemoize, () => {
expect(selector.resultFunc.clearCache).toBeUndefined()
})

test('cache miss identifier does not collide with state values', () => {
const state = ['NOT_FOUND', 'FOUND']

type State = typeof state

const createSelector = createSelectorCreator({
memoize: lruMemoize,
argsMemoize: lruMemoize
}).withTypes<State>()

const selector = createSelector(
[(state, id: number) => state[id]],
state => state,
{
argsMemoizeOptions: { maxSize: 10 },
memoizeOptions: { maxSize: 10 }
}
)

const firstResult = selector(state, 0)

expect(selector(state, 1)).toBe(selector(state, 1))

const secondResult = selector(state, 0)

expect(secondResult).toBe('NOT_FOUND')

expect(firstResult).toBe(secondResult)

expect(selector.recomputations()).toBe(2)
})

localTest(
'maxSize should default to 1 when set to a number that is less than 1',
({ state, store }) => {
Expand Down

0 comments on commit 92671f0

Please sign in to comment.