Socket
Socket
Sign inDemoInstall

re-reselect

Package Overview
Dependencies
Maintainers
1
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

re-reselect - npm Package Compare versions

Comparing version 0.0.0 to 0.1.0

3

CHANGELOG.md

@@ -0,2 +1,5 @@

# 0.1.0
- Allow resolver function to return keys of type number
# 0.0.0
- Initial release

2

es/index.js

@@ -16,3 +16,3 @@ import { createSelector } from 'reselect';

if (typeof cacheKey === 'string') {
if (typeof cacheKey === 'string' || typeof cacheKey === 'number') {
if (cache.hasOwnProperty(cacheKey) === false) {

@@ -19,0 +19,0 @@ cache[cacheKey] = createSelectorInstance.apply(undefined, funcs);

@@ -21,3 +21,3 @@ 'use strict';

if (typeof cacheKey === 'string') {
if (typeof cacheKey === 'string' || typeof cacheKey === 'number') {
if (cache.hasOwnProperty(cacheKey) === false) {

@@ -24,0 +24,0 @@ cache[cacheKey] = createSelectorInstance.apply(undefined, funcs);

{
"name": "re-reselect",
"version": "0.0.0",
"version": "0.1.0",
"description": "Memoize selectors and avoid recalculation between calls with different inputs",

@@ -13,2 +13,3 @@ "main": "lib/index.js",

"scripts": {
"test": "jest",
"clean": "rm -rf lib es",

@@ -18,4 +19,6 @@ "compile": "npm run clean && npm run compile:es && npm run compile:commonjs",

"compile:commonjs": "NODE_ENV=commonjs babel -d lib/ index.js",
"prepublish": "npm run compile",
"test": "jest"
"preversion": "npm test",
"version": "git add package.json",
"postversion": "git push && git push --tags",
"prepublish": "npm run compile"
},

@@ -22,0 +25,0 @@ "keywords": [

@@ -64,3 +64,3 @@ # Re-reselect [![Build Status][ci-img]][ci]

`resolver` is a custom function which receives the same arguments of final selector (in the example: `state`, `itemId`, `'dataX'`, `otherArgs`) and returns a `string`.
`resolver` is a custom function which receives the same arguments of final selector (in the example: `state`, `itemId`, `'dataX'`, `otherArgs`) and returns a `string` or `number`.

@@ -150,4 +150,6 @@ That said, I was able to configure `re-reselect` to create a map of selector using the 3rd argument as key:

`resolverFunction` is a function which receives the same arguments of your selectors (and `inputSelectors`) and *must return a string*. The resulting string is used as cache key to store/retrieve selector instances.
`resolverFunction` is a function which receives the same arguments of your selectors (and `inputSelectors`) and *must return a string or number*. The result is used as cache key to store/retrieve selector instances.
Cache keys of type `number` are treated like strings, since they are assigned to a JS object as arguments.
The resolver idea is inspired by [Lodash's .memoize](https://lodash.com/docs/4.17.4#memoize) util.

@@ -154,0 +156,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc