
Research
2025 Report: Destructive Malware in Open Source Packages
Destructive malware is rising across open source registries, using delays and kill switches to wipe code, break builds, and disrupt CI/CD.
Memoized selector library
The motivation behind this library is to improve reselect usage to be more resilient and concise. By using the new way to construct selectors, you should be able to write selectors that are easier to combine with.
/* selectors.js
**
** You never call createSelector in your `selectors.js`
** import { createSelector } from 'reselect'
*/
const shopItemsSelector = state => state.shop.items
const taxPercentSelector = state => state.shop.taxPercent
// Notice how to use an array structure to describe a selector
const subtotalSelector = [
shopItemsSelector,
items => items.reduce((acc, item) => acc + item.value, 0)
]
const taxSelector = [
[subtotalSelector, taxPercentSelector],
(subtotal, taxPercent) => subtotal * (taxPercent / 100)
]
let exampleState = {
shop: {
taxPercent: 8,
items: [
{ name: 'apple', value: 1.20 },
{ name: 'orange', value: 0.95 },
]
}
}
// container.js
// On your view layer where the selectors actually get called
import createSelector from 're-select';
connect(createSelector({
subtotal: subtotalSelector, // 2.15
tax: taxSelector, // 0.172
}))
npm install re-select
This introduction will assume you have a basic understanding of reselect. The major difference between re-select and reselect is how you describe/combine a selector.
const getVisibilityFilter = (state) => state.visibilityFilter
const getTodos = (state) => state.todos
/*
const getVisibleTodosFilteredByKeyword = createSelector(
[ getVisibleTodos, getKeyword ],
(visibleTodos, keyword) => visibleTodos.filter(
todo => todo.text.includes(keyword)
)
)
*/
const filteredVisibleTodosSelector = [
[ getVisibleTodos, getKeyword ],
(visibleTodos, keyword) => visibleTodos.filter(
todo => todo.text.includes(keyword)
)
]
A very common selector shown in the example above. Instead of calling createSelector to create a selector function, you construct an array structure to describe a selector.
Let's take a closer look at how it works.
The selectors consisted of two parts.
The first element is an array of functions, each of which takes the store as input. The second element is a plain function, it takes the value of selectors in the first element as input. So the first argument it takes will be the result of getVisibleTodos and the second will be getKeyword. The Values of each element are cached so if the values of one element are the same as previous the following element will not get called and return the previously computed value. In this example, the second element function will not run until the result of getVisibleTodos or getKeyword changed.
On the previous example, all input selectors are functions. But they don't have to be.
const todoAuthorSelector = [
[filteredVisibleTodosSelector],
todos => todos.map(todo => todo.author)
]
A valid selector description can be a function, an array or a plain object(we'll see it later).
Let's implement the todoAuthorSelector without nested selectors this time.
const todoAuthorSelector = [
[ getVisibleTodos, getKeyword ],
(visibleTodos, keyword) => visibleTodos.filter(
todo => todo.text.includes(keyword)
),
todos => todos.map(todo => todo.author)
]
You can have even more element in a selector.
Like what we have known, each element is memorized and each element takes the previous as input.
You should also notice the second element have not been wrapped in []. It's fine, [] is optional when there is only one selector that is not an array.
When working on a react/redux project, it's a common pattern that selecting data from the redux store and passing it as props to a component. A selector might look like this:
const usernameSelector = state => state.user.name
const postsSelector = state => state.posts
connect(createSelector([
[usernameSelector, postsSelector],
(username, posts) => ({
username,
posts,
})
]))
It is when structured selectors come into play. Structured selectors are objects whose properties are a selector. A structured selector equivalent to above can be:
connect(createSelector({
username: usernameSelector,
posts: postsSelector,
}))
Takes one selector, return a memoized function.
A selector can be a function, an array or a plain object. It determines if the value has changed using reference equality(===).
Passing in an equalityCheck function, return a function that transforms a function to the memoized version.
createSelectorCreator takes a memoize function as input and returns a customized version of createSelector.
Here is an example for using Immutable.is as equalityCheck
import { is } from 'immutable'
import { createSelectorCreator, createMemoizor } from 're-select'
const createImmutableSelector = createSelectorCreator(createMemoizor(is))
MIT
FAQs
Memoized selector library
We found that re-select demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Research
Destructive malware is rising across open source registries, using delays and kill switches to wipe code, break builds, and disrupt CI/CD.

Security News
Socket CTO Ahmad Nassri shares practical AI coding techniques, tools, and team workflows, plus what still feels noisy and why shipping remains human-led.

Research
/Security News
A five-month operation turned 27 npm packages into durable hosting for browser-run lures that mimic document-sharing portals and Microsoft sign-in, targeting 25 organizations across manufacturing, industrial automation, plastics, and healthcare for credential theft.