{"_id":"@comfy/redux-selectors","_rev":"6-86916fb6ac80c582b8a8ab4c4d655132","name":"@comfy/redux-selectors","description":"Redux selectors","dist-tags":{"latest":"0.4.0"},"versions":{"0.3.0":{"name":"@comfy/redux-selectors","version":"0.3.0","description":"Redux selectors","main":"lib/redux-selectors.js","module":"es/redux-selectors.js","files":["dist","lib","es","src"],"scripts":{"clean":"rimraf lib dist es coverage","format":"prettier --write '{src,test}/**/*.js'","format:check":"prettier --list-different '{src,test}/**/*.js'","lint":"eslint src test build","pretest":"npm run build:commonjs","test":"cross-env BABEL_ENV=commonjs jest","test:watch":"npm test -- --watch","test:cov":"npm test -- --coverage","build:commonjs":"cross-env NODE_ENV=cjs rollup -c -o lib/redux-selectors.js","build:es":"cross-env BABEL_ENV=es NODE_ENV=es rollup -c -o es/redux-selectors.js","build:umd":"cross-env BABEL_ENV=es NODE_ENV=development rollup -c -o dist/redux-selectors.js","build:umd:min":"cross-env BABEL_ENV=es NODE_ENV=production rollup -c -o dist/redux-selectors.min.js","build":"npm run build:commonjs && npm run build:es && npm run build:umd && npm run build:umd:min","prepare":"npm run clean && npm run format:check && npm run lint && npm test && npm run build","examples:lint":"eslint examples","examples:test":"cross-env CI=true babel-node examples/testAll.js","docs:clean":"rimraf _book","docs:prepare":"gitbook install","docs:build":"npm run docs:prepare && gitbook build -g heygrady/redux-selectors","docs:watch":"npm run docs:prepare && gitbook serve","docs:publish":"npm run docs:clean && npm run docs:build && cd _book && git init && git commit --allow-empty -m 'update book' && git checkout -b gh-pages && touch .nojekyll && git add . && git commit -am 'update book' && git push git@github.com:heygrady/redux-selectors gh-pages --force"},"repository":{"type":"git","url":"git+https://github.com/heygrady/redux-selectors.git"},"keywords":["redux","selectors"],"authors":["Grady Kuhnline <github@heygrady.net> (https://github.com/heygrady)"],"license":"MIT","bugs":{"url":"https://github.com/heygrady/redux-selectors/issues"},"homepage":"http://redux-selectors.js.org","dependencies":{"loose-envify":"^1.1.0","symbol-observable":"^1.0.3"},"devDependencies":{"babel-cli":"^6.26.0","babel-core":"^6.26.0","babel-eslint":"^8.0.1","babel-jest":"^21.2.0","babel-plugin-external-helpers":"^6.22.0","babel-plugin-transform-object-rest-spread":"^6.26.0","babel-preset-env":"^1.6.1","babel-register":"^6.26.0","cross-env":"^5.1.0","eslint":"^4.9.0","eslint-config-prettier":"^2.9.0","eslint-config-react-app":"^2.0.1","eslint-config-standard":"^11.0.0-beta.0","eslint-config-standard-react":"^5.0.0","eslint-plugin-flowtype":"^2.39.1","eslint-plugin-import":"^2.2.0","eslint-plugin-jsx-a11y":"^5.1.1","eslint-plugin-node":"^5.2.1","eslint-plugin-promise":"^3.6.0","eslint-plugin-react":"^7.4.0","eslint-plugin-standard":"^3.0.1","gitbook-cli":"^2.3.2","gitbook-plugin-algolia":"^1.0.7","gitbook-plugin-anchorjs":"^1.1.1","gitbook-plugin-edit-link":"^2.0.2","gitbook-plugin-github":"^2.0.0","gitbook-plugin-prism":"^2.3.0","glob":"^7.1.1","jest":"^21.2.1","lodash.get":"^4.4.2","prettier":"1.8.2","redux":"^3.7.2","rimraf":"^2.6.2","rollup":"^0.51.8","rollup-plugin-babel":"^3.0.2","rollup-plugin-node-resolve":"^3.0.0","rollup-plugin-replace":"^2.0.0","rollup-plugin-uglify":"^2.0.1","rxjs":"^5.5.0","uglify-es":"^3.3.8"},"npmName":"@comfy/redux-selectors","npmFileMap":[{"basePath":"/dist/","files":["*.js"]}],"browserify":{"transform":["loose-envify"]},"jest":{"testRegex":"(/test/.*\\.spec.js)$"},"peerDependencies":{"lodash.get":"^4.4.2","redux":"^3.7.2"},"gitHead":"f250fa4f8a1a83a58625e5c91bfd76592158b661","_id":"@comfy/redux-selectors@0.3.0","_npmVersion":"5.5.1","_nodeVersion":"9.2.0","_npmUser":{"name":"heygrady","email":"github@heygrady.net"},"dist":{"integrity":"sha512-wwI8AKFsvPCgYeo13EIO1SonYZdZV9Pl5hA6kaMvep+IlnQrWL8ChorubuLbEDqcNvWZVFn1rqyrrCrN96A3OQ==","shasum":"4526119cad151f180234f8b121562285808f21bd","tarball":"https://registry.npmjs.org/@comfy/redux-selectors/-/redux-selectors-0.3.0.tgz","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIEhVHwR06TA7SdGaWruifgiCTLTHElQkFzt+UgzCN4B5AiEAqVwUY+Jn6LpVshG8zuJF/uD90WQ0q19iKdT5QXSduCQ="}]},"maintainers":[{"name":"heygrady","email":"github@heygrady.net"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/redux-selectors-0.3.0.tgz_1517786715367_0.3086070322897285"},"directories":{}},"0.3.1":{"name":"@comfy/redux-selectors","version":"0.3.1","description":"Redux selectors","main":"lib/redux-selectors.js","module":"es/redux-selectors.js","files":["dist","lib","es","src"],"scripts":{"clean":"rimraf lib dist es coverage","format":"prettier --write '{src,test}/**/*.js'","format:check":"prettier --list-different '{src,test}/**/*.js'","lint":"eslint src test build","pretest":"npm run build:commonjs","test":"cross-env BABEL_ENV=commonjs jest","test:watch":"npm test -- --watch","test:cov":"npm test -- --coverage","build:commonjs":"cross-env NODE_ENV=cjs rollup -c -o lib/redux-selectors.js","build:es":"cross-env BABEL_ENV=es NODE_ENV=es rollup -c -o es/redux-selectors.js","build:umd":"cross-env BABEL_ENV=es NODE_ENV=development rollup -c -o dist/redux-selectors.js","build:umd:min":"cross-env BABEL_ENV=es NODE_ENV=production rollup -c -o dist/redux-selectors.min.js","build":"npm run build:commonjs && npm run build:es && npm run build:umd && npm run build:umd:min","prepare":"npm run clean && npm run format:check && npm run lint && npm test && npm run build","examples:lint":"eslint examples","examples:test":"cross-env CI=true babel-node examples/testAll.js","docs:clean":"rimraf _book","docs:prepare":"gitbook install","docs:build":"npm run docs:prepare && gitbook build -g heygrady/redux-selectors","docs:watch":"npm run docs:prepare && gitbook serve","docs:publish":"npm run docs:clean && npm run docs:build && cd _book && git init && git commit --allow-empty -m 'update book' && git checkout -b gh-pages && touch .nojekyll && git add . && git commit -am 'update book' && git push git@github.com:heygrady/redux-selectors gh-pages --force"},"repository":{"type":"git","url":"git+https://github.com/heygrady/redux-selectors.git"},"keywords":["redux","selectors"],"authors":["Grady Kuhnline <github@heygrady.net> (https://github.com/heygrady)"],"license":"MIT","bugs":{"url":"https://github.com/heygrady/redux-selectors/issues"},"homepage":"https://heygrady.github.io/redux-selectors/","dependencies":{"loose-envify":"^1.1.0","symbol-observable":"^1.0.3"},"devDependencies":{"babel-cli":"^6.26.0","babel-core":"^6.26.0","babel-eslint":"^8.0.1","babel-jest":"^21.2.0","babel-plugin-external-helpers":"^6.22.0","babel-plugin-transform-object-rest-spread":"^6.26.0","babel-preset-env":"^1.6.1","babel-register":"^6.26.0","cross-env":"^5.1.0","eslint":"^4.9.0","eslint-config-prettier":"^2.9.0","eslint-config-react-app":"^2.0.1","eslint-config-standard":"^11.0.0-beta.0","eslint-config-standard-react":"^5.0.0","eslint-plugin-flowtype":"^2.39.1","eslint-plugin-import":"^2.2.0","eslint-plugin-jsx-a11y":"^5.1.1","eslint-plugin-node":"^5.2.1","eslint-plugin-promise":"^3.6.0","eslint-plugin-react":"^7.4.0","eslint-plugin-standard":"^3.0.1","gitbook-cli":"^2.3.2","gitbook-plugin-algolia":"^1.0.7","gitbook-plugin-anchorjs":"^1.1.1","gitbook-plugin-edit-link":"^2.0.2","gitbook-plugin-github":"^2.0.0","gitbook-plugin-prism":"^2.3.0","glob":"^7.1.1","jest":"^21.2.1","lodash.get":"^4.4.2","prettier":"1.8.2","redux":"^3.7.2","rimraf":"^2.6.2","rollup":"^0.51.8","rollup-plugin-babel":"^3.0.2","rollup-plugin-node-resolve":"^3.0.0","rollup-plugin-replace":"^2.0.0","rollup-plugin-uglify":"^2.0.1","rxjs":"^5.5.0","uglify-es":"^3.3.8"},"npmName":"@comfy/redux-selectors","npmFileMap":[{"basePath":"/dist/","files":["*.js"]}],"browserify":{"transform":["loose-envify"]},"jest":{"testRegex":"(/test/.*\\.spec.js)$"},"peerDependencies":{"lodash.get":"^4.4.2","redux":"^3.7.2"},"gitHead":"b34182f2c73534329bf30d64668ffb2094e181be","_id":"@comfy/redux-selectors@0.3.1","_npmVersion":"5.5.1","_nodeVersion":"9.2.0","_npmUser":{"name":"heygrady","email":"github@heygrady.net"},"dist":{"integrity":"sha512-VHuFTB6nBsketqobpV90V63Epp/4HegVlkod9p9k4LNPOYQ93QImrZtovAhyUWeLYqZOJ0oEEvRVPd42FmeV/A==","shasum":"a525640e04ac7f3a7a65926b9b06e9dd4eda0dd1","tarball":"https://registry.npmjs.org/@comfy/redux-selectors/-/redux-selectors-0.3.1.tgz","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCICibZiRCPa5W5uf86W9ux/UvfHkpXp4tSC0z4K1EBRggAiANoWUMXWTVbq2/GpS1Cx+Rbe5hOtE3Wy8MZ4EbHxshSQ=="}]},"maintainers":[{"name":"heygrady","email":"github@heygrady.net"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/redux-selectors-0.3.1.tgz_1517786799164_0.23789034015499055"},"directories":{}},"0.4.0":{"name":"@comfy/redux-selectors","version":"0.4.0","description":"Redux selectors","main":"lib/redux-selectors.js","module":"es/redux-selectors.js","files":["dist","lib","es","src"],"scripts":{"clean":"rimraf lib dist es coverage","format":"prettier --write '{src,test}/**/*.js'","format:check":"prettier --list-different '{src,test}/**/*.js'","lint":"eslint src test build","pretest":"npm run build:commonjs","test":"cross-env BABEL_ENV=commonjs jest","test:watch":"npm test -- --watch","test:cov":"npm test -- --coverage","build:commonjs":"cross-env NODE_ENV=cjs rollup -c -o lib/redux-selectors.js","build:es":"cross-env BABEL_ENV=es NODE_ENV=es rollup -c -o es/redux-selectors.js","build:umd":"cross-env BABEL_ENV=es NODE_ENV=development rollup -c -o dist/redux-selectors.js","build:umd:min":"cross-env BABEL_ENV=es NODE_ENV=production rollup -c -o dist/redux-selectors.min.js","build":"npm run build:commonjs && npm run build:es && npm run build:umd && npm run build:umd:min","prepare":"npm run clean && npm run format:check && npm run lint && npm test && npm run build","examples:lint":"eslint examples","examples:test":"cross-env CI=true babel-node examples/testAll.js","docs:clean":"rimraf _book","docs:prepare":"gitbook install","docs:build":"npm run docs:prepare && gitbook build -g heygrady/redux-selectors","docs:watch":"npm run docs:prepare && gitbook serve","docs:publish":"npm run docs:clean && npm run docs:build && cd _book && git init && git commit --allow-empty -m 'update book' && git checkout -b gh-pages && touch .nojekyll && git add . && git commit -am 'update book' && git push git@github.com:heygrady/redux-selectors gh-pages --force"},"repository":{"type":"git","url":"https://github.com/heygrady/redux-selectors.git"},"keywords":["redux","selectors"],"authors":["Grady Kuhnline <github@heygrady.net> (https://github.com/heygrady)"],"license":"MIT","bugs":{"url":"https://github.com/heygrady/redux-selectors/issues"},"homepage":"https://heygrady.github.io/redux-selectors/","dependencies":{"loose-envify":"^1.1.0","symbol-observable":"^1.0.3"},"devDependencies":{"babel-cli":"^6.26.0","babel-core":"^6.26.0","babel-eslint":"^8.0.1","babel-jest":"^21.2.0","babel-plugin-external-helpers":"^6.22.0","babel-plugin-transform-object-rest-spread":"^6.26.0","babel-preset-env":"^1.6.1","babel-register":"^6.26.0","cross-env":"^5.1.0","eslint":"^4.9.0","eslint-config-prettier":"^2.9.0","eslint-config-react-app":"^2.0.1","eslint-config-standard":"^11.0.0-beta.0","eslint-plugin-flowtype":"^2.39.1","eslint-plugin-import":"^2.2.0","eslint-plugin-jsx-a11y":"^5.1.1","eslint-plugin-node":"^5.2.1","eslint-plugin-prettier":"^2.6.0","eslint-plugin-promise":"^3.6.0","eslint-plugin-react":"^7.4.0","eslint-plugin-standard":"^3.0.1","gitbook-cli":"^2.3.2","gitbook-plugin-algolia":"^1.0.7","gitbook-plugin-anchorjs":"^1.1.1","gitbook-plugin-edit-link":"^2.0.2","gitbook-plugin-github":"^2.0.0","gitbook-plugin-prism":"^2.3.0","glob":"^7.1.1","jest":"^21.2.1","prettier":"1.8.2","redux":"^3.7.2","rimraf":"^2.6.2","rollup":"^0.51.8","rollup-plugin-babel":"^3.0.2","rollup-plugin-node-resolve":"^3.0.0","rollup-plugin-replace":"^2.0.0","rollup-plugin-uglify":"^2.0.1","rxjs":"^5.5.0","uglify-es":"^3.3.8"},"npmName":"@comfy/redux-selectors","npmFileMap":[{"basePath":"/dist/","files":["*.js"]}],"browserify":{"transform":["loose-envify"]},"jest":{"testPathIgnorePatterns":["/node_modules/","/_book/","/_fun/"],"testRegex":"(/test/.*\\.spec.js)$"},"peerDependencies":{"redux":"^3.7.2"},"_id":"@comfy/redux-selectors@0.4.0","dist":{"shasum":"792facff74ce2c962e741d59e1c988980fb6f595","tarball":"https://registry.npmjs.org/@comfy/redux-selectors/-/redux-selectors-0.4.0.tgz","fileCount":24,"unpackedSize":52729,"integrity":"sha512-v4+RbOUMGjxcXi9YX9XfrD78BlUbvBmBeolGH2YYjz0qpIvCqxbFZ1jP1LIaNdLFnm3jGVjl0uLJjjb4GUBfuQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIBzdhUlmOe6cued7r+M2bGtBOKMgHrxmONFB71Yj53F2AiBksMOTTDhWlymUphKJnzi7E3XiIMoiVfJ1z11y93d+Rg=="}]},"maintainers":[{"name":"heygrady","email":"github@heygrady.net"}],"_npmUser":{"name":"heygrady","email":"github@heygrady.net"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/redux-selectors_0.4.0_1519618257161_0.20925665014877848"},"_hasShrinkwrap":false}},"readme":"# Comfy Redux Selectors\n\nA suite of composable functions that make it very easy to work with selectors. This library is intended to be used with redux but it works for any situation where you need to read values from structured objects.\n\nRedux-selectors allows you to:\n\n- Easily create selectors from a path string\n- Easily memoize dependent selectors\n- Easily create configurable selectors\n- Plus: utility functions like [`combineSelectors`](/docs/api/combineSelectors.md) and [`composeSelectors`](/docs/api/composeSelectors.md) make it easy to stitch selectors together\n\n**Note:** If [reselect](https://github.com/reactjs/reselect) is working for you, keep using it. If you find yourself commonly bumping in \"missing features\" in reselect, keep reading.\n\n## Installation\n\n```bash\nyarn add @comfy/redux-selectors redux\n```\n\n**Note:** `composeSelectors` depends on `compose` from redux\n\n## Getting started\n\nThe main point of this library is to create selectors that will read from `state`. Here you can see an example of creating a \"path selector\" that will return the value of `state.fruit.apples`.\n\n```js\nimport { createSelector } from '@comfy/redux-selectors'\n\nconst selectApples = createSelector('fruit.apples')\n\n// ---\n\nconst state = {\n  fruit: { apples: 1, oranges: 2 }\n}\n\nselectApples(state) // => 1\n```\n\n## API\n\nDocs:\n- https://heygrady.github.io/redux-selectors/\n- https://github.com/heygrady/redux-selectors/tree/master/docs\n\nHere are the key functions:\n\n- [`createSelector(path)`](/docs/api/createSelector.md) or `createSelector(...selectors, resultsFunc)`\n- [`withOptions(creator, argsFilter)`](/docs/api/withOptions.md)\n- [`withProps(creator, ...propsSelectors)`](/docs/api/withProps.md)\n- [`withState(selector)`](/docs/api/withState.md)\n- [`combineSelectors(selectorMap)`](/docs/api/combineSelectors.md)\n- [`composeSelectors(...selectors)`](/docs/api/composeSelectors.md)\n- [`memoizeSelector(selector)`](/docs/api/memoizeSelector.md)\n\n## Examples\n\nFor each of the examples below, we'll be using the following structure for `state` and `ownProps`.\n\nWhy `state` and `ownProps`? Typically selectors are used to select values from `state` within a `mapStateToProps` function. React-redux provides a `connect` function which supplies `mapStateToProps` with the current redux `state` and the wrapper component's `ownProps`.\n\n```js\nconst state = {\n  department: {\n    produce: {\n      fruit: {\n        apples: [\n          { id: 1, size: 'big' }\n        ],\n        oranges: [\n          { id: 2, size: 'medium' }\n        ]\n      },\n      veggies: {\n        potatoes: [\n          { id: 3, size: 'small' }\n        ]\n      }\n    }\n  },\n  filter: { size: 'big' }\n}\nconst ownProps = { id: 1, type: 'apples' }\n```\n\n### Path selectors: `createSelector(path)`\n\nYou can create a selector from a path. Under the hood it uses `get(state, path)` (with the same API as [lodash `get`](https://lodash.com/docs/latest#get)) to read the value. The `get` function allows `path` to be either a string or an array. You can read more about [path selectors](/docs/usage/path-selectors.md) in the docs.\n\nPath selectors are not memoized.\n\n```js\nimport { createSelector } from '@comfy/redux-selectors'\n\nconst selectFirstApple = createSelector('department.produce.fruit.apples[0]')\nconst selectFirstPotato = createSelector(['department', 'produce', 'veggies', 'potatoes', 0])\n\nselectFirstApple(state) // => { id: 1, size: 'big' }\nselectFirstPotato(state) // => { id: 3, size: 'small' }\n```\n\nYou can also create a path selector by hand, using [`get(state, path)`](https://lodash.com/docs/#get).\n\n```js\nimport get from 'lodash.get'\n\nconst selectFirstOrange = state => get(state, 'department.produce.fruit.oranges[0]')\n\nselectFirstOrange(state) // => { id: 2, size: 'medium' }\n```\n\n### Dependent selectors: `createSelector(...selectors, resultsFunc)`\n\nYou can also combine many dependent selectors using a \"results function\". This is very similar to how reselect works. You can supply several selectors and the results will be fed into a final results function. You can see below that the `resultsFunc` receives an argument for each selector. You can read more about [dependent selectors](/docs/usage/dependent-selectors.md) in the docs.\n\nDependent selectors are memoized.\n\n```js\nimport { createSelector } from '@comfy/redux-selectors'\n\nconst selectAppleCount = createSelector('department.produce.fruit.apples.length')\n\nconst selectTotal = createSelector(\n  selectAppleCount, // selector\n  'department.produce.fruit.oranges.length', // path selector\n  state => state.department.produce.veggies.potatoes.length,\n  (apples, oranges, potatoes) => apples + oranges + potatoes // resultsFunc\n)\n\nselectTotal(state) // => 3\n```\n\n### Configurable selectors: `withOptions(creator)`\n\nSometimes you need to configure your selectors to make them more reusable. A configurable selector is a curried function that accepts configuration on the first call and state on the second. You can read more about [configurable selectors](/docs/usage/configurable-selectors.md) in the docs.\n\nConfigurable selectors are memoized.\n\n```js\nimport { composeSelectors, createSelector, withOptions } from '@comfy/redux-selectors'\n\nconst selectApples = createSelector('department.produce.fruit.apples')\nconst selectAppleById = withOptions(id => composeSelectors(\n  selectApples,\n  apples => apples.find(apple => apple.id === id)\n))\n\nselectAppleById(id)(state) // => { id: 1, size: 'big' }\n```\n\n###  Configurable selectors: `withProps(creator)`\n\nIt is recommendable to use `ownProps` to provide configuration for your selectors. Using [`withProps`](/docs/api/withProps.md) will create a selector that accepts both `state` ane `ownProps`. Under the hood, `withProps` is a thin wrapper around `withOptions`. There is an important memoization edge case that `withProps` will optimize for you. You can read more about [configurable selectors](/docs/usage/configurable-selectors.md) in the docs.\n\nConfigurable selectors are memoized.\n\n```js\nimport { composeSelectors, createSelector, withProps } from '@comfy/redux-selectors'\n\nconst selectFruit = createSelector('department.produce.fruit')\nconst selectFruitById = withProps(props => composeSelectors(\n  selectFruit,\n  props.type,\n  items => items.find(item => item.id === props.id)\n))\n\nselectFruitById(state, ownProps) // => { id: 1, size: 'big' }\n```\n\n### Configurable selector: using `state`\n\n```js\nconst selectSizeFilter = createSelector('filter.size')\nconst selectApples = createSelector('department.produce.fruit.apples')\nconst selectApplesBySize = withOptions(size => composeSelectors(\n  selectApples,\n  apples => apples.filter(apple => apple.size === size)\n))\nconst selectApplesBySizeFilter = state => composeSelectors(\n  selectSizeFilter,\n  selectApplesBySize,\n  selectFilteredApples => selectFilteredApples(state)\n)(state)\n\nselectApplesBySizeFilter(state) // => [{ id: 1, size: 'big' }]\n```\n\n### Using `mapStateToProps` and `withProps(creator)`\n\nIn cases where you are combining your selectors using `mapStateToProps`, you can use `withProps` to efficiently pass configuration from `ownProps` to selectors created with `withOptions`.\n\nYou can read more about [using `mapStateToProps`](/docs/usage/with-mapStateToProps.md) in the docs.\n\n```js\nimport { composeSelectors, createSelector, withOptions, withProps } from '@comfy/redux-selectors'\n\nconst selectApples = createSelector('department.produce.fruit.apples')\nconst selectAppleById = withOptions(id => composeSelectors(\n  selectApples,\n  apples => apples.find(apple => apple.id === id)\n))\n\nconst mapStateToProps = withProps(props => combineSelectors({\n  apple: selectAppleById(props.id)\n}))\n\nmapStateToProps(state, ownProps) // => { apple: { id: 1, size: 'big' } }\n```\n\n### Using `mapStateToProps` and `withState(selector)`\n\nSometimes you need to ensure that your selector function accepts only a single argument. If you are using react-redux's `connect` function, you will see a small performance boost by specifying `mapStateToProps` functions that only accept state. This tells `connect` to recompute your selectors only when `state` changes, ignoring `props` altogether.\n\nYou can read more about [using `mapStateToProps`](/docs/usage/with-mapStateToProps.md) in the docs.\n\n```js\nimport { withState } from '@comfy/redux-selectors'\n\nconst selectApples = createSelector('department.produce.fruit.apples')\nconst selectAppleById = withOptions(id => composeSelectors(\n  selectApples,\n  apples => apples.find(apple => apple.id === id)\n))\n\nconst mapStateToProps = withState(combineSelectors({\n  apple: selectAppleById(1)\n}))\n\nmapStateToProps(state, ownProps) // => { apple: { id: 1, size: 'big' } }\n```\n\n### Combining selectors: `combineSelectors(selectorMap)`\n\nYou can read more about [combining selectors for usage with `mapStateToProps`](/docs/usage/with-mapStateToProps.md) in the docs.\n\n```js\nimport { combineSelectors, composeSelectors, createSelector, withProps } from '@comfy/redux-selectors'\n\nconst selectFruit = createSelector('department.produce.fruit')\nconst selectFruitById = withProps(props => composeSelectors(\n  selectFruit,\n  props.type,\n  items => items.find(items => items.id === props.id)\n))\nconst selectFruitSize = composeSelectors(\n  selectFruitById,\n  'size'\n)\n\nconst mapStateToProps = combineSelectors({\n  size: selectFruitSize\n})\n\nmapStateToProps(state, ownProps) // => { size: 'big' }\n```\n\n### Composing selectors: `composeSelectors(...selectors)`\n\nYou can read more about [composing selectors](/docs/usage/composing-selectors.md) in the docs.\n\n```js\nimport { composeSelectors, createSelector, withOptions, withProps, withState } from '@comfy/redux-selectors'\n\nconst selectProduce = createSelector('department.produce')\nconst selectFruit = composeSelectors(selectProduce, 'fruit')\nconst selectApples = composeSelectors(selectFruit, 'apples')\nconst selectAppleById = withOptions(id => composeSelectors(\n  selectApples,\n  apples => apples.find(apple => apple.id === id)\n))\nconst selectFruitSize = withProps(props => composeSelectors(\n  withState(selectAppleById(props.id)),\n  'size'\n))\n\nselectFruitSize(state, ownProps) // => 'big'\n```\n","maintainers":[{"name":"heygrady","email":"github@heygrady.net"}],"time":{"modified":"2022-06-12T16:23:06.993Z","created":"2018-02-04T23:25:15.476Z","0.3.0":"2018-02-04T23:25:15.476Z","0.3.1":"2018-02-04T23:26:39.285Z","0.4.0":"2018-02-26T04:10:57.252Z"},"homepage":"https://heygrady.github.io/redux-selectors/","keywords":["redux","selectors"],"repository":{"type":"git","url":"https://github.com/heygrady/redux-selectors.git"},"bugs":{"url":"https://github.com/heygrady/redux-selectors/issues"},"license":"MIT","readmeFilename":"README.md"}