To be used as an extension to the reselect library.
npm install reselect-equality-check-n-parameters --save
// This creates a memoize function that will only check the first parameter
const equalityCheckFirstParam = equalityCheckNParamsCreator(1);
// Import createSelectorCreator from the reselect library passing it the memoize function
const createSelectorFirstParam = createSelectorCreator(equalityCheckFirstParam);
const selector = createSelectorFirstParam(
state => state.a,
state => state.b,
(a, b) => a + b
);
const state1 = {a: 1, b: 2};
selector(state1) // would be 3
// b will not be check for equality
// even if it has changed no new value will be calculated
const state2 = {a: 1, b: 4};
selector(state2) // would be 3
selector.recomputations() // would be 1
const state3 = {a: 2, b: 4};
selector(state3) // would be 6
npm test
runs the tests via karmanpm build
builds a UMD version for distribution with webpacknpm pre-publish
used when publishing to NPM
- Run tests
npm test
- Run build and check that your module was built (needs to be exported via index.ts to index.js)
- Install it into your project to test before publishing by running
npm install '/path-to-this/'
- Bump version in package.json following Semantic Versioning SemVer
- Tag the release commit in git:
git tag -a v0.1.5 -m "Published v0.1.5"
- Push the tags up to github:
git push origin --tags
- Publish
npm publish