This commit is contained in:
Yamozha
2021-04-02 02:24:13 +03:00
parent c23950b545
commit 7256d79e2c
31493 changed files with 3036630 additions and 0 deletions

294
node_modules/reselect/CHANGELOG.md generated vendored Normal file
View File

@ -0,0 +1,294 @@
# Change log
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).
## [v3.0.0](https://github.com/reactjs/reselect/releases/tag/v3.0.0) - 2017/03/24
### New Features
Performance improvements (thanks to @johnhaley81)
Updated Typescript typings (thanks to everyone who helped)
### Breaking Changes
For performance reasons, a selector is now not recalculated if its input is equal by reference (`===`).
#### Example:
```js
import { createSelector } from 'reselect';
const mySelector = createSelector(
state => state.values.filter(val => val < 5),
values => {
console.log('calling..')
return values.reduce((acc, val) => acc + val, 0)
}
)
var createSelector = require('./dist/reselect.js').createSelector;
const mySelector = createSelector(
state => state.values.filter(val => val < 5),
values => {
console.log('calling..')
return values.reduce((acc, val) => acc + val, 0)
}
)
var state1 = {values: [1,2,3,4,5,6,7,8,9]};
console.log(mySelector(state1));
state1.values = [3,4,5,6,7,8,9];
console.log(mySelector(state1));
var state2 = {values: [1,2,3,4,5,6,7,8,9]};
console.log(mySelector(state2));
var state3 = {values: [3,4,5,6,7]};
console.log(mySelector(state3));
```
#### Output in v2.5.4:
```
calling..
10
calling..
7
calling..
10
calling..
7
```
#### Output in v3.0.0:
```
calling..
10
10
calling..
10
calling..
7
```
## [v2.5.4](https://github.com/reactjs/reselect/releases/tag/v2.5.4) - 2016/09/17
### Bug Fixes
Improve performance of `defaultMemoize` when using custom equality check. (#170)
## [v2.5.3](https://github.com/reactjs/reselect/releases/tag/v2.5.3) - 2016/07/04
### Bug Fixes
Reverts a Typescript change that was a breaking change. It will be reinstated in a major release. (#145)
## [v2.5.2](https://github.com/reactjs/reselect/releases/tag/v2.5.2) - 2016/07/03
### Bug Fixes
When a selector uses defaultMemoize, if an exception is thrown for a set of arguments then the selector should also throw when called again with those arguments. (#144)
## [v2.5.1](https://github.com/reactjs/reselect/releases/tag/v2.5.1) - 2016/04/21
### Bug Fixes
Include es directory in package.json (#117)
## [v2.5.0](https://github.com/reactjs/reselect/releases/tag/v2.5.0) - 2016/04/21
### New features
Add jsnext build (#116)
## [v2.4.0](https://github.com/reactjs/reselect/releases/tag/v2.4.0) - 2016/04/16
### New features
Add umd build (#112)
## [v2.3.0](https://github.com/reactjs/reselect/releases/tag/v2.3.0) - 2016/04/07
### New features
Add `resultFunc` property to selectors (#92)
## [v2.2.0](https://github.com/reactjs/reselect/releases/tag/v2.2.0) - 2016/03/15
### New features
Add Typescript typings to package.json (#94)
## [v2.1.0](https://github.com/reactjs/reselect/releases/tag/v2.1.0) - 2016/03/03
### New features
Add `resetRecomputations` method to selectors (#90)
## [v2.0.3](https://github.com/reactjs/reselect/releases/tag/v2.0.3) - 2016/02/01
### New features
Fix bug (#78) in `defaultMemoize` which could cause the memoized value to be mistakenly returned for variadic functions.
## [v2.0.2](https://github.com/reactjs/reselect/releases/tag/v2.0.2) - 2016/01/14
### New features
Fix IE8 support by compiling in 'loose' mode
## [v2.0.1](https://github.com/reactjs/reselect/releases/tag/v2.0.1) - 2015/11/08
### Chore
Update README and github links since move to reactjs.
## [v2.0.0](https://github.com/reactjs/reselect/releases/tag/v2.0.0) - 2015/10/02
### Breaking Changes
#### `createSelector`, `createStructuredSelector`, and custom selector creators check arguments
Input selectors are now verified to be functions during selector creation. If verification fails an error is thrown, allowing for a useful stack trace
There is a small chance that this could cause a breaking change in code that contains a faulty selector that is never called.
## [v1.1.0](https://github.com/reactjs/reselect/releases/tag/v1.1.0) - 2015/09/16
### New features
#### `createStructuredSelector`
`createStructuredSelector` is a convenience function that helps with a common pattern when using Reselect. The selector passed to a connect decorator often just takes other selectors and maps them to keys in an object:
```js
const mySelectorA = state => state.a;
const mySelectorB = state => state.b;
const structuredSelector = createSelector(
mySelectorA,
mySelectorB,
mySelectorC,
(a, b, c) => ({
a,
b,
c
})
);
```
`createStructuredSelector` takes an object whose properties are input-selectors and returns a structured selector. The structured selector returns an object with the same keys as the `inputSelectors` argument, but with the selectors replaced with their values.
```js
const mySelectorA = state => state.a;
const mySelectorB = state => state.b;
const structuredSelector = createStructuredSelector({
x: mySelectorA,
y: mySelectorB
});
const result = structuredSelector({a: 1, b: 2}); // will produce {x: 1, y: 2}
```
## [v1.0.0](https://github.com/reactjs/reselect/releases/tag/v1.0.0) - 2015/09/09
### Breaking Changes
If upgrading from 0.0.2, see the release notes for v1.0.0-alpha
## [v1.0.0-alpha2](https://github.com/reactjs/reselect/releases/tag/v1.0.0-alpha2) - 2015/09/01
### New features
src directory included in npm package
js:next field added to package.json
## [v1.0.0-alpha](https://github.com/reactjs/reselect/releases/tag/v1.0.0-alpha) - 2015/09/01
### Breaking Changes
`createSelectorCreator` takes a user specified memoize function instead of a custom `valueEqualsFunc`.
#### Before
```js
import { isEqual } from 'lodash';
import { createSelectorCreator } from 'reselect';
const deepEqualsSelectorCreator = createSelectorCreator(isEqual);
```
#### After
```js
import { isEqual } from 'lodash';
import { createSelectorCreator, defaultMemoize } from 'reselect';
const deepEqualsSelectorCreator = createSelectorCreator(
defaultMemoize,
isEqual
);
```
### New features
#### Variadic Dependencies
Selector creators can receive a variadic number of dependencies as well as an array of dependencies.
#### Before
```js
const selector = createSelector(
[state => state.a, state => state.b],
(a, b) => a * b
);
```
#### After
```js
const selector = createSelector(
state => state.a,
state => state.b,
(a, b) => a * b
);
```
#### Access `ownProps` in Selector
Selector dependencies can receive a variadic number of parameters allowing a selector to receive `ownProps` passed from `mapToProps` in `connect`.
```js
const selector = createSelector(
(state) => state.a,
(state, props) => state.b * props.c,
(_, props) => props.d,
(a, bc, d) => a + bc + d
);
```
#### Configurable Memoize Function
```js
import { createSelectorCreator } from 'reselect';
import memoize from 'lodash.memoize';
let called = 0;
const customSelectorCreator = createSelectorCreator(memoize, JSON.stringify);
const selector = customSelectorCreator(
state => state.a,
state => state.b,
(a, b) => {
called++;
return a + b;
}
);
assert.equal(selector({a: 1, b: 2}), 3);
assert.equal(selector({a: 1, b: 2}), 3);
assert.equal(called, 1);
assert.equal(selector({a: 2, b: 3}), 5);
assert.equal(called, 2);
```

21
node_modules/reselect/LICENSE generated vendored Normal file
View File

@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2015-2016 Reselect Contributors
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

972
node_modules/reselect/README.md generated vendored Normal file
View File

@ -0,0 +1,972 @@
# Reselect
[![Travis][build-badge]][build]
[![npm package][npm-badge]][npm]
[![Coveralls][coveralls-badge]][coveralls]
Simple “selector” library for Redux inspired by getters in [NuclearJS](https://github.com/optimizely/nuclear-js.git), [subscriptions](https://github.com/Day8/re-frame#just-a-read-only-cursor) in [re-frame](https://github.com/Day8/re-frame) and this [proposal](https://github.com/gaearon/redux/pull/169) from [speedskater](https://github.com/speedskater).
* Selectors can compute derived data, allowing Redux to store the minimal possible state.
* Selectors are efficient. A selector is not recomputed unless one of its arguments change.
* Selectors are composable. They can be used as input to other selectors.
```js
import { createSelector } from 'reselect'
const shopItemsSelector = state => state.shop.items
const taxPercentSelector = state => state.shop.taxPercent
const subtotalSelector = createSelector(
shopItemsSelector,
items => items.reduce((acc, item) => acc + item.value, 0)
)
const taxSelector = createSelector(
subtotalSelector,
taxPercentSelector,
(subtotal, taxPercent) => subtotal * (taxPercent / 100)
)
export const totalSelector = createSelector(
subtotalSelector,
taxSelector,
(subtotal, tax) => ({ total: subtotal + tax })
)
let exampleState = {
shop: {
taxPercent: 8,
items: [
{ name: 'apple', value: 1.20 },
{ name: 'orange', value: 0.95 },
]
}
}
console.log(subtotalSelector(exampleState)) // 2.15
console.log(taxSelector(exampleState)) // 0.172
console.log(totalSelector(exampleState)) // { total: 2.322 }
```
## Table of Contents
- [Installation](#installation)
- [Example](#example)
- [Motivation for Memoized Selectors](#motivation-for-memoized-selectors)
- [Creating a Memoized Selector](#creating-a-memoized-selector)
- [Composing Selectors](#composing-selectors)
- [Connecting a Selector to the Redux Store](#connecting-a-selector-to-the-redux-store)
- [Accessing React Props in Selectors](#accessing-react-props-in-selectors)
- [Sharing Selectors with Props Across Multiple Components](#sharing-selectors-with-props-across-multiple-components)
- [API](#api)
- [`createSelector`](#createselectorinputselectors--inputselectors-resultfunc)
- [`defaultMemoize`](#defaultmemoizefunc-equalitycheck--defaultequalitycheck)
- [`createSelectorCreator`](#createselectorcreatormemoize-memoizeoptions)
- [`createStructuredSelector`](#createstructuredselectorinputselectors-selectorcreator--createselector)
- [FAQ](#faq)
- [Why isn't my selector recomputing when the input state changes?](#q-why-isnt-my-selector-recomputing-when-the-input-state-changes)
- [Why is my selector recomputing when the input state stays the same?](#q-why-is-my-selector-recomputing-when-the-input-state-stays-the-same)
- [Can I use Reselect without Redux?](#q-can-i-use-reselect-without-redux)
- [The default memoization function is no good, can I use a different one?](#q-the-default-memoization-function-is-no-good-can-i-use-a-different-one)
- [How do I test a selector?](#q-how-do-i-test-a-selector)
- [How do I create a selector that takes an argument? ](#q-how-do-i-create-a-selector-that-takes-an-argument)
- [How do I use Reselect with Immutable.js?](#q-how-do-i-use-reselect-with-immutablejs)
- [Can I share a selector across multiple components?](#q-can-i-share-a-selector-across-multiple-components)
- [Are there TypeScript typings?](#q-are-there-typescript-typings)
- [How can I make a curried selector?](#q-how-can-i-make-a-curried-selector)
- [Related Projects](#related-projects)
- [License](#license)
## Installation
npm install reselect
## Example
### Motivation for Memoized Selectors
> The examples in this section are based on the [Redux Todos List example](http://redux.js.org/docs/basics/UsageWithReact.html).
#### `containers/VisibleTodoList.js`
```js
import { connect } from 'react-redux'
import { toggleTodo } from '../actions'
import TodoList from '../components/TodoList'
const getVisibleTodos = (todos, filter) => {
switch (filter) {
case 'SHOW_ALL':
return todos
case 'SHOW_COMPLETED':
return todos.filter(t => t.completed)
case 'SHOW_ACTIVE':
return todos.filter(t => !t.completed)
}
}
const mapStateToProps = (state) => {
return {
todos: getVisibleTodos(state.todos, state.visibilityFilter)
}
}
const mapDispatchToProps = (dispatch) => {
return {
onTodoClick: (id) => {
dispatch(toggleTodo(id))
}
}
}
const VisibleTodoList = connect(
mapStateToProps,
mapDispatchToProps
)(TodoList)
export default VisibleTodoList
```
In the above example, `mapStateToProps` calls `getVisibleTodos` to calculate `todos`. This works great, but there is a drawback: `todos` is calculated every time the component is updated. If the state tree is large, or the calculation expensive, repeating the calculation on every update may cause performance problems. Reselect can help to avoid these unnecessary recalculations.
### Creating a Memoized Selector
We would like to replace `getVisibleTodos` with a memoized selector that recalculates `todos` when the value of `state.todos` or `state.visibilityFilter` changes, but not when changes occur in other (unrelated) parts of the state tree.
Reselect provides a function `createSelector` for creating memoized selectors. `createSelector` takes an array of input-selectors and a transform function as its arguments. If the Redux state tree is mutated in a way that causes the value of an input-selector to change, the selector will call its transform function with the values of the input-selectors as arguments and return the result. If the values of the input-selectors are the same as the previous call to the selector, it will return the previously computed value instead of calling the transform function.
Let's define a memoized selector named `getVisibleTodos` to replace the non-memoized version above:
#### `selectors/index.js`
```js
import { createSelector } from 'reselect'
const getVisibilityFilter = (state) => state.visibilityFilter
const getTodos = (state) => state.todos
export const getVisibleTodos = createSelector(
[ getVisibilityFilter, getTodos ],
(visibilityFilter, todos) => {
switch (visibilityFilter) {
case 'SHOW_ALL':
return todos
case 'SHOW_COMPLETED':
return todos.filter(t => t.completed)
case 'SHOW_ACTIVE':
return todos.filter(t => !t.completed)
}
}
)
```
In the example above, `getVisibilityFilter` and `getTodos` are input-selectors. They are created as ordinary non-memoized selector functions because they do not transform the data they select. `getVisibleTodos` on the other hand is a memoized selector. It takes `getVisibilityFilter` and `getTodos` as input-selectors, and a transform function that calculates the filtered todos list.
### Composing Selectors
A memoized selector can itself be an input-selector to another memoized selector. Here is `getVisibleTodos` being used as an input-selector to a selector that further filters the todos by keyword:
```js
const getKeyword = (state) => state.keyword
const getVisibleTodosFilteredByKeyword = createSelector(
[ getVisibleTodos, getKeyword ],
(visibleTodos, keyword) => visibleTodos.filter(
todo => todo.text.indexOf(keyword) > -1
)
)
```
### Connecting a Selector to the Redux Store
If you are using [React Redux](https://github.com/reactjs/react-redux), you can call selectors as regular functions inside `mapStateToProps()`:
#### `containers/VisibleTodoList.js`
```js
import { connect } from 'react-redux'
import { toggleTodo } from '../actions'
import TodoList from '../components/TodoList'
import { getVisibleTodos } from '../selectors'
const mapStateToProps = (state) => {
return {
todos: getVisibleTodos(state)
}
}
const mapDispatchToProps = (dispatch) => {
return {
onTodoClick: (id) => {
dispatch(toggleTodo(id))
}
}
}
const VisibleTodoList = connect(
mapStateToProps,
mapDispatchToProps
)(TodoList)
export default VisibleTodoList
```
### Accessing React Props in Selectors
> This section introduces a hypothetical extension to our app that allows it to support multiple Todo Lists. Please note that a full implementation of this extension requires changes to the reducers, components, actions etc. that arent directly relevant to the topics discussed and have been omitted for brevity.
So far we have only seen selectors receive the Redux store state as an argument, but a selector can receive props too.
Here is an `App` component that renders three `VisibleTodoList` components, each of which has a `listId` prop:
#### `components/App.js`
```js
import React from 'react'
import Footer from './Footer'
import AddTodo from '../containers/AddTodo'
import VisibleTodoList from '../containers/VisibleTodoList'
const App = () => (
<div>
<VisibleTodoList listId="1" />
<VisibleTodoList listId="2" />
<VisibleTodoList listId="3" />
</div>
)
```
Each `VisibleTodoList` container should select a different slice of the state depending on the value of the `listId` prop, so lets modify `getVisibilityFilter` and `getTodos` to accept a props argument:
#### `selectors/todoSelectors.js`
```js
import { createSelector } from 'reselect'
const getVisibilityFilter = (state, props) =>
state.todoLists[props.listId].visibilityFilter
const getTodos = (state, props) =>
state.todoLists[props.listId].todos
const getVisibleTodos = createSelector(
[ getVisibilityFilter, getTodos ],
(visibilityFilter, todos) => {
switch (visibilityFilter) {
case 'SHOW_COMPLETED':
return todos.filter(todo => todo.completed)
case 'SHOW_ACTIVE':
return todos.filter(todo => !todo.completed)
default:
return todos
}
}
)
export default getVisibleTodos
```
`props` can be passed to `getVisibleTodos` from `mapStateToProps`:
```js
const mapStateToProps = (state, props) => {
return {
todos: getVisibleTodos(state, props)
}
}
```
So now `getVisibleTodos` has access to `props`, and everything seems to be working fine.
**But there is a problem!**
Using the `getVisibleTodos` selector with multiple instances of the `VisibleTodoList` container will not correctly memoize:
#### `containers/VisibleTodoList.js`
```js
import { connect } from 'react-redux'
import { toggleTodo } from '../actions'
import TodoList from '../components/TodoList'
import { getVisibleTodos } from '../selectors'
const mapStateToProps = (state, props) => {
return {
// WARNING: THE FOLLOWING SELECTOR DOES NOT CORRECTLY MEMOIZE
todos: getVisibleTodos(state, props)
}
}
const mapDispatchToProps = (dispatch) => {
return {
onTodoClick: (id) => {
dispatch(toggleTodo(id))
}
}
}
const VisibleTodoList = connect(
mapStateToProps,
mapDispatchToProps
)(TodoList)
export default VisibleTodoList
```
A selector created with `createSelector` has a cache size of 1 and only returns the cached value when its set of arguments is the same as its previous set of arguments. If we alternate between rendering `<VisibleTodoList listId="1" />` and `<VisibleTodoList listId="2" />`, the shared selector will alternate between receiving `{listId: 1}` and `{listId: 2}` as its `props` argument. This will cause the arguments to be different on each call, so the selector will always recompute instead of returning the cached value. Well see how to overcome this limitation in the next section.
### Sharing Selectors with Props Across Multiple Components
> The examples in this section require React Redux v4.3.0 or greater
> An alternative approach be found in [re-reselect](https://github.com/toomuchdesign/re-reselect)
To share a selector across multiple `VisibleTodoList` components while passing in `props` **and** retaining memoization, each instance of the component needs its own private copy of the selector.
Lets create a function named `makeGetVisibleTodos` that returns a new copy of the `getVisibleTodos` selector each time it is called:
#### `selectors/todoSelectors.js`
```js
import { createSelector } from 'reselect'
const getVisibilityFilter = (state, props) =>
state.todoLists[props.listId].visibilityFilter
const getTodos = (state, props) =>
state.todoLists[props.listId].todos
const makeGetVisibleTodos = () => {
return createSelector(
[ getVisibilityFilter, getTodos ],
(visibilityFilter, todos) => {
switch (visibilityFilter) {
case 'SHOW_COMPLETED':
return todos.filter(todo => todo.completed)
case 'SHOW_ACTIVE':
return todos.filter(todo => !todo.completed)
default:
return todos
}
}
)
}
export default makeGetVisibleTodos
```
We also need a way to give each instance of a container access to its own private selector. The `mapStateToProps` argument of `connect` can help with this.
**If the `mapStateToProps` argument supplied to `connect` returns a function instead of an object, it will be used to create an individual `mapStateToProps` function for each instance of the container.**
In the example below `makeMapStateToProps` creates a new `getVisibleTodos` selector, and returns a `mapStateToProps` function that has exclusive access to the new selector:
```js
const makeMapStateToProps = () => {
const getVisibleTodos = makeGetVisibleTodos()
const mapStateToProps = (state, props) => {
return {
todos: getVisibleTodos(state, props)
}
}
return mapStateToProps
}
```
If we pass `makeMapStateToProps` to `connect`, each instance of the `VisibleTodosList` container will get its own `mapStateToProps` function with a private `getVisibleTodos` selector. Memoization will now work correctly regardless of the render order of the `VisibleTodoList` containers.
#### `containers/VisibleTodoList.js`
```js
import { connect } from 'react-redux'
import { toggleTodo } from '../actions'
import TodoList from '../components/TodoList'
import { makeGetVisibleTodos } from '../selectors'
const makeMapStateToProps = () => {
const getVisibleTodos = makeGetVisibleTodos()
const mapStateToProps = (state, props) => {
return {
todos: getVisibleTodos(state, props)
}
}
return mapStateToProps
}
const mapDispatchToProps = (dispatch) => {
return {
onTodoClick: (id) => {
dispatch(toggleTodo(id))
}
}
}
const VisibleTodoList = connect(
makeMapStateToProps,
mapDispatchToProps
)(TodoList)
export default VisibleTodoList
```
## API
### createSelector(...inputSelectors | [inputSelectors], resultFunc)
Takes one or more selectors, or an array of selectors, computes their values and passes them as arguments to `resultFunc`.
`createSelector` determines if the value returned by an input-selector has changed between calls using reference equality (`===`). Inputs to selectors created with `createSelector` should be immutable.
Selectors created with `createSelector` have a cache size of 1. This means they always recalculate when the value of an input-selector changes, as a selector only stores the preceding value of each input-selector.
```js
const mySelector = createSelector(
state => state.values.value1,
state => state.values.value2,
(value1, value2) => value1 + value2
)
// You can also pass an array of selectors
const totalSelector = createSelector(
[
state => state.values.value1,
state => state.values.value2
],
(value1, value2) => value1 + value2
)
```
It can be useful to access the props of a component from within a selector. When a selector is connected to a component with `connect`, the component props are passed as the second argument to the selector:
```js
const abSelector = (state, props) => state.a * props.b
// props only (ignoring state argument)
const cSelector = (_, props) => props.c
// state only (props argument omitted as not required)
const dSelector = state => state.d
const totalSelector = createSelector(
abSelector,
cSelector,
dSelector,
(ab, c, d) => ({
total: ab + c + d
})
)
```
### defaultMemoize(func, equalityCheck = defaultEqualityCheck)
`defaultMemoize` memoizes the function passed in the func parameter. It is the memoize function used by `createSelector`.
`defaultMemoize` has a cache size of 1. This means it always recalculates when the value of an argument changes.
`defaultMemoize` determines if an argument has changed by calling the `equalityCheck` function. As `defaultMemoize` is designed to be used with immutable data, the default `equalityCheck` function checks for changes using reference equality:
```js
function defaultEqualityCheck(currentVal, previousVal) {
return currentVal === previousVal
}
```
`defaultMemoize` can be used with `createSelectorCreator` to [customize the `equalityCheck` function](#customize-equalitycheck-for-defaultmemoize).
### createSelectorCreator(memoize, ...memoizeOptions)
`createSelectorCreator` can be used to make a customized version of `createSelector`.
The `memoize` argument is a memoization function to replace `defaultMemoize`.
The `...memoizeOptions` rest parameters are zero or more configuration options to be passed to `memoizeFunc`. The selectors `resultFunc` is passed as the first argument to `memoize` and the `memoizeOptions` are passed as the second argument onwards:
```js
const customSelectorCreator = createSelectorCreator(
customMemoize, // function to be used to memoize resultFunc
option1, // option1 will be passed as second argument to customMemoize
option2, // option2 will be passed as third argument to customMemoize
option3 // option3 will be passed as fourth argument to customMemoize
)
const customSelector = customSelectorCreator(
input1,
input2,
resultFunc // resultFunc will be passed as first argument to customMemoize
)
```
Internally `customSelector` calls the memoize function as follows:
```js
customMemoize(resultFunc, option1, option2, option3)
```
Here are some examples of how you might use `createSelectorCreator`:
#### Customize `equalityCheck` for `defaultMemoize`
```js
import { createSelectorCreator, defaultMemoize } from 'reselect'
import isEqual from 'lodash.isEqual'
// create a "selector creator" that uses lodash.isEqual instead of ===
const createDeepEqualSelector = createSelectorCreator(
defaultMemoize,
isEqual
)
// use the new "selector creator" to create a selector
const mySelector = createDeepEqualSelector(
state => state.values.filter(val => val < 5),
values => values.reduce((acc, val) => acc + val, 0)
)
```
#### Use memoize function from lodash for an unbounded cache
```js
import { createSelectorCreator } from 'reselect'
import memoize from 'lodash.memoize'
let called = 0
const hashFn = (...args) => args.reduce(
(acc, val) => acc + '-' + JSON.stringify(val),
''
)
const customSelectorCreator = createSelectorCreator(memoize, hashFn)
const selector = customSelectorCreator(
state => state.a,
state => state.b,
(a, b) => {
called++
return a + b
}
)
```
### createStructuredSelector({inputSelectors}, selectorCreator = createSelector)
`createStructuredSelector` is a convenience function for a common pattern that arises when using Reselect. The selector passed to a `connect` decorator often just takes the values of its input-selectors and maps them to keys in an object:
```js
const mySelectorA = state => state.a
const mySelectorB = state => state.b
// The result function in the following selector
// is simply building an object from the input selectors
const structuredSelector = createSelector(
mySelectorA,
mySelectorB,
mySelectorC,
(a, b, c) => ({
a,
b,
c
})
)
```
`createStructuredSelector` takes an object whose properties are input-selectors and returns a structured selector. The structured selector returns an object with the same keys as the `inputSelectors` argument, but with the selectors replaced with their values.
```js
const mySelectorA = state => state.a
const mySelectorB = state => state.b
const structuredSelector = createStructuredSelector({
x: mySelectorA,
y: mySelectorB
})
const result = structuredSelector({ a: 1, b: 2 }) // will produce { x: 1, y: 2 }
```
Structured selectors can be nested:
```js
const nestedSelector = createStructuredSelector({
subA: createStructuredSelector({
selectorA,
selectorB
}),
subB: createStructuredSelector({
selectorC,
selectorD
})
})
```
## FAQ
### Q: Why isnt my selector recomputing when the input state changes?
A: Check that your memoization function is compatible with your state update function (i.e. the reducer if you are using Redux). For example, a selector created with `createSelector` will not work with a state update function that mutates an existing object instead of creating a new one each time. `createSelector` uses an identity check (`===`) to detect that an input has changed, so mutating an existing object will not trigger the selector to recompute because mutating an object does not change its identity. Note that if you are using Redux, mutating the state object is [almost certainly a mistake](http://redux.js.org/docs/Troubleshooting.html).
The following example defines a simple selector that determines if the first todo item in an array of todos has been completed:
```js
const isFirstTodoCompleteSelector = createSelector(
state => state.todos[0],
todo => todo && todo.completed
)
```
The following state update function **will not** work with `isFirstTodoCompleteSelector`:
```js
export default function todos(state = initialState, action) {
switch (action.type) {
case COMPLETE_ALL:
const areAllMarked = state.every(todo => todo.completed)
// BAD: mutating an existing object
return state.map(todo => {
todo.completed = !areAllMarked
return todo
})
default:
return state
}
}
```
The following state update function **will** work with `isFirstTodoCompleteSelector`:
```js
export default function todos(state = initialState, action) {
switch (action.type) {
case COMPLETE_ALL:
const areAllMarked = state.every(todo => todo.completed)
// GOOD: returning a new object each time with Object.assign
return state.map(todo => Object.assign({}, todo, {
completed: !areAllMarked
}))
default:
return state
}
}
```
If you are not using Redux and have a requirement to work with mutable data, you can use `createSelectorCreator` to replace the default memoization function and/or use a different equality check function. See [here](#use-memoize-function-from-lodash-for-an-unbounded-cache) and [here](#customize-equalitycheck-for-defaultmemoize) for examples.
### Q: Why is my selector recomputing when the input state stays the same?
A: Check that your memoization function is compatible with your state update function (i.e. the reducer if you are using Redux). For example, a selector created with `createSelector` that recomputes unexpectedly may be receiving a new object on each update whether the values it contains have changed or not. `createSelector` uses an identity check (`===`) to detect that an input has changed, so returning a new object on each update means that the selector will recompute on each update.
```js
import { REMOVE_OLD } from '../constants/ActionTypes'
const initialState = [
{
text: 'Use Redux',
completed: false,
id: 0,
timestamp: Date.now()
}
]
export default function todos(state = initialState, action) {
switch (action.type) {
case REMOVE_OLD:
return state.filter(todo => {
return todo.timestamp + 30 * 24 * 60 * 60 * 1000 > Date.now()
})
default:
return state
}
}
```
The following selector is going to recompute every time REMOVE_OLD is invoked because Array.filter always returns a new object. However, in the majority of cases the REMOVE_OLD action will not change the list of todos so the recomputation is unnecessary.
```js
import { createSelector } from 'reselect'
const todosSelector = state => state.todos
export const visibleTodosSelector = createSelector(
todosSelector,
(todos) => {
...
}
)
```
You can eliminate unnecessary recomputations by returning a new object from the state update function only when a deep equality check has found that the list of todos has actually changed:
```js
import { REMOVE_OLD } from '../constants/ActionTypes'
import isEqual from 'lodash.isEqual'
const initialState = [
{
text: 'Use Redux',
completed: false,
id: 0,
timestamp: Date.now()
}
]
export default function todos(state = initialState, action) {
switch (action.type) {
case REMOVE_OLD:
const updatedState = state.filter(todo => {
return todo.timestamp + 30 * 24 * 60 * 60 * 1000 > Date.now()
})
return isEqual(updatedState, state) ? state : updatedState
default:
return state
}
}
```
Alternatively, the default `equalityCheck` function in the selector can be replaced by a deep equality check:
```js
import { createSelectorCreator, defaultMemoize } from 'reselect'
import isEqual from 'lodash.isEqual'
const todosSelector = state => state.todos
// create a "selector creator" that uses lodash.isEqual instead of ===
const createDeepEqualSelector = createSelectorCreator(
defaultMemoize,
isEqual
)
// use the new "selector creator" to create a selector
const mySelector = createDeepEqualSelector(
todosSelector,
(todos) => {
...
}
)
```
Always check that the cost of an alternative `equalityCheck` function or deep equality check in the state update function is not greater than the cost of recomputing every time. If recomputing every time does work out to be the cheaper option, it may be that for this case Reselect is not giving you any benefit over passing a plain `mapStateToProps` function to `connect`.
### Q: Can I use Reselect without Redux?
A: Yes. Reselect has no dependencies on any other package, so although it was designed to be used with Redux it can be used independently. It is currently being used successfully in traditional Flux apps.
> If you create selectors using `createSelector` make sure its arguments are immutable.
> See [here](#createselectorinputselectors--inputselectors-resultfunc)
### Q: How do I create a selector that takes an argument?
A: Keep in mind that selectors can access React props, so if your arguments are (or can be made available as) React props, you can use that functionality. [See here](#accessing-react-props-in-selectors) for details.
Otherwise, Reselect doesn't have built-in support for creating selectors that accepts arguments, but here are some suggestions for implementing similar functionality...
If the argument is not dynamic you can use a factory function:
```js
const expensiveItemSelectorFactory = minValue => {
return createSelector(
shopItemsSelector,
items => items.filter(item => item.value > minValue)
)
}
const subtotalSelector = createSelector(
expensiveItemSelectorFactory(200),
items => items.reduce((acc, item) => acc + item.value, 0)
)
```
The general consensus [here](https://github.com/reactjs/reselect/issues/38) and [over at nuclear-js](https://github.com/optimizely/nuclear-js/issues/14) is that if a selector needs a dynamic argument, then that argument should probably be state in the store. If you decide that you do require a selector with a dynamic argument, then a selector that returns a memoized function may be suitable:
```js
import { createSelector } from 'reselect'
import memoize from 'lodash.memoize'
const expensiveSelector = createSelector(
state => state.items,
items => memoize(
minValue => items.filter(item => item.value > minValue)
)
)
const expensiveFilter = expensiveSelector(state)
const slightlyExpensive = expensiveFilter(100)
const veryExpensive = expensiveFilter(1000000)
```
### Q: The default memoization function is no good, can I use a different one?
A: We think it works great for a lot of use cases, but sure. See [these examples](#customize-equalitycheck-for-defaultmemoize).
### Q: How do I test a selector?
A: For a given input, a selector should always produce the same output. For this reason they are simple to unit test.
```js
const selector = createSelector(
state => state.a,
state => state.b,
(a, b) => ({
c: a * 2,
d: b * 3
})
)
test("selector unit test", () => {
assert.deepEqual(selector({ a: 1, b: 2 }), { c: 2, d: 6 })
assert.deepEqual(selector({ a: 2, b: 3 }), { c: 4, d: 9 })
})
```
It may also be useful to check that the memoization function for a selector works correctly with the state update function (i.e. the reducer if you are using Redux). Each selector has a `recomputations` method that will return the number of times it has been recomputed:
```js
suite('selector', () => {
let state = { a: 1, b: 2 }
const reducer = (state, action) => (
{
a: action(state.a),
b: action(state.b)
}
)
const selector = createSelector(
state => state.a,
state => state.b,
(a, b) => ({
c: a * 2,
d: b * 3
})
)
const plusOne = x => x + 1
const id = x => x
test("selector unit test", () => {
state = reducer(state, plusOne)
assert.deepEqual(selector(state), { c: 4, d: 9 })
state = reducer(state, id)
assert.deepEqual(selector(state), { c: 4, d: 9 })
assert.equal(selector.recomputations(), 1)
state = reducer(state, plusOne)
assert.deepEqual(selector(state), { c: 6, d: 12 })
assert.equal(selector.recomputations(), 2)
})
})
```
Additionally, selectors keep a reference to the last result function as `.resultFunc`. If you have selectors composed of many other selectors this can help you test each selector without coupling all of your tests to the shape of your state.
For example if you have a set of selectors like this:
**selectors.js**
```js
export const firstSelector = createSelector( ... )
export const secondSelector = createSelector( ... )
export const thirdSelector = createSelector( ... )
export const myComposedSelector = createSelector(
firstSelector,
secondSelector,
thirdSelector,
(first, second, third) => first * second < third
)
```
And then a set of unit tests like this:
**test/selectors.js**
```js
// tests for the first three selectors...
test("firstSelector unit test", () => { ... })
test("secondSelector unit test", () => { ... })
test("thirdSelector unit test", () => { ... })
// We have already tested the previous
// three selector outputs so we can just call `.resultFunc`
// with the values we want to test directly:
test("myComposedSelector unit test", () => {
// here instead of calling selector()
// we just call selector.resultFunc()
assert(selector.resultFunc(1, 2, 3), true)
assert(selector.resultFunc(2, 2, 1), false)
})
```
Finally, each selector has a `resetRecomputations` method that sets
recomputations back to 0. The intended use is for a complex selector that may
have many independent tests and you don't want to manually manage the
computation count or create a "dummy" selector for each test.
### Q: How do I use Reselect with Immutable.js?
A: Selectors created with `createSelector` should work just fine with Immutable.js data structures.
If your selector is recomputing and you don't think the state has changed, make sure you are aware of which Immutable.js update methods **always** return a new object and which update methods only return a new object **when the collection actually changes**.
```js
import Immutable from 'immutable'
let myMap = Immutable.Map({
a: 1,
b: 2,
c: 3
})
// set, merge and others only return a new obj when update changes collection
let newMap = myMap.set('a', 1)
assert.equal(myMap, newMap)
newMap = myMap.merge({ 'a', 1 })
assert.equal(myMap, newMap)
// map, reduce, filter and others always return a new obj
newMap = myMap.map(a => a * 1)
assert.notEqual(myMap, newMap)
```
If a selector's input is updated by an operation that always returns a new object, it may be performing unnecessary recomputations. See [here](#q-why-is-my-selector-recomputing-when-the-input-state-stays-the-same) for a discussion on the pros and cons of using a deep equality check like `Immutable.is` to eliminate unnecessary recomputations.
### Q: Can I share a selector across multiple components?
A: Selectors created using `createSelector` only have a cache size of one. This can make them unsuitable for sharing across multiple components if the arguments to the selector are different for each instance of the component. There are a couple of ways to get around this:
* Create a factory function which returns a new selector for each instance of the component. There is built-in support for factory functions in React Redux v4.3 or higher. See [here](#sharing-selectors-with-props-across-multiple-components) for an example.
* Create a custom selector with a cache size greater than one.
### Q: Are there TypeScript Typings?
A: Yes! They are included and referenced in `package.json`. They should Just Work™.
### Q: How can I make a [curried](https://github.com/hemanth/functional-programming-jargon#currying) selector?
A: Try these [helper functions](https://github.com/reactjs/reselect/issues/159#issuecomment-238724788) courtesy of [MattSPalmer](https://github.com/MattSPalmer)
## Related Projects
### [re-reselect](https://github.com/toomuchdesign/re-reselect)
Enhances Reselect selectors by wrapping `createSelector` and returning a memoized collection of selectors indexed with the cache key returned by a custom resolver function.
Useful to reduce selectors recalculation when the same selector is repeatedly called with one/few different arguments.
### [reselect-map](https://github.com/HeyImAlex/reselect-map)
Can be useful when doing **very expensive** computations on elements of a collection because Reselect might not give you the granularity of caching that you need. Check out the reselect-maps README for examples.
**The optimizations in reselect-map only apply in a small number of cases. If you are unsure whether you need it, you don't!**
## License
MIT
[build-badge]: https://img.shields.io/travis/reactjs/reselect/master.svg?style=flat-square
[build]: https://travis-ci.org/reactjs/reselect
[npm-badge]: https://img.shields.io/npm/v/reselect.svg?style=flat-square
[npm]: https://www.npmjs.org/package/reselect
[coveralls-badge]: https://img.shields.io/coveralls/reactjs/reselect/master.svg?style=flat-square
[coveralls]: https://coveralls.io/github/reactjs/reselect

139
node_modules/reselect/dist/reselect.js generated vendored Normal file
View File

@ -0,0 +1,139 @@
(function (global, factory) {
if (typeof define === "function" && define.amd) {
define('Reselect', ['exports'], factory);
} else if (typeof exports !== "undefined") {
factory(exports);
} else {
var mod = {
exports: {}
};
factory(mod.exports);
global.Reselect = mod.exports;
}
})(this, function (exports) {
'use strict';
exports.__esModule = true;
exports.defaultMemoize = defaultMemoize;
exports.createSelectorCreator = createSelectorCreator;
exports.createStructuredSelector = createStructuredSelector;
function defaultEqualityCheck(a, b) {
return a === b;
}
function areArgumentsShallowlyEqual(equalityCheck, prev, next) {
if (prev === null || next === null || prev.length !== next.length) {
return false;
}
// Do this in a for loop (and not a `forEach` or an `every`) so we can determine equality as fast as possible.
var length = prev.length;
for (var i = 0; i < length; i++) {
if (!equalityCheck(prev[i], next[i])) {
return false;
}
}
return true;
}
function defaultMemoize(func) {
var equalityCheck = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : defaultEqualityCheck;
var lastArgs = null;
var lastResult = null;
// we reference arguments instead of spreading them for performance reasons
return function () {
if (!areArgumentsShallowlyEqual(equalityCheck, lastArgs, arguments)) {
// apply arguments instead of spreading for performance.
lastResult = func.apply(null, arguments);
}
lastArgs = arguments;
return lastResult;
};
}
function getDependencies(funcs) {
var dependencies = Array.isArray(funcs[0]) ? funcs[0] : funcs;
if (!dependencies.every(function (dep) {
return typeof dep === 'function';
})) {
var dependencyTypes = dependencies.map(function (dep) {
return typeof dep;
}).join(', ');
throw new Error('Selector creators expect all input-selectors to be functions, ' + ('instead received the following types: [' + dependencyTypes + ']'));
}
return dependencies;
}
function createSelectorCreator(memoize) {
for (var _len = arguments.length, memoizeOptions = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
memoizeOptions[_key - 1] = arguments[_key];
}
return function () {
for (var _len2 = arguments.length, funcs = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
funcs[_key2] = arguments[_key2];
}
var recomputations = 0;
var resultFunc = funcs.pop();
var dependencies = getDependencies(funcs);
var memoizedResultFunc = memoize.apply(undefined, [function () {
recomputations++;
// apply arguments instead of spreading for performance.
return resultFunc.apply(null, arguments);
}].concat(memoizeOptions));
// If a selector is called with the exact same arguments we don't need to traverse our dependencies again.
var selector = defaultMemoize(function () {
var params = [];
var length = dependencies.length;
for (var i = 0; i < length; i++) {
// apply arguments instead of spreading and mutate a local list of params for performance.
params.push(dependencies[i].apply(null, arguments));
}
// apply arguments instead of spreading for performance.
return memoizedResultFunc.apply(null, params);
});
selector.resultFunc = resultFunc;
selector.recomputations = function () {
return recomputations;
};
selector.resetRecomputations = function () {
return recomputations = 0;
};
return selector;
};
}
var createSelector = exports.createSelector = createSelectorCreator(defaultMemoize);
function createStructuredSelector(selectors) {
var selectorCreator = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : createSelector;
if (typeof selectors !== 'object') {
throw new Error('createStructuredSelector expects first argument to be an object ' + ('where each property is a selector, instead received a ' + typeof selectors));
}
var objectKeys = Object.keys(selectors);
return selectorCreator(objectKeys.map(function (key) {
return selectors[key];
}), function () {
for (var _len3 = arguments.length, values = Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
values[_key3] = arguments[_key3];
}
return values.reduce(function (composition, value, index) {
composition[objectKeys[index]] = value;
return composition;
}, {});
});
}
});

119
node_modules/reselect/es/index.js generated vendored Normal file
View File

@ -0,0 +1,119 @@
function defaultEqualityCheck(a, b) {
return a === b;
}
function areArgumentsShallowlyEqual(equalityCheck, prev, next) {
if (prev === null || next === null || prev.length !== next.length) {
return false;
}
// Do this in a for loop (and not a `forEach` or an `every`) so we can determine equality as fast as possible.
var length = prev.length;
for (var i = 0; i < length; i++) {
if (!equalityCheck(prev[i], next[i])) {
return false;
}
}
return true;
}
export function defaultMemoize(func) {
var equalityCheck = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : defaultEqualityCheck;
var lastArgs = null;
var lastResult = null;
// we reference arguments instead of spreading them for performance reasons
return function () {
if (!areArgumentsShallowlyEqual(equalityCheck, lastArgs, arguments)) {
// apply arguments instead of spreading for performance.
lastResult = func.apply(null, arguments);
}
lastArgs = arguments;
return lastResult;
};
}
function getDependencies(funcs) {
var dependencies = Array.isArray(funcs[0]) ? funcs[0] : funcs;
if (!dependencies.every(function (dep) {
return typeof dep === 'function';
})) {
var dependencyTypes = dependencies.map(function (dep) {
return typeof dep;
}).join(', ');
throw new Error('Selector creators expect all input-selectors to be functions, ' + ('instead received the following types: [' + dependencyTypes + ']'));
}
return dependencies;
}
export function createSelectorCreator(memoize) {
for (var _len = arguments.length, memoizeOptions = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
memoizeOptions[_key - 1] = arguments[_key];
}
return function () {
for (var _len2 = arguments.length, funcs = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
funcs[_key2] = arguments[_key2];
}
var recomputations = 0;
var resultFunc = funcs.pop();
var dependencies = getDependencies(funcs);
var memoizedResultFunc = memoize.apply(undefined, [function () {
recomputations++;
// apply arguments instead of spreading for performance.
return resultFunc.apply(null, arguments);
}].concat(memoizeOptions));
// If a selector is called with the exact same arguments we don't need to traverse our dependencies again.
var selector = defaultMemoize(function () {
var params = [];
var length = dependencies.length;
for (var i = 0; i < length; i++) {
// apply arguments instead of spreading and mutate a local list of params for performance.
params.push(dependencies[i].apply(null, arguments));
}
// apply arguments instead of spreading for performance.
return memoizedResultFunc.apply(null, params);
});
selector.resultFunc = resultFunc;
selector.recomputations = function () {
return recomputations;
};
selector.resetRecomputations = function () {
return recomputations = 0;
};
return selector;
};
}
export var createSelector = createSelectorCreator(defaultMemoize);
export function createStructuredSelector(selectors) {
var selectorCreator = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : createSelector;
if (typeof selectors !== 'object') {
throw new Error('createStructuredSelector expects first argument to be an object ' + ('where each property is a selector, instead received a ' + typeof selectors));
}
var objectKeys = Object.keys(selectors);
return selectorCreator(objectKeys.map(function (key) {
return selectors[key];
}), function () {
for (var _len3 = arguments.length, values = Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
values[_key3] = arguments[_key3];
}
return values.reduce(function (composition, value, index) {
composition[objectKeys[index]] = value;
return composition;
}, {});
});
}

617
node_modules/reselect/lib/index.d.ts generated vendored Normal file
View File

@ -0,0 +1,617 @@
export as namespace Reselect;
export type Selector<S, R> = (state: S) => R;
export type OutputSelector<S, R, C> = Selector<S, R> & {
resultFunc: C;
recomputations: () => number;
resetRecomputations: () => number;
}
export type ParametricSelector<S, P, R> = (state: S, props: P, ...args: any[]) => R;
export type OutputParametricSelector<S, P, R, C> = ParametricSelector<S, P, R> & {
resultFunc: C;
recomputations: () => number;
resetRecomputations: () => number;
}
/* one selector */
export function createSelector<S, R1, T>(
selector: Selector<S, R1>,
combiner: (res: R1) => T,
): OutputSelector<S, T, (res: R1) => T>;
export function createSelector<S, P, R1, T>(
selector: ParametricSelector<S, P, R1>,
combiner: (res: R1) => T,
): OutputParametricSelector<S, P, T, (res: R1) => T>;
/* two selectors */
export function createSelector<S, R1, R2, T>(
selector1: Selector<S, R1>,
selector2: Selector<S, R2>,
combiner: (res1: R1, res2: R2) => T,
): OutputSelector<S, T, (res1: R1, res2: R2) => T>;
export function createSelector<S, P, R1, R2, T>(
selector1: ParametricSelector<S, P, R1>,
selector2: ParametricSelector<S, P, R2>,
combiner: (res1: R1, res2: R2) => T,
): OutputParametricSelector<S, P, T, (res1: R1, res2: R2) => T>;
/* three selectors */
export function createSelector<S, R1, R2, R3, T>(
selector1: Selector<S, R1>,
selector2: Selector<S, R2>,
selector3: Selector<S, R3>,
combiner: (res1: R1, res2: R2, res3: R3) => T,
): OutputSelector<S, T, (res1: R1, res2: R2, res3: R3) => T>;
export function createSelector<S, P, R1, R2, R3, T>(
selector1: ParametricSelector<S, P, R1>,
selector2: ParametricSelector<S, P, R2>,
selector3: ParametricSelector<S, P, R3>,
combiner: (res1: R1, res2: R2, res3: R3) => T,
): OutputParametricSelector<S, P, T, (res1: R1, res2: R2, res3: R3) => T>;
/* four selectors */
export function createSelector<S, R1, R2, R3, R4, T>(
selector1: Selector<S, R1>,
selector2: Selector<S, R2>,
selector3: Selector<S, R3>,
selector4: Selector<S, R4>,
combiner: (res1: R1, res2: R2, res3: R3, res4: R4) => T,
): OutputSelector<S, T, (res1: R1, res2: R2, res3: R3, res4: R4) => T>;
export function createSelector<S, P, R1, R2, R3, R4, T>(
selector1: ParametricSelector<S, P, R1>,
selector2: ParametricSelector<S, P, R2>,
selector3: ParametricSelector<S, P, R3>,
selector4: ParametricSelector<S, P, R4>,
combiner: (res1: R1, res2: R2, res3: R3, res4: R4) => T,
): OutputParametricSelector<S, P, T, (res1: R1, res2: R2, res3: R3, res4: R4) => T>;
/* five selectors */
export function createSelector<S, R1, R2, R3, R4, R5, T>(
selector1: Selector<S, R1>,
selector2: Selector<S, R2>,
selector3: Selector<S, R3>,
selector4: Selector<S, R4>,
selector5: Selector<S, R5>,
combiner: (res1: R1, res2: R2, res3: R3, res4: R4, res5: R5) => T,
): OutputSelector<S, T, (res1: R1, res2: R2, res3: R3, res4: R4, res5: R5) => T>;
export function createSelector<S, P, R1, R2, R3, R4, R5, T>(
selector1: ParametricSelector<S, P, R1>,
selector2: ParametricSelector<S, P, R2>,
selector3: ParametricSelector<S, P, R3>,
selector4: ParametricSelector<S, P, R4>,
selector5: ParametricSelector<S, P, R5>,
combiner: (res1: R1, res2: R2, res3: R3, res4: R4, res5: R5) => T,
): OutputParametricSelector<S, P, T, (res1: R1, res2: R2, res3: R3, res4: R4, res5: R5) => T>;
/* six selectors */
export function createSelector<S, R1, R2, R3, R4, R5, R6, T>(
selector1: Selector<S, R1>,
selector2: Selector<S, R2>,
selector3: Selector<S, R3>,
selector4: Selector<S, R4>,
selector5: Selector<S, R5>,
selector6: Selector<S, R6>,
combiner: (res1: R1, res2: R2, res3: R3, res4: R4, res5: R5, res6: R6) => T,
): OutputSelector<S, T, (res1: R1, res2: R2, res3: R3, res4: R4, res5: R5, res6: R6) => T>;
export function createSelector<S, P, R1, R2, R3, R4, R5, R6, T>(
selector1: ParametricSelector<S, P, R1>,
selector2: ParametricSelector<S, P, R2>,
selector3: ParametricSelector<S, P, R3>,
selector4: ParametricSelector<S, P, R4>,
selector5: ParametricSelector<S, P, R5>,
selector6: ParametricSelector<S, P, R6>,
combiner: (res1: R1, res2: R2, res3: R3, res4: R4, res5: R5, res6: R6) => T,
): OutputParametricSelector<S, P, T, (res1: R1, res2: R2, res3: R3, res4: R4, res5: R5, res6: R6) => T>;
/* seven selectors */
export function createSelector<S, R1, R2, R3, R4, R5, R6, R7, T>(
selector1: Selector<S, R1>,
selector2: Selector<S, R2>,
selector3: Selector<S, R3>,
selector4: Selector<S, R4>,
selector5: Selector<S, R5>,
selector6: Selector<S, R6>,
selector7: Selector<S, R7>,
combiner: (res1: R1, res2: R2, res3: R3, res4: R4, res5: R5, res6: R6,
res7: R7) => T,
): OutputSelector<S, T, (res1: R1, res2: R2, res3: R3, res4: R4, res5: R5, res6: R6,
res7: R7) => T>;
export function createSelector<S, P, R1, R2, R3, R4, R5, R6, R7, T>(
selector1: ParametricSelector<S, P, R1>,
selector2: ParametricSelector<S, P, R2>,
selector3: ParametricSelector<S, P, R3>,
selector4: ParametricSelector<S, P, R4>,
selector5: ParametricSelector<S, P, R5>,
selector6: ParametricSelector<S, P, R6>,
selector7: ParametricSelector<S, P, R7>,
combiner: (res1: R1, res2: R2, res3: R3, res4: R4, res5: R5, res6: R6,
res7: R7) => T,
): OutputParametricSelector<S, P, T, (res1: R1, res2: R2, res3: R3, res4: R4, res5: R5, res6: R6,
res7: R7) => T>;
/* eight selectors */
export function createSelector<S, R1, R2, R3, R4, R5, R6, R7, R8, T>(
selector1: Selector<S, R1>,
selector2: Selector<S, R2>,
selector3: Selector<S, R3>,
selector4: Selector<S, R4>,
selector5: Selector<S, R5>,
selector6: Selector<S, R6>,
selector7: Selector<S, R7>,
selector8: Selector<S, R8>,
combiner: (res1: R1, res2: R2, res3: R3, res4: R4, res5: R5, res6: R6,
res7: R7, res8: R8) => T,
): OutputSelector<S, T, (res1: R1, res2: R2, res3: R3, res4: R4, res5: R5, res6: R6,
res7: R7, res8: R8) => T>;
export function createSelector<S, P, R1, R2, R3, R4, R5, R6, R7, R8, T>(
selector1: ParametricSelector<S, P, R1>,
selector2: ParametricSelector<S, P, R2>,
selector3: ParametricSelector<S, P, R3>,
selector4: ParametricSelector<S, P, R4>,
selector5: ParametricSelector<S, P, R5>,
selector6: ParametricSelector<S, P, R6>,
selector7: ParametricSelector<S, P, R7>,
selector8: ParametricSelector<S, P, R8>,
combiner: (res1: R1, res2: R2, res3: R3, res4: R4, res5: R5, res6: R6,
res7: R7, res8: R8) => T,
): OutputParametricSelector<S, P, T, (res1: R1, res2: R2, res3: R3, res4: R4, res5: R5, res6: R6,
res7: R7, res8: R8) => T>;
/* nine selectors */
export function createSelector<S, R1, R2, R3, R4, R5, R6, R7, R8, R9, T>(
selector1: Selector<S, R1>,
selector2: Selector<S, R2>,
selector3: Selector<S, R3>,
selector4: Selector<S, R4>,
selector5: Selector<S, R5>,
selector6: Selector<S, R6>,
selector7: Selector<S, R7>,
selector8: Selector<S, R8>,
selector9: Selector<S, R9>,
combiner: (res1: R1, res2: R2, res3: R3, res4: R4, res5: R5, res6: R6,
res7: R7, res8: R8, res9: R9) => T,
): OutputSelector<S, T, (res1: R1, res2: R2, res3: R3, res4: R4, res5: R5, res6: R6,
res7: R7, res8: R8, res9: R9) => T>;
export function createSelector<S, P, R1, R2, R3, R4, R5, R6, R7, R8, R9, T>(
selector1: ParametricSelector<S, P, R1>,
selector2: ParametricSelector<S, P, R2>,
selector3: ParametricSelector<S, P, R3>,
selector4: ParametricSelector<S, P, R4>,
selector5: ParametricSelector<S, P, R5>,
selector6: ParametricSelector<S, P, R6>,
selector7: ParametricSelector<S, P, R7>,
selector8: ParametricSelector<S, P, R8>,
selector9: ParametricSelector<S, P, R9>,
combiner: (res1: R1, res2: R2, res3: R3, res4: R4, res5: R5, res6: R6,
res7: R7, res8: R8, res9: R9) => T,
): OutputParametricSelector<S, P, T, (res1: R1, res2: R2, res3: R3, res4: R4, res5: R5, res6: R6,
res7: R7, res8: R8, res9: R9) => T>;
/* ten selectors */
export function createSelector<S, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, T>(
selector1: Selector<S, R1>,
selector2: Selector<S, R2>,
selector3: Selector<S, R3>,
selector4: Selector<S, R4>,
selector5: Selector<S, R5>,
selector6: Selector<S, R6>,
selector7: Selector<S, R7>,
selector8: Selector<S, R8>,
selector9: Selector<S, R9>,
selector10: Selector<S, R10>,
combiner: (res1: R1, res2: R2, res3: R3, res4: R4, res5: R5, res6: R6,
res7: R7, res8: R8, res9: R9, res10: R10) => T,
): OutputSelector<S, T, (res1: R1, res2: R2, res3: R3, res4: R4, res5: R5, res6: R6,
res7: R7, res8: R8, res9: R9, res10: R10) => T>;
export function createSelector<S, P, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, T>(
selector1: ParametricSelector<S, P, R1>,
selector2: ParametricSelector<S, P, R2>,
selector3: ParametricSelector<S, P, R3>,
selector4: ParametricSelector<S, P, R4>,
selector5: ParametricSelector<S, P, R5>,
selector6: ParametricSelector<S, P, R6>,
selector7: ParametricSelector<S, P, R7>,
selector8: ParametricSelector<S, P, R8>,
selector9: ParametricSelector<S, P, R9>,
selector10: ParametricSelector<S, P, R10>,
combiner: (res1: R1, res2: R2, res3: R3, res4: R4, res5: R5, res6: R6,
res7: R7, res8: R8, res9: R9, res10: R10) => T,
): OutputParametricSelector<S, P, T, (res1: R1, res2: R2, res3: R3, res4: R4, res5: R5, res6: R6,
res7: R7, res8: R8, res9: R9, res10: R10) => T>;
/* eleven selectors */
export function createSelector<S, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, T>(
selector1: Selector<S, R1>,
selector2: Selector<S, R2>,
selector3: Selector<S, R3>,
selector4: Selector<S, R4>,
selector5: Selector<S, R5>,
selector6: Selector<S, R6>,
selector7: Selector<S, R7>,
selector8: Selector<S, R8>,
selector9: Selector<S, R9>,
selector10: Selector<S, R10>,
selector11: Selector<S, R11>,
combiner: (res1: R1, res2: R2, res3: R3, res4: R4, res5: R5, res6: R6,
res7: R7, res8: R8, res9: R9, res10: R10, res11: R11) => T,
): OutputSelector<S, T, (res1: R1, res2: R2, res3: R3, res4: R4, res5: R5, res6: R6,
res7: R7, res8: R8, res9: R9, res10: R10, res11: R11) => T>;
export function createSelector<S, P, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, T>(
selector1: ParametricSelector<S, P, R1>,
selector2: ParametricSelector<S, P, R2>,
selector3: ParametricSelector<S, P, R3>,
selector4: ParametricSelector<S, P, R4>,
selector5: ParametricSelector<S, P, R5>,
selector6: ParametricSelector<S, P, R6>,
selector7: ParametricSelector<S, P, R7>,
selector8: ParametricSelector<S, P, R8>,
selector9: ParametricSelector<S, P, R9>,
selector10: ParametricSelector<S, P, R10>,
selector11: ParametricSelector<S, P, R11>,
combiner: (res1: R1, res2: R2, res3: R3, res4: R4, res5: R5, res6: R6,
res7: R7, res8: R8, res9: R9, res10: R10, res11: R11) => T,
): OutputParametricSelector<S, P, T, (res1: R1, res2: R2, res3: R3, res4: R4, res5: R5, res6: R6,
res7: R7, res8: R8, res9: R9, res10: R10, res11: R11) => T>;
/* twelve selectors */
export function createSelector<S, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, T>(
selector1: Selector<S, R1>,
selector2: Selector<S, R2>,
selector3: Selector<S, R3>,
selector4: Selector<S, R4>,
selector5: Selector<S, R5>,
selector6: Selector<S, R6>,
selector7: Selector<S, R7>,
selector8: Selector<S, R8>,
selector9: Selector<S, R9>,
selector10: Selector<S, R10>,
selector11: Selector<S, R11>,
selector12: Selector<S, R12>,
combiner: (res1: R1, res2: R2, res3: R3, res4: R4, res5: R5, res6: R6,
res7: R7, res8: R8, res9: R9, res10: R10, res11: R11, res12: R12) => T,
): OutputSelector<S, T, (res1: R1, res2: R2, res3: R3, res4: R4, res5: R5, res6: R6,
res7: R7, res8: R8, res9: R9, res10: R10, res11: R11, res12: R12) => T>;
export function createSelector<S, P, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, T>(
selector1: ParametricSelector<S, P, R1>,
selector2: ParametricSelector<S, P, R2>,
selector3: ParametricSelector<S, P, R3>,
selector4: ParametricSelector<S, P, R4>,
selector5: ParametricSelector<S, P, R5>,
selector6: ParametricSelector<S, P, R6>,
selector7: ParametricSelector<S, P, R7>,
selector8: ParametricSelector<S, P, R8>,
selector9: ParametricSelector<S, P, R9>,
selector10: ParametricSelector<S, P, R10>,
selector11: ParametricSelector<S, P, R11>,
selector12: ParametricSelector<S, P, R12>,
combiner: (res1: R1, res2: R2, res3: R3, res4: R4, res5: R5, res6: R6,
res7: R7, res8: R8, res9: R9, res10: R10, res11: R11, res12: R12) => T,
): OutputParametricSelector<S, P, T, (res1: R1, res2: R2, res3: R3, res4: R4, res5: R5, res6: R6,
res7: R7, res8: R8, res9: R9, res10: R10, res11: R11, res12: R12) => T>;
/* array argument */
/* one selector */
export function createSelector<S, R1, T>(
selectors: [Selector<S, R1>],
combiner: (res: R1) => T,
): OutputSelector<S, T, (res: R1) => T>;
export function createSelector<S, P, R1, T>(
selectors: [ParametricSelector<S, P, R1>],
combiner: (res: R1) => T,
): OutputParametricSelector<S, P, T, (res: R1) => T>;
/* two selectors */
export function createSelector<S, R1, R2, T>(
selectors: [Selector<S, R1>,
Selector<S, R2>],
combiner: (res1: R1, res2: R2) => T,
): OutputSelector<S, T, (res1: R1, res2: R2) => T>;
export function createSelector<S, P, R1, R2, T>(
selectors: [ParametricSelector<S, P, R1>,
ParametricSelector<S, P, R2>],
combiner: (res1: R1, res2: R2) => T,
): OutputParametricSelector<S, P, T, (res1: R1, res2: R2) => T>;
/* three selectors */
export function createSelector<S, R1, R2, R3, T>(
selectors: [Selector<S, R1>,
Selector<S, R2>,
Selector<S, R3>],
combiner: (res1: R1, res2: R2, res3: R3) => T,
): OutputSelector<S, T, (res1: R1, res2: R2, res3: R3) => T>;
export function createSelector<S, P, R1, R2, R3, T>(
selectors: [ParametricSelector<S, P, R1>,
ParametricSelector<S, P, R2>,
ParametricSelector<S, P, R3>],
combiner: (res1: R1, res2: R2, res3: R3) => T,
): OutputParametricSelector<S, P, T, (res1: R1, res2: R2, res3: R3) => T>;
/* four selectors */
export function createSelector<S, R1, R2, R3, R4, T>(
selectors: [Selector<S, R1>,
Selector<S, R2>,
Selector<S, R3>,
Selector<S, R4>],
combiner: (res1: R1, res2: R2, res3: R3, res4: R4) => T,
): OutputSelector<S, T, (res1: R1, res2: R2, res3: R3, res4: R4) => T>;
export function createSelector<S, P, R1, R2, R3, R4, T>(
selectors: [ParametricSelector<S, P, R1>,
ParametricSelector<S, P, R2>,
ParametricSelector<S, P, R3>,
ParametricSelector<S, P, R4>],
combiner: (res1: R1, res2: R2, res3: R3, res4: R4) => T,
): OutputParametricSelector<S, P, T, (res1: R1, res2: R2, res3: R3, res4: R4) => T>;
/* five selectors */
export function createSelector<S, R1, R2, R3, R4, R5, T>(
selectors: [Selector<S, R1>,
Selector<S, R2>,
Selector<S, R3>,
Selector<S, R4>,
Selector<S, R5>],
combiner: (res1: R1, res2: R2, res3: R3, res4: R4, res5: R5) => T,
): OutputSelector<S, T, (res1: R1, res2: R2, res3: R3, res4: R4, res5: R5) => T>;
export function createSelector<S, P, R1, R2, R3, R4, R5, T>(
selectors: [ParametricSelector<S, P, R1>,
ParametricSelector<S, P, R2>,
ParametricSelector<S, P, R3>,
ParametricSelector<S, P, R4>,
ParametricSelector<S, P, R5>],
combiner: (res1: R1, res2: R2, res3: R3, res4: R4, res5: R5) => T,
): OutputParametricSelector<S, P, T, (res1: R1, res2: R2, res3: R3, res4: R4, res5: R5) => T>;
/* six selectors */
export function createSelector<S, R1, R2, R3, R4, R5, R6, T>(
selectors: [Selector<S, R1>,
Selector<S, R2>,
Selector<S, R3>,
Selector<S, R4>,
Selector<S, R5>,
Selector<S, R6>],
combiner: (res1: R1, res2: R2, res3: R3, res4: R4, res5: R5, res6: R6) => T,
): OutputSelector<S, T, (res1: R1, res2: R2, res3: R3, res4: R4, res5: R5, res6: R6) => T>;
export function createSelector<S, P, R1, R2, R3, R4, R5, R6, T>(
selectors: [ParametricSelector<S, P, R1>,
ParametricSelector<S, P, R2>,
ParametricSelector<S, P, R3>,
ParametricSelector<S, P, R4>,
ParametricSelector<S, P, R5>,
ParametricSelector<S, P, R6>],
combiner: (res1: R1, res2: R2, res3: R3, res4: R4, res5: R5, res6: R6) => T,
): OutputParametricSelector<S, P, T, (res1: R1, res2: R2, res3: R3, res4: R4, res5: R5, res6: R6) => T>;
/* seven selectors */
export function createSelector<S, R1, R2, R3, R4, R5, R6, R7, T>(
selectors: [Selector<S, R1>,
Selector<S, R2>,
Selector<S, R3>,
Selector<S, R4>,
Selector<S, R5>,
Selector<S, R6>,
Selector<S, R7>],
combiner: (res1: R1, res2: R2, res3: R3, res4: R4, res5: R5, res6: R6,
res7: R7) => T,
): OutputSelector<S, T, (res1: R1, res2: R2, res3: R3, res4: R4, res5: R5, res6: R6,
res7: R7) => T>;
export function createSelector<S, P, R1, R2, R3, R4, R5, R6, R7, T>(
selectors: [ParametricSelector<S, P, R1>,
ParametricSelector<S, P, R2>,
ParametricSelector<S, P, R3>,
ParametricSelector<S, P, R4>,
ParametricSelector<S, P, R5>,
ParametricSelector<S, P, R6>,
ParametricSelector<S, P, R7>],
combiner: (res1: R1, res2: R2, res3: R3, res4: R4, res5: R5, res6: R6,
res7: R7) => T,
): OutputParametricSelector<S, P, T, (res1: R1, res2: R2, res3: R3, res4: R4, res5: R5, res6: R6,
res7: R7) => T>;
/* eight selectors */
export function createSelector<S, R1, R2, R3, R4, R5, R6, R7, R8, T>(
selectors: [Selector<S, R1>,
Selector<S, R2>,
Selector<S, R3>,
Selector<S, R4>,
Selector<S, R5>,
Selector<S, R6>,
Selector<S, R7>,
Selector<S, R8>],
combiner: (res1: R1, res2: R2, res3: R3, res4: R4, res5: R5, res6: R6,
res7: R7, res8: R8) => T,
): OutputSelector<S, T, (res1: R1, res2: R2, res3: R3, res4: R4, res5: R5, res6: R6,
res7: R7, res8: R8) => T>;
export function createSelector<S, P, R1, R2, R3, R4, R5, R6, R7, R8, T>(
selectors: [ParametricSelector<S, P, R1>,
ParametricSelector<S, P, R2>,
ParametricSelector<S, P, R3>,
ParametricSelector<S, P, R4>,
ParametricSelector<S, P, R5>,
ParametricSelector<S, P, R6>,
ParametricSelector<S, P, R7>,
ParametricSelector<S, P, R8>],
combiner: (res1: R1, res2: R2, res3: R3, res4: R4, res5: R5, res6: R6,
res7: R7, res8: R8) => T,
): OutputParametricSelector<S, P, T, (res1: R1, res2: R2, res3: R3, res4: R4, res5: R5, res6: R6,
res7: R7, res8: R8) => T>;
/* nine selectors */
export function createSelector<S, R1, R2, R3, R4, R5, R6, R7, R8, R9, T>(
selectors: [Selector<S, R1>,
Selector<S, R2>,
Selector<S, R3>,
Selector<S, R4>,
Selector<S, R5>,
Selector<S, R6>,
Selector<S, R7>,
Selector<S, R8>,
Selector<S, R9>],
combiner: (res1: R1, res2: R2, res3: R3, res4: R4, res5: R5, res6: R6,
res7: R7, res8: R8, res9: R9) => T,
): OutputSelector<S, T, (res1: R1, res2: R2, res3: R3, res4: R4, res5: R5, res6: R6,
res7: R7, res8: R8, res9: R9) => T>;
export function createSelector<S, P, R1, R2, R3, R4, R5, R6, R7, R8, R9, T>(
selectors: [ParametricSelector<S, P, R1>,
ParametricSelector<S, P, R2>,
ParametricSelector<S, P, R3>,
ParametricSelector<S, P, R4>,
ParametricSelector<S, P, R5>,
ParametricSelector<S, P, R6>,
ParametricSelector<S, P, R7>,
ParametricSelector<S, P, R8>,
ParametricSelector<S, P, R9>],
combiner: (res1: R1, res2: R2, res3: R3, res4: R4, res5: R5, res6: R6,
res7: R7, res8: R8, res9: R9) => T,
): OutputParametricSelector<S, P, T, (res1: R1, res2: R2, res3: R3, res4: R4, res5: R5, res6: R6,
res7: R7, res8: R8, res9: R9) => T>;
/* ten selectors */
export function createSelector<S, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, T>(
selectors: [Selector<S, R1>,
Selector<S, R2>,
Selector<S, R3>,
Selector<S, R4>,
Selector<S, R5>,
Selector<S, R6>,
Selector<S, R7>,
Selector<S, R8>,
Selector<S, R9>,
Selector<S, R10>],
combiner: (res1: R1, res2: R2, res3: R3, res4: R4, res5: R5, res6: R6,
res7: R7, res8: R8, res9: R9, res10: R10) => T,
): OutputSelector<S, T, (res1: R1, res2: R2, res3: R3, res4: R4, res5: R5, res6: R6,
res7: R7, res8: R8, res9: R9, res10: R10) => T>;
export function createSelector<S, P, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, T>(
selectors: [ParametricSelector<S, P, R1>,
ParametricSelector<S, P, R2>,
ParametricSelector<S, P, R3>,
ParametricSelector<S, P, R4>,
ParametricSelector<S, P, R5>,
ParametricSelector<S, P, R6>,
ParametricSelector<S, P, R7>,
ParametricSelector<S, P, R8>,
ParametricSelector<S, P, R9>,
ParametricSelector<S, P, R10>],
combiner: (res1: R1, res2: R2, res3: R3, res4: R4, res5: R5, res6: R6,
res7: R7, res8: R8, res9: R9, res10: R10) => T,
): OutputParametricSelector<S, P, T, (res1: R1, res2: R2, res3: R3, res4: R4, res5: R5, res6: R6,
res7: R7, res8: R8, res9: R9, res10: R10) => T>;
/* eleven selectors */
export function createSelector<S, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, T>(
selectors: [Selector<S, R1>,
Selector<S, R2>,
Selector<S, R3>,
Selector<S, R4>,
Selector<S, R5>,
Selector<S, R6>,
Selector<S, R7>,
Selector<S, R8>,
Selector<S, R9>,
Selector<S, R10>,
Selector<S, R11>],
combiner: (res1: R1, res2: R2, res3: R3, res4: R4, res5: R5, res6: R6,
res7: R7, res8: R8, res9: R9, res10: R10, res11: R11) => T,
): OutputSelector<S, T, (res1: R1, res2: R2, res3: R3, res4: R4, res5: R5, res6: R6,
res7: R7, res8: R8, res9: R9, res10: R10, res11: R11) => T>;
export function createSelector<S, P, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, T>(
selectors: [ParametricSelector<S, P, R1>,
ParametricSelector<S, P, R2>,
ParametricSelector<S, P, R3>,
ParametricSelector<S, P, R4>,
ParametricSelector<S, P, R5>,
ParametricSelector<S, P, R6>,
ParametricSelector<S, P, R7>,
ParametricSelector<S, P, R8>,
ParametricSelector<S, P, R9>,
ParametricSelector<S, P, R10>,
ParametricSelector<S, P, R11>],
combiner: (res1: R1, res2: R2, res3: R3, res4: R4, res5: R5, res6: R6,
res7: R7, res8: R8, res9: R9, res10: R10, res11: R11) => T,
): OutputParametricSelector<S, P, T, (res1: R1, res2: R2, res3: R3, res4: R4, res5: R5, res6: R6,
res7: R7, res8: R8, res9: R9, res10: R10, res11: R11) => T>;
/* twelve selectors */
export function createSelector<S, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, T>(
selectors: [Selector<S, R1>,
Selector<S, R2>,
Selector<S, R3>,
Selector<S, R4>,
Selector<S, R5>,
Selector<S, R6>,
Selector<S, R7>,
Selector<S, R8>,
Selector<S, R9>,
Selector<S, R10>,
Selector<S, R11>,
Selector<S, R12>],
combiner: (res1: R1, res2: R2, res3: R3, res4: R4, res5: R5, res6: R6,
res7: R7, res8: R8, res9: R9, res10: R10, res11: R11, res12: R12) => T,
): OutputSelector<S, T, (res1: R1, res2: R2, res3: R3, res4: R4, res5: R5, res6: R6,
res7: R7, res8: R8, res9: R9, res10: R10, res11: R11, res12: R12) => T>;
export function createSelector<S, P, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, T>(
selectors: [ParametricSelector<S, P, R1>,
ParametricSelector<S, P, R2>,
ParametricSelector<S, P, R3>,
ParametricSelector<S, P, R4>,
ParametricSelector<S, P, R5>,
ParametricSelector<S, P, R6>,
ParametricSelector<S, P, R7>,
ParametricSelector<S, P, R8>,
ParametricSelector<S, P, R9>,
ParametricSelector<S, P, R10>,
ParametricSelector<S, P, R11>,
ParametricSelector<S, P, R12>],
combiner: (res1: R1, res2: R2, res3: R3, res4: R4, res5: R5, res6: R6,
res7: R7, res8: R8, res9: R9, res10: R10, res11: R11, res12: R12) => T,
): OutputParametricSelector<S, P, T, (res1: R1, res2: R2, res3: R3, res4: R4, res5: R5, res6: R6,
res7: R7, res8: R8, res9: R9, res10: R10, res11: R11, res12: R12) => T>;
export function defaultMemoize<F extends Function>(
func: F, equalityCheck?: <T>(a: T, b: T, index: number) => boolean,
): F;
export function createSelectorCreator(
memoize: <F extends Function>(func: F) => F,
): typeof createSelector;
export function createSelectorCreator<O1>(
memoize: <F extends Function>(func: F,
option1: O1) => F,
option1: O1,
): typeof createSelector;
export function createSelectorCreator<O1, O2>(
memoize: <F extends Function>(func: F,
option1: O1,
option2: O2) => F,
option1: O1,
option2: O2,
): typeof createSelector;
export function createSelectorCreator<O1, O2, O3>(
memoize: <F extends Function>(func: F,
option1: O1,
option2: O2,
option3: O3,
...rest: any[]) => F,
option1: O1,
option2: O2,
option3: O3,
...rest: any[],
): typeof createSelector;
export function createStructuredSelector<S, T>(
selectors: {[K in keyof T]: Selector<S, T[K]>},
selectorCreator?: typeof createSelector,
): Selector<S, T>;
export function createStructuredSelector<S, P, T>(
selectors: {[K in keyof T]: ParametricSelector<S, P, T[K]>},
selectorCreator?: typeof createSelector,
): ParametricSelector<S, P, T>;

125
node_modules/reselect/lib/index.js generated vendored Normal file
View File

@ -0,0 +1,125 @@
'use strict';
exports.__esModule = true;
exports.defaultMemoize = defaultMemoize;
exports.createSelectorCreator = createSelectorCreator;
exports.createStructuredSelector = createStructuredSelector;
function defaultEqualityCheck(a, b) {
return a === b;
}
function areArgumentsShallowlyEqual(equalityCheck, prev, next) {
if (prev === null || next === null || prev.length !== next.length) {
return false;
}
// Do this in a for loop (and not a `forEach` or an `every`) so we can determine equality as fast as possible.
var length = prev.length;
for (var i = 0; i < length; i++) {
if (!equalityCheck(prev[i], next[i])) {
return false;
}
}
return true;
}
function defaultMemoize(func) {
var equalityCheck = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : defaultEqualityCheck;
var lastArgs = null;
var lastResult = null;
// we reference arguments instead of spreading them for performance reasons
return function () {
if (!areArgumentsShallowlyEqual(equalityCheck, lastArgs, arguments)) {
// apply arguments instead of spreading for performance.
lastResult = func.apply(null, arguments);
}
lastArgs = arguments;
return lastResult;
};
}
function getDependencies(funcs) {
var dependencies = Array.isArray(funcs[0]) ? funcs[0] : funcs;
if (!dependencies.every(function (dep) {
return typeof dep === 'function';
})) {
var dependencyTypes = dependencies.map(function (dep) {
return typeof dep;
}).join(', ');
throw new Error('Selector creators expect all input-selectors to be functions, ' + ('instead received the following types: [' + dependencyTypes + ']'));
}
return dependencies;
}
function createSelectorCreator(memoize) {
for (var _len = arguments.length, memoizeOptions = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
memoizeOptions[_key - 1] = arguments[_key];
}
return function () {
for (var _len2 = arguments.length, funcs = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
funcs[_key2] = arguments[_key2];
}
var recomputations = 0;
var resultFunc = funcs.pop();
var dependencies = getDependencies(funcs);
var memoizedResultFunc = memoize.apply(undefined, [function () {
recomputations++;
// apply arguments instead of spreading for performance.
return resultFunc.apply(null, arguments);
}].concat(memoizeOptions));
// If a selector is called with the exact same arguments we don't need to traverse our dependencies again.
var selector = defaultMemoize(function () {
var params = [];
var length = dependencies.length;
for (var i = 0; i < length; i++) {
// apply arguments instead of spreading and mutate a local list of params for performance.
params.push(dependencies[i].apply(null, arguments));
}
// apply arguments instead of spreading for performance.
return memoizedResultFunc.apply(null, params);
});
selector.resultFunc = resultFunc;
selector.recomputations = function () {
return recomputations;
};
selector.resetRecomputations = function () {
return recomputations = 0;
};
return selector;
};
}
var createSelector = exports.createSelector = createSelectorCreator(defaultMemoize);
function createStructuredSelector(selectors) {
var selectorCreator = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : createSelector;
if (typeof selectors !== 'object') {
throw new Error('createStructuredSelector expects first argument to be an object ' + ('where each property is a selector, instead received a ' + typeof selectors));
}
var objectKeys = Object.keys(selectors);
return selectorCreator(objectKeys.map(function (key) {
return selectors[key];
}), function () {
for (var _len3 = arguments.length, values = Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
values[_key3] = arguments[_key3];
}
return values.reduce(function (composition, value, index) {
composition[objectKeys[index]] = value;
return composition;
}, {});
});
}

675
node_modules/reselect/lib/index.js.flow generated vendored Normal file
View File

@ -0,0 +1,675 @@
type Selector<TState, TProps, TResult> = {
(state: TState, props: TProps, ...rest: any[]): TResult;
};
type SelectorCreator = {
<TState, TProps, TResult, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15>(
selector1: Selector<TState, TProps, T1>,
selector2: Selector<TState, TProps, T2>,
selector3: Selector<TState, TProps, T3>,
selector4: Selector<TState, TProps, T4>,
selector5: Selector<TState, TProps, T5>,
selector6: Selector<TState, TProps, T6>,
selector7: Selector<TState, TProps, T7>,
selector8: Selector<TState, TProps, T8>,
selector9: Selector<TState, TProps, T9>,
selector10: Selector<TState, TProps, T10>,
selector11: Selector<TState, TProps, T11>,
selector12: Selector<TState, TProps, T12>,
selector13: Selector<TState, TProps, T13>,
selector14: Selector<TState, TProps, T14>,
selector15: Selector<TState, TProps, T15>,
resultFunc: (
arg1: T1,
arg2: T2,
arg3: T3,
arg4: T4,
arg5: T5,
arg6: T6,
arg7: T7,
arg8: T8,
arg9: T9,
arg10: T10,
arg11: T11,
arg12: T12,
arg13: T13,
arg14: T14,
arg15: T15
) => TResult
): Selector<TState, TProps, TResult>;
<TState, TProps, TResult, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15>(
selectors: [
Selector<TState, TProps, T1>,
Selector<TState, TProps, T2>,
Selector<TState, TProps, T3>,
Selector<TState, TProps, T4>,
Selector<TState, TProps, T5>,
Selector<TState, TProps, T6>,
Selector<TState, TProps, T7>,
Selector<TState, TProps, T8>,
Selector<TState, TProps, T9>,
Selector<TState, TProps, T10>,
Selector<TState, TProps, T11>,
Selector<TState, TProps, T12>,
Selector<TState, TProps, T13>,
Selector<TState, TProps, T14>,
Selector<TState, TProps, T15>
],
resultFunc: (
arg1: T1,
arg2: T2,
arg3: T3,
arg4: T4,
arg5: T5,
arg6: T6,
arg7: T7,
arg8: T8,
arg9: T9,
arg10: T10,
arg11: T11,
arg12: T12,
arg13: T13,
arg14: T14,
arg15: T15
) => TResult
): Selector<TState, TProps, TResult>;
<TState, TProps, TResult, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14>(
selector1: Selector<TState, TProps, T1>,
selector2: Selector<TState, TProps, T2>,
selector3: Selector<TState, TProps, T3>,
selector4: Selector<TState, TProps, T4>,
selector5: Selector<TState, TProps, T5>,
selector6: Selector<TState, TProps, T6>,
selector7: Selector<TState, TProps, T7>,
selector8: Selector<TState, TProps, T8>,
selector9: Selector<TState, TProps, T9>,
selector10: Selector<TState, TProps, T10>,
selector11: Selector<TState, TProps, T11>,
selector12: Selector<TState, TProps, T12>,
selector13: Selector<TState, TProps, T13>,
selector14: Selector<TState, TProps, T14>,
resultFunc: (
arg1: T1,
arg2: T2,
arg3: T3,
arg4: T4,
arg5: T5,
arg6: T6,
arg7: T7,
arg8: T8,
arg9: T9,
arg10: T10,
arg11: T11,
arg12: T12,
arg13: T13,
arg14: T14
) => TResult
): Selector<TState, TProps, TResult>;
<TState, TProps, TResult, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14>(
selectors: [
Selector<TState, TProps, T1>,
Selector<TState, TProps, T2>,
Selector<TState, TProps, T3>,
Selector<TState, TProps, T4>,
Selector<TState, TProps, T5>,
Selector<TState, TProps, T6>,
Selector<TState, TProps, T7>,
Selector<TState, TProps, T8>,
Selector<TState, TProps, T9>,
Selector<TState, TProps, T10>,
Selector<TState, TProps, T11>,
Selector<TState, TProps, T12>,
Selector<TState, TProps, T13>,
Selector<TState, TProps, T14>
],
resultFunc: (
arg1: T1,
arg2: T2,
arg3: T3,
arg4: T4,
arg5: T5,
arg6: T6,
arg7: T7,
arg8: T8,
arg9: T9,
arg10: T10,
arg11: T11,
arg12: T12,
arg13: T13,
arg14: T14
) => TResult
): Selector<TState, TProps, TResult>;
<TState, TProps, TResult, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13>(
selector1: Selector<TState, TProps, T1>,
selector2: Selector<TState, TProps, T2>,
selector3: Selector<TState, TProps, T3>,
selector4: Selector<TState, TProps, T4>,
selector5: Selector<TState, TProps, T5>,
selector6: Selector<TState, TProps, T6>,
selector7: Selector<TState, TProps, T7>,
selector8: Selector<TState, TProps, T8>,
selector9: Selector<TState, TProps, T9>,
selector10: Selector<TState, TProps, T10>,
selector11: Selector<TState, TProps, T11>,
selector12: Selector<TState, TProps, T12>,
selector13: Selector<TState, TProps, T13>,
resultFunc: (
arg1: T1,
arg2: T2,
arg3: T3,
arg4: T4,
arg5: T5,
arg6: T6,
arg7: T7,
arg8: T8,
arg9: T9,
arg10: T10,
arg11: T11,
arg12: T12,
arg13: T13
) => TResult
): Selector<TState, TProps, TResult>;
<TState, TProps, TResult, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13>(
selectors: [
Selector<TState, TProps, T1>,
Selector<TState, TProps, T2>,
Selector<TState, TProps, T3>,
Selector<TState, TProps, T4>,
Selector<TState, TProps, T5>,
Selector<TState, TProps, T6>,
Selector<TState, TProps, T7>,
Selector<TState, TProps, T8>,
Selector<TState, TProps, T9>,
Selector<TState, TProps, T10>,
Selector<TState, TProps, T11>,
Selector<TState, TProps, T12>,
Selector<TState, TProps, T13>
],
resultFunc: (
arg1: T1,
arg2: T2,
arg3: T3,
arg4: T4,
arg5: T5,
arg6: T6,
arg7: T7,
arg8: T8,
arg9: T9,
arg10: T10,
arg11: T11,
arg12: T12,
arg13: T13
) => TResult
): Selector<TState, TProps, TResult>;
<TState, TProps, TResult, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>(
selector1: Selector<TState, TProps, T1>,
selector2: Selector<TState, TProps, T2>,
selector3: Selector<TState, TProps, T3>,
selector4: Selector<TState, TProps, T4>,
selector5: Selector<TState, TProps, T5>,
selector6: Selector<TState, TProps, T6>,
selector7: Selector<TState, TProps, T7>,
selector8: Selector<TState, TProps, T8>,
selector9: Selector<TState, TProps, T9>,
selector10: Selector<TState, TProps, T10>,
selector11: Selector<TState, TProps, T11>,
selector12: Selector<TState, TProps, T12>,
resultFunc: (
arg1: T1,
arg2: T2,
arg3: T3,
arg4: T4,
arg5: T5,
arg6: T6,
arg7: T7,
arg8: T8,
arg9: T9,
arg10: T10,
arg11: T11,
arg12: T12
) => TResult
): Selector<TState, TProps, TResult>;
<TState, TProps, TResult, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>(
selectors: [
Selector<TState, TProps, T1>,
Selector<TState, TProps, T2>,
Selector<TState, TProps, T3>,
Selector<TState, TProps, T4>,
Selector<TState, TProps, T5>,
Selector<TState, TProps, T6>,
Selector<TState, TProps, T7>,
Selector<TState, TProps, T8>,
Selector<TState, TProps, T9>,
Selector<TState, TProps, T10>,
Selector<TState, TProps, T11>,
Selector<TState, TProps, T12>
],
resultFunc: (
arg1: T1,
arg2: T2,
arg3: T3,
arg4: T4,
arg5: T5,
arg6: T6,
arg7: T7,
arg8: T8,
arg9: T9,
arg10: T10,
arg11: T11,
arg12: T12
) => TResult
): Selector<TState, TProps, TResult>;
<TState, TProps, TResult, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>(
selector1: Selector<TState, TProps, T1>,
selector2: Selector<TState, TProps, T2>,
selector3: Selector<TState, TProps, T3>,
selector4: Selector<TState, TProps, T4>,
selector5: Selector<TState, TProps, T5>,
selector6: Selector<TState, TProps, T6>,
selector7: Selector<TState, TProps, T7>,
selector8: Selector<TState, TProps, T8>,
selector9: Selector<TState, TProps, T9>,
selector10: Selector<TState, TProps, T10>,
selector11: Selector<TState, TProps, T11>,
resultFunc: (
arg1: T1,
arg2: T2,
arg3: T3,
arg4: T4,
arg5: T5,
arg6: T6,
arg7: T7,
arg8: T8,
arg9: T9,
arg10: T10,
arg11: T11
) => TResult
): Selector<TState, TProps, TResult>;
<TState, TProps, TResult, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>(
selectors: [
Selector<TState, TProps, T1>,
Selector<TState, TProps, T2>,
Selector<TState, TProps, T3>,
Selector<TState, TProps, T4>,
Selector<TState, TProps, T5>,
Selector<TState, TProps, T6>,
Selector<TState, TProps, T7>,
Selector<TState, TProps, T8>,
Selector<TState, TProps, T9>,
Selector<TState, TProps, T10>,
Selector<TState, TProps, T11>
],
resultFunc: (
arg1: T1,
arg2: T2,
arg3: T3,
arg4: T4,
arg5: T5,
arg6: T6,
arg7: T7,
arg8: T8,
arg9: T9,
arg10: T10,
arg11: T11
) => TResult
): Selector<TState, TProps, TResult>;
<TState, TProps, TResult, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>(
selector1: Selector<TState, TProps, T1>,
selector2: Selector<TState, TProps, T2>,
selector3: Selector<TState, TProps, T3>,
selector4: Selector<TState, TProps, T4>,
selector5: Selector<TState, TProps, T5>,
selector6: Selector<TState, TProps, T6>,
selector7: Selector<TState, TProps, T7>,
selector8: Selector<TState, TProps, T8>,
selector9: Selector<TState, TProps, T9>,
selector10: Selector<TState, TProps, T10>,
resultFunc: (
arg1: T1,
arg2: T2,
arg3: T3,
arg4: T4,
arg5: T5,
arg6: T6,
arg7: T7,
arg8: T8,
arg9: T9,
arg10: T10
) => TResult
): Selector<TState, TProps, TResult>;
<TState, TProps, TResult, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>(
selectors: [
Selector<TState, TProps, T1>,
Selector<TState, TProps, T2>,
Selector<TState, TProps, T3>,
Selector<TState, TProps, T4>,
Selector<TState, TProps, T5>,
Selector<TState, TProps, T6>,
Selector<TState, TProps, T7>,
Selector<TState, TProps, T8>,
Selector<TState, TProps, T9>,
Selector<TState, TProps, T10>
],
resultFunc: (
arg1: T1,
arg2: T2,
arg3: T3,
arg4: T4,
arg5: T5,
arg6: T6,
arg7: T7,
arg8: T8,
arg9: T9,
arg10: T10
) => TResult
): Selector<TState, TProps, TResult>;
<TState, TProps, TResult, T1, T2, T3, T4, T5, T6, T7, T8, T9>(
selector1: Selector<TState, TProps, T1>,
selector2: Selector<TState, TProps, T2>,
selector3: Selector<TState, TProps, T3>,
selector4: Selector<TState, TProps, T4>,
selector5: Selector<TState, TProps, T5>,
selector6: Selector<TState, TProps, T6>,
selector7: Selector<TState, TProps, T7>,
selector8: Selector<TState, TProps, T8>,
selector9: Selector<TState, TProps, T9>,
resultFunc: (
arg1: T1,
arg2: T2,
arg3: T3,
arg4: T4,
arg5: T5,
arg6: T6,
arg7: T7,
arg8: T8,
arg9: T9
) => TResult
): Selector<TState, TProps, TResult>;
<TState, TProps, TResult, T1, T2, T3, T4, T5, T6, T7, T8, T9>(
selectors: [
Selector<TState, TProps, T1>,
Selector<TState, TProps, T2>,
Selector<TState, TProps, T3>,
Selector<TState, TProps, T4>,
Selector<TState, TProps, T5>,
Selector<TState, TProps, T6>,
Selector<TState, TProps, T7>,
Selector<TState, TProps, T8>,
Selector<TState, TProps, T9>
],
resultFunc: (
arg1: T1,
arg2: T2,
arg3: T3,
arg4: T4,
arg5: T5,
arg6: T6,
arg7: T7,
arg8: T8,
arg9: T9
) => TResult
): Selector<TState, TProps, TResult>;
<TState, TProps, TResult, T1, T2, T3, T4, T5, T6, T7, T8>(
selector1: Selector<TState, TProps, T1>,
selector2: Selector<TState, TProps, T2>,
selector3: Selector<TState, TProps, T3>,
selector4: Selector<TState, TProps, T4>,
selector5: Selector<TState, TProps, T5>,
selector6: Selector<TState, TProps, T6>,
selector7: Selector<TState, TProps, T7>,
selector8: Selector<TState, TProps, T8>,
resultFunc: (
arg1: T1,
arg2: T2,
arg3: T3,
arg4: T4,
arg5: T5,
arg6: T6,
arg7: T7,
arg8: T8
) => TResult
): Selector<TState, TProps, TResult>;
<TState, TProps, TResult, T1, T2, T3, T4, T5, T6, T7, T8>(
selectors: [
Selector<TState, TProps, T1>,
Selector<TState, TProps, T2>,
Selector<TState, TProps, T3>,
Selector<TState, TProps, T4>,
Selector<TState, TProps, T5>,
Selector<TState, TProps, T6>,
Selector<TState, TProps, T7>,
Selector<TState, TProps, T8>
],
resultFunc: (
arg1: T1,
arg2: T2,
arg3: T3,
arg4: T4,
arg5: T5,
arg6: T6,
arg7: T7,
arg8: T8
) => TResult
): Selector<TState, TProps, TResult>;
<TState, TProps, TResult, T1, T2, T3, T4, T5, T6, T7>(
selector1: Selector<TState, TProps, T1>,
selector2: Selector<TState, TProps, T2>,
selector3: Selector<TState, TProps, T3>,
selector4: Selector<TState, TProps, T4>,
selector5: Selector<TState, TProps, T5>,
selector6: Selector<TState, TProps, T6>,
selector7: Selector<TState, TProps, T7>,
resultFunc: (
arg1: T1,
arg2: T2,
arg3: T3,
arg4: T4,
arg5: T5,
arg6: T6,
arg7: T7
) => TResult
): Selector<TState, TProps, TResult>;
<TState, TProps, TResult, T1, T2, T3, T4, T5, T6, T7>(
selectors: [
Selector<TState, TProps, T1>,
Selector<TState, TProps, T2>,
Selector<TState, TProps, T3>,
Selector<TState, TProps, T4>,
Selector<TState, TProps, T5>,
Selector<TState, TProps, T6>,
Selector<TState, TProps, T7>
],
resultFunc: (
arg1: T1,
arg2: T2,
arg3: T3,
arg4: T4,
arg5: T5,
arg6: T6,
arg7: T7
) => TResult
): Selector<TState, TProps, TResult>;
<TState, TProps, TResult, T1, T2, T3, T4, T5, T6>(
selector1: Selector<TState, TProps, T1>,
selector2: Selector<TState, TProps, T2>,
selector3: Selector<TState, TProps, T3>,
selector4: Selector<TState, TProps, T4>,
selector5: Selector<TState, TProps, T5>,
selector6: Selector<TState, TProps, T6>,
resultFunc: (
arg1: T1,
arg2: T2,
arg3: T3,
arg4: T4,
arg5: T5,
arg6: T6
) => TResult
): Selector<TState, TProps, TResult>;
<TState, TProps, TResult, T1, T2, T3, T4, T5, T6>(
selectors: [
Selector<TState, TProps, T1>,
Selector<TState, TProps, T2>,
Selector<TState, TProps, T3>,
Selector<TState, TProps, T4>,
Selector<TState, TProps, T5>,
Selector<TState, TProps, T6>
],
resultFunc: (
arg1: T1,
arg2: T2,
arg3: T3,
arg4: T4,
arg5: T5,
arg6: T6
) => TResult
): Selector<TState, TProps, TResult>;
<TState, TProps, TResult, T1, T2, T3, T4, T5>(
selector1: Selector<TState, TProps, T1>,
selector2: Selector<TState, TProps, T2>,
selector3: Selector<TState, TProps, T3>,
selector4: Selector<TState, TProps, T4>,
selector5: Selector<TState, TProps, T5>,
resultFunc: (
arg1: T1,
arg2: T2,
arg3: T3,
arg4: T4,
arg5: T5
) => TResult
): Selector<TState, TProps, TResult>;
<TState, TProps, TResult, T1, T2, T3, T4, T5>(
selectors: [
Selector<TState, TProps, T1>,
Selector<TState, TProps, T2>,
Selector<TState, TProps, T3>,
Selector<TState, TProps, T4>,
Selector<TState, TProps, T5>
],
resultFunc: (
arg1: T1,
arg2: T2,
arg3: T3,
arg4: T4,
arg5: T5
) => TResult
): Selector<TState, TProps, TResult>;
<TState, TProps, TResult, T1, T2, T3, T4>(
selector1: Selector<TState, TProps, T1>,
selector2: Selector<TState, TProps, T2>,
selector3: Selector<TState, TProps, T3>,
selector4: Selector<TState, TProps, T4>,
resultFunc: (
arg1: T1,
arg2: T2,
arg3: T3,
arg4: T4
) => TResult
): Selector<TState, TProps, TResult>;
<TState, TProps, TResult, T1, T2, T3, T4>(
selectors: [
Selector<TState, TProps, T1>,
Selector<TState, TProps, T2>,
Selector<TState, TProps, T3>,
Selector<TState, TProps, T4>
],
resultFunc: (
arg1: T1,
arg2: T2,
arg3: T3,
arg4: T4
) => TResult
): Selector<TState, TProps, TResult>;
<TState, TProps, TResult, T1, T2, T3>(
selector1: Selector<TState, TProps, T1>,
selector2: Selector<TState, TProps, T2>,
selector3: Selector<TState, TProps, T3>,
resultFunc: (
arg1: T1,
arg2: T2,
arg3: T3
) => TResult
): Selector<TState, TProps, TResult>;
<TState, TProps, TResult, T1, T2, T3>(
selectors: [
Selector<TState, TProps, T1>,
Selector<TState, TProps, T2>,
Selector<TState, TProps, T3>
],
resultFunc: (
arg1: T1,
arg2: T2,
arg3: T3
) => TResult
): Selector<TState, TProps, TResult>;
<TState, TProps, TResult, T1, T2>(
selector1: Selector<TState, TProps, T1>,
selector2: Selector<TState, TProps, T2>,
resultFunc: (
arg1: T1,
arg2: T2
) => TResult
): Selector<TState, TProps, TResult>;
<TState, TProps, TResult, T1, T2>(
selectors: [
Selector<TState, TProps, T1>,
Selector<TState, TProps, T2>
],
resultFunc: (
arg1: T1,
arg2: T2
) => TResult
): Selector<TState, TProps, TResult>;
<TState, TProps, TResult, T1>(
selector1: Selector<TState, TProps, T1>,
resultFunc: (
arg1: T1
) => TResult
): Selector<TState, TProps, TResult>;
<TState, TProps, TResult, T1>(
selectors: [
Selector<TState, TProps, T1>
],
resultFunc: (
arg1: T1
) => TResult
): Selector<TState, TProps, TResult>;
};
type Reselect = {
createSelector: SelectorCreator;
defaultMemoize: <TFunc: Function>(
func: TFunc,
equalityCheck?: (a: any, b: any) => boolean
) => TFunc;
createSelectorCreator: (
memoize: Function,
...memoizeOptions: any[]
) => SelectorCreator;
createStructuredSelector: <TState, TProps>(
inputSelectors: {
[k: string | number]: Selector<TState, TProps, any>
},
selectorCreator?: SelectorCreator
) => Selector<TState, TProps, any>;
};
declare module 'reselect' {
declare var exports: Reselect;
}

100
node_modules/reselect/package.json generated vendored Normal file
View File

@ -0,0 +1,100 @@
{
"name": "reselect",
"version": "3.0.1",
"description": "Selectors for Redux.",
"main": "lib/index.js",
"jsnext:main": "es/index.js",
"typings": "lib/index.d.ts",
"files": [
"lib",
"src",
"dist",
"es"
],
"bugs": {
"url": "https://github.com/reactjs/reselect/issues"
},
"scripts": {
"compile:commonjs": "better-npm-run compile:commonjs",
"compile:umd": "better-npm-run compile:umd",
"compile:es": "babel -d es/ src/",
"compile": "npm run compile:commonjs && npm run compile:umd && npm run compile:es",
"lint": "eslint src test",
"prepublish": "npm run compile",
"test": "better-npm-run test",
"test:cov": "better-npm-run test:cov",
"test:typescript": "better-npm-run test:typescript"
},
"betterScripts": {
"test": {
"command": "mocha --compilers js:babel-register --ui tdd --recursive",
"env": {
"NODE_ENV": "test"
}
},
"test:cov": {
"command": "nyc --reporter=lcov --reporter=text mocha --compilers js:babel-register --ui tdd",
"env": {
"NODE_ENV": "test",
"COVERAGE": "true"
}
},
"test:typescript": {
"command": "typings-tester --dir typescript_test"
},
"compile:commonjs": {
"command": "babel -d lib/ src/ && ncp ./src/index.d.ts ./lib/index.d.ts",
"env": {
"NODE_ENV": "commonjs"
}
},
"compile:umd": {
"command": "mkdirp dist/ && babel -o dist/reselect.js src/",
"env": {
"NODE_ENV": "umd"
}
}
},
"keywords": [
"react",
"redux"
],
"authors": [
"Lee Bannard",
"Robert Binna",
"Martijn Faassen",
"Philip Spitzlinger"
],
"repository": {
"type": "git",
"url": "https://github.com/reactjs/reselect.git"
},
"license": "MIT",
"devDependencies": {
"babel-cli": "^6.7.5",
"babel-plugin-check-es2015-constants": "^6.7.2",
"babel-plugin-transform-es2015-arrow-functions": "^6.5.2",
"babel-plugin-transform-es2015-block-scoping": "^6.7.1",
"babel-plugin-transform-es2015-function-name": "^6.5.0",
"babel-plugin-transform-es2015-modules-commonjs": "^6.7.4",
"babel-plugin-transform-es2015-modules-umd": "^6.6.5",
"babel-plugin-transform-es2015-parameters": "^6.7.0",
"babel-plugin-transform-es2015-shorthand-properties": "^6.5.0",
"babel-plugin-transform-es2015-spread": "^6.6.5",
"babel-plugin-transform-es2015-template-literals": "^6.6.5",
"babel-register": "^6.7.2",
"better-npm-run": "0.0.8",
"chai": "^3.0.0",
"codecov.io": "^0.1.6",
"coveralls": "^2.11.4",
"eslint": "^2.11",
"eslint-plugin-react": "^5.1.1",
"lodash.memoize": "^4.1.0",
"mkdirp": "^0.5.1",
"mocha": "^2.2.5",
"ncp": "^2.0.0",
"nyc": "^6.4.0",
"typescript": "^2.1.4",
"typings-tester": "^0.2.0"
}
}

617
node_modules/reselect/src/index.d.ts generated vendored Normal file
View File

@ -0,0 +1,617 @@
export as namespace Reselect;
export type Selector<S, R> = (state: S) => R;
export type OutputSelector<S, R, C> = Selector<S, R> & {
resultFunc: C;
recomputations: () => number;
resetRecomputations: () => number;
}
export type ParametricSelector<S, P, R> = (state: S, props: P, ...args: any[]) => R;
export type OutputParametricSelector<S, P, R, C> = ParametricSelector<S, P, R> & {
resultFunc: C;
recomputations: () => number;
resetRecomputations: () => number;
}
/* one selector */
export function createSelector<S, R1, T>(
selector: Selector<S, R1>,
combiner: (res: R1) => T,
): OutputSelector<S, T, (res: R1) => T>;
export function createSelector<S, P, R1, T>(
selector: ParametricSelector<S, P, R1>,
combiner: (res: R1) => T,
): OutputParametricSelector<S, P, T, (res: R1) => T>;
/* two selectors */
export function createSelector<S, R1, R2, T>(
selector1: Selector<S, R1>,
selector2: Selector<S, R2>,
combiner: (res1: R1, res2: R2) => T,
): OutputSelector<S, T, (res1: R1, res2: R2) => T>;
export function createSelector<S, P, R1, R2, T>(
selector1: ParametricSelector<S, P, R1>,
selector2: ParametricSelector<S, P, R2>,
combiner: (res1: R1, res2: R2) => T,
): OutputParametricSelector<S, P, T, (res1: R1, res2: R2) => T>;
/* three selectors */
export function createSelector<S, R1, R2, R3, T>(
selector1: Selector<S, R1>,
selector2: Selector<S, R2>,
selector3: Selector<S, R3>,
combiner: (res1: R1, res2: R2, res3: R3) => T,
): OutputSelector<S, T, (res1: R1, res2: R2, res3: R3) => T>;
export function createSelector<S, P, R1, R2, R3, T>(
selector1: ParametricSelector<S, P, R1>,
selector2: ParametricSelector<S, P, R2>,
selector3: ParametricSelector<S, P, R3>,
combiner: (res1: R1, res2: R2, res3: R3) => T,
): OutputParametricSelector<S, P, T, (res1: R1, res2: R2, res3: R3) => T>;
/* four selectors */
export function createSelector<S, R1, R2, R3, R4, T>(
selector1: Selector<S, R1>,
selector2: Selector<S, R2>,
selector3: Selector<S, R3>,
selector4: Selector<S, R4>,
combiner: (res1: R1, res2: R2, res3: R3, res4: R4) => T,
): OutputSelector<S, T, (res1: R1, res2: R2, res3: R3, res4: R4) => T>;
export function createSelector<S, P, R1, R2, R3, R4, T>(
selector1: ParametricSelector<S, P, R1>,
selector2: ParametricSelector<S, P, R2>,
selector3: ParametricSelector<S, P, R3>,
selector4: ParametricSelector<S, P, R4>,
combiner: (res1: R1, res2: R2, res3: R3, res4: R4) => T,
): OutputParametricSelector<S, P, T, (res1: R1, res2: R2, res3: R3, res4: R4) => T>;
/* five selectors */
export function createSelector<S, R1, R2, R3, R4, R5, T>(
selector1: Selector<S, R1>,
selector2: Selector<S, R2>,
selector3: Selector<S, R3>,
selector4: Selector<S, R4>,
selector5: Selector<S, R5>,
combiner: (res1: R1, res2: R2, res3: R3, res4: R4, res5: R5) => T,
): OutputSelector<S, T, (res1: R1, res2: R2, res3: R3, res4: R4, res5: R5) => T>;
export function createSelector<S, P, R1, R2, R3, R4, R5, T>(
selector1: ParametricSelector<S, P, R1>,
selector2: ParametricSelector<S, P, R2>,
selector3: ParametricSelector<S, P, R3>,
selector4: ParametricSelector<S, P, R4>,
selector5: ParametricSelector<S, P, R5>,
combiner: (res1: R1, res2: R2, res3: R3, res4: R4, res5: R5) => T,
): OutputParametricSelector<S, P, T, (res1: R1, res2: R2, res3: R3, res4: R4, res5: R5) => T>;
/* six selectors */
export function createSelector<S, R1, R2, R3, R4, R5, R6, T>(
selector1: Selector<S, R1>,
selector2: Selector<S, R2>,
selector3: Selector<S, R3>,
selector4: Selector<S, R4>,
selector5: Selector<S, R5>,
selector6: Selector<S, R6>,
combiner: (res1: R1, res2: R2, res3: R3, res4: R4, res5: R5, res6: R6) => T,
): OutputSelector<S, T, (res1: R1, res2: R2, res3: R3, res4: R4, res5: R5, res6: R6) => T>;
export function createSelector<S, P, R1, R2, R3, R4, R5, R6, T>(
selector1: ParametricSelector<S, P, R1>,
selector2: ParametricSelector<S, P, R2>,
selector3: ParametricSelector<S, P, R3>,
selector4: ParametricSelector<S, P, R4>,
selector5: ParametricSelector<S, P, R5>,
selector6: ParametricSelector<S, P, R6>,
combiner: (res1: R1, res2: R2, res3: R3, res4: R4, res5: R5, res6: R6) => T,
): OutputParametricSelector<S, P, T, (res1: R1, res2: R2, res3: R3, res4: R4, res5: R5, res6: R6) => T>;
/* seven selectors */
export function createSelector<S, R1, R2, R3, R4, R5, R6, R7, T>(
selector1: Selector<S, R1>,
selector2: Selector<S, R2>,
selector3: Selector<S, R3>,
selector4: Selector<S, R4>,
selector5: Selector<S, R5>,
selector6: Selector<S, R6>,
selector7: Selector<S, R7>,
combiner: (res1: R1, res2: R2, res3: R3, res4: R4, res5: R5, res6: R6,
res7: R7) => T,
): OutputSelector<S, T, (res1: R1, res2: R2, res3: R3, res4: R4, res5: R5, res6: R6,
res7: R7) => T>;
export function createSelector<S, P, R1, R2, R3, R4, R5, R6, R7, T>(
selector1: ParametricSelector<S, P, R1>,
selector2: ParametricSelector<S, P, R2>,
selector3: ParametricSelector<S, P, R3>,
selector4: ParametricSelector<S, P, R4>,
selector5: ParametricSelector<S, P, R5>,
selector6: ParametricSelector<S, P, R6>,
selector7: ParametricSelector<S, P, R7>,
combiner: (res1: R1, res2: R2, res3: R3, res4: R4, res5: R5, res6: R6,
res7: R7) => T,
): OutputParametricSelector<S, P, T, (res1: R1, res2: R2, res3: R3, res4: R4, res5: R5, res6: R6,
res7: R7) => T>;
/* eight selectors */
export function createSelector<S, R1, R2, R3, R4, R5, R6, R7, R8, T>(
selector1: Selector<S, R1>,
selector2: Selector<S, R2>,
selector3: Selector<S, R3>,
selector4: Selector<S, R4>,
selector5: Selector<S, R5>,
selector6: Selector<S, R6>,
selector7: Selector<S, R7>,
selector8: Selector<S, R8>,
combiner: (res1: R1, res2: R2, res3: R3, res4: R4, res5: R5, res6: R6,
res7: R7, res8: R8) => T,
): OutputSelector<S, T, (res1: R1, res2: R2, res3: R3, res4: R4, res5: R5, res6: R6,
res7: R7, res8: R8) => T>;
export function createSelector<S, P, R1, R2, R3, R4, R5, R6, R7, R8, T>(
selector1: ParametricSelector<S, P, R1>,
selector2: ParametricSelector<S, P, R2>,
selector3: ParametricSelector<S, P, R3>,
selector4: ParametricSelector<S, P, R4>,
selector5: ParametricSelector<S, P, R5>,
selector6: ParametricSelector<S, P, R6>,
selector7: ParametricSelector<S, P, R7>,
selector8: ParametricSelector<S, P, R8>,
combiner: (res1: R1, res2: R2, res3: R3, res4: R4, res5: R5, res6: R6,
res7: R7, res8: R8) => T,
): OutputParametricSelector<S, P, T, (res1: R1, res2: R2, res3: R3, res4: R4, res5: R5, res6: R6,
res7: R7, res8: R8) => T>;
/* nine selectors */
export function createSelector<S, R1, R2, R3, R4, R5, R6, R7, R8, R9, T>(
selector1: Selector<S, R1>,
selector2: Selector<S, R2>,
selector3: Selector<S, R3>,
selector4: Selector<S, R4>,
selector5: Selector<S, R5>,
selector6: Selector<S, R6>,
selector7: Selector<S, R7>,
selector8: Selector<S, R8>,
selector9: Selector<S, R9>,
combiner: (res1: R1, res2: R2, res3: R3, res4: R4, res5: R5, res6: R6,
res7: R7, res8: R8, res9: R9) => T,
): OutputSelector<S, T, (res1: R1, res2: R2, res3: R3, res4: R4, res5: R5, res6: R6,
res7: R7, res8: R8, res9: R9) => T>;
export function createSelector<S, P, R1, R2, R3, R4, R5, R6, R7, R8, R9, T>(
selector1: ParametricSelector<S, P, R1>,
selector2: ParametricSelector<S, P, R2>,
selector3: ParametricSelector<S, P, R3>,
selector4: ParametricSelector<S, P, R4>,
selector5: ParametricSelector<S, P, R5>,
selector6: ParametricSelector<S, P, R6>,
selector7: ParametricSelector<S, P, R7>,
selector8: ParametricSelector<S, P, R8>,
selector9: ParametricSelector<S, P, R9>,
combiner: (res1: R1, res2: R2, res3: R3, res4: R4, res5: R5, res6: R6,
res7: R7, res8: R8, res9: R9) => T,
): OutputParametricSelector<S, P, T, (res1: R1, res2: R2, res3: R3, res4: R4, res5: R5, res6: R6,
res7: R7, res8: R8, res9: R9) => T>;
/* ten selectors */
export function createSelector<S, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, T>(
selector1: Selector<S, R1>,
selector2: Selector<S, R2>,
selector3: Selector<S, R3>,
selector4: Selector<S, R4>,
selector5: Selector<S, R5>,
selector6: Selector<S, R6>,
selector7: Selector<S, R7>,
selector8: Selector<S, R8>,
selector9: Selector<S, R9>,
selector10: Selector<S, R10>,
combiner: (res1: R1, res2: R2, res3: R3, res4: R4, res5: R5, res6: R6,
res7: R7, res8: R8, res9: R9, res10: R10) => T,
): OutputSelector<S, T, (res1: R1, res2: R2, res3: R3, res4: R4, res5: R5, res6: R6,
res7: R7, res8: R8, res9: R9, res10: R10) => T>;
export function createSelector<S, P, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, T>(
selector1: ParametricSelector<S, P, R1>,
selector2: ParametricSelector<S, P, R2>,
selector3: ParametricSelector<S, P, R3>,
selector4: ParametricSelector<S, P, R4>,
selector5: ParametricSelector<S, P, R5>,
selector6: ParametricSelector<S, P, R6>,
selector7: ParametricSelector<S, P, R7>,
selector8: ParametricSelector<S, P, R8>,
selector9: ParametricSelector<S, P, R9>,
selector10: ParametricSelector<S, P, R10>,
combiner: (res1: R1, res2: R2, res3: R3, res4: R4, res5: R5, res6: R6,
res7: R7, res8: R8, res9: R9, res10: R10) => T,
): OutputParametricSelector<S, P, T, (res1: R1, res2: R2, res3: R3, res4: R4, res5: R5, res6: R6,
res7: R7, res8: R8, res9: R9, res10: R10) => T>;
/* eleven selectors */
export function createSelector<S, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, T>(
selector1: Selector<S, R1>,
selector2: Selector<S, R2>,
selector3: Selector<S, R3>,
selector4: Selector<S, R4>,
selector5: Selector<S, R5>,
selector6: Selector<S, R6>,
selector7: Selector<S, R7>,
selector8: Selector<S, R8>,
selector9: Selector<S, R9>,
selector10: Selector<S, R10>,
selector11: Selector<S, R11>,
combiner: (res1: R1, res2: R2, res3: R3, res4: R4, res5: R5, res6: R6,
res7: R7, res8: R8, res9: R9, res10: R10, res11: R11) => T,
): OutputSelector<S, T, (res1: R1, res2: R2, res3: R3, res4: R4, res5: R5, res6: R6,
res7: R7, res8: R8, res9: R9, res10: R10, res11: R11) => T>;
export function createSelector<S, P, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, T>(
selector1: ParametricSelector<S, P, R1>,
selector2: ParametricSelector<S, P, R2>,
selector3: ParametricSelector<S, P, R3>,
selector4: ParametricSelector<S, P, R4>,
selector5: ParametricSelector<S, P, R5>,
selector6: ParametricSelector<S, P, R6>,
selector7: ParametricSelector<S, P, R7>,
selector8: ParametricSelector<S, P, R8>,
selector9: ParametricSelector<S, P, R9>,
selector10: ParametricSelector<S, P, R10>,
selector11: ParametricSelector<S, P, R11>,
combiner: (res1: R1, res2: R2, res3: R3, res4: R4, res5: R5, res6: R6,
res7: R7, res8: R8, res9: R9, res10: R10, res11: R11) => T,
): OutputParametricSelector<S, P, T, (res1: R1, res2: R2, res3: R3, res4: R4, res5: R5, res6: R6,
res7: R7, res8: R8, res9: R9, res10: R10, res11: R11) => T>;
/* twelve selectors */
export function createSelector<S, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, T>(
selector1: Selector<S, R1>,
selector2: Selector<S, R2>,
selector3: Selector<S, R3>,
selector4: Selector<S, R4>,
selector5: Selector<S, R5>,
selector6: Selector<S, R6>,
selector7: Selector<S, R7>,
selector8: Selector<S, R8>,
selector9: Selector<S, R9>,
selector10: Selector<S, R10>,
selector11: Selector<S, R11>,
selector12: Selector<S, R12>,
combiner: (res1: R1, res2: R2, res3: R3, res4: R4, res5: R5, res6: R6,
res7: R7, res8: R8, res9: R9, res10: R10, res11: R11, res12: R12) => T,
): OutputSelector<S, T, (res1: R1, res2: R2, res3: R3, res4: R4, res5: R5, res6: R6,
res7: R7, res8: R8, res9: R9, res10: R10, res11: R11, res12: R12) => T>;
export function createSelector<S, P, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, T>(
selector1: ParametricSelector<S, P, R1>,
selector2: ParametricSelector<S, P, R2>,
selector3: ParametricSelector<S, P, R3>,
selector4: ParametricSelector<S, P, R4>,
selector5: ParametricSelector<S, P, R5>,
selector6: ParametricSelector<S, P, R6>,
selector7: ParametricSelector<S, P, R7>,
selector8: ParametricSelector<S, P, R8>,
selector9: ParametricSelector<S, P, R9>,
selector10: ParametricSelector<S, P, R10>,
selector11: ParametricSelector<S, P, R11>,
selector12: ParametricSelector<S, P, R12>,
combiner: (res1: R1, res2: R2, res3: R3, res4: R4, res5: R5, res6: R6,
res7: R7, res8: R8, res9: R9, res10: R10, res11: R11, res12: R12) => T,
): OutputParametricSelector<S, P, T, (res1: R1, res2: R2, res3: R3, res4: R4, res5: R5, res6: R6,
res7: R7, res8: R8, res9: R9, res10: R10, res11: R11, res12: R12) => T>;
/* array argument */
/* one selector */
export function createSelector<S, R1, T>(
selectors: [Selector<S, R1>],
combiner: (res: R1) => T,
): OutputSelector<S, T, (res: R1) => T>;
export function createSelector<S, P, R1, T>(
selectors: [ParametricSelector<S, P, R1>],
combiner: (res: R1) => T,
): OutputParametricSelector<S, P, T, (res: R1) => T>;
/* two selectors */
export function createSelector<S, R1, R2, T>(
selectors: [Selector<S, R1>,
Selector<S, R2>],
combiner: (res1: R1, res2: R2) => T,
): OutputSelector<S, T, (res1: R1, res2: R2) => T>;
export function createSelector<S, P, R1, R2, T>(
selectors: [ParametricSelector<S, P, R1>,
ParametricSelector<S, P, R2>],
combiner: (res1: R1, res2: R2) => T,
): OutputParametricSelector<S, P, T, (res1: R1, res2: R2) => T>;
/* three selectors */
export function createSelector<S, R1, R2, R3, T>(
selectors: [Selector<S, R1>,
Selector<S, R2>,
Selector<S, R3>],
combiner: (res1: R1, res2: R2, res3: R3) => T,
): OutputSelector<S, T, (res1: R1, res2: R2, res3: R3) => T>;
export function createSelector<S, P, R1, R2, R3, T>(
selectors: [ParametricSelector<S, P, R1>,
ParametricSelector<S, P, R2>,
ParametricSelector<S, P, R3>],
combiner: (res1: R1, res2: R2, res3: R3) => T,
): OutputParametricSelector<S, P, T, (res1: R1, res2: R2, res3: R3) => T>;
/* four selectors */
export function createSelector<S, R1, R2, R3, R4, T>(
selectors: [Selector<S, R1>,
Selector<S, R2>,
Selector<S, R3>,
Selector<S, R4>],
combiner: (res1: R1, res2: R2, res3: R3, res4: R4) => T,
): OutputSelector<S, T, (res1: R1, res2: R2, res3: R3, res4: R4) => T>;
export function createSelector<S, P, R1, R2, R3, R4, T>(
selectors: [ParametricSelector<S, P, R1>,
ParametricSelector<S, P, R2>,
ParametricSelector<S, P, R3>,
ParametricSelector<S, P, R4>],
combiner: (res1: R1, res2: R2, res3: R3, res4: R4) => T,
): OutputParametricSelector<S, P, T, (res1: R1, res2: R2, res3: R3, res4: R4) => T>;
/* five selectors */
export function createSelector<S, R1, R2, R3, R4, R5, T>(
selectors: [Selector<S, R1>,
Selector<S, R2>,
Selector<S, R3>,
Selector<S, R4>,
Selector<S, R5>],
combiner: (res1: R1, res2: R2, res3: R3, res4: R4, res5: R5) => T,
): OutputSelector<S, T, (res1: R1, res2: R2, res3: R3, res4: R4, res5: R5) => T>;
export function createSelector<S, P, R1, R2, R3, R4, R5, T>(
selectors: [ParametricSelector<S, P, R1>,
ParametricSelector<S, P, R2>,
ParametricSelector<S, P, R3>,
ParametricSelector<S, P, R4>,
ParametricSelector<S, P, R5>],
combiner: (res1: R1, res2: R2, res3: R3, res4: R4, res5: R5) => T,
): OutputParametricSelector<S, P, T, (res1: R1, res2: R2, res3: R3, res4: R4, res5: R5) => T>;
/* six selectors */
export function createSelector<S, R1, R2, R3, R4, R5, R6, T>(
selectors: [Selector<S, R1>,
Selector<S, R2>,
Selector<S, R3>,
Selector<S, R4>,
Selector<S, R5>,
Selector<S, R6>],
combiner: (res1: R1, res2: R2, res3: R3, res4: R4, res5: R5, res6: R6) => T,
): OutputSelector<S, T, (res1: R1, res2: R2, res3: R3, res4: R4, res5: R5, res6: R6) => T>;
export function createSelector<S, P, R1, R2, R3, R4, R5, R6, T>(
selectors: [ParametricSelector<S, P, R1>,
ParametricSelector<S, P, R2>,
ParametricSelector<S, P, R3>,
ParametricSelector<S, P, R4>,
ParametricSelector<S, P, R5>,
ParametricSelector<S, P, R6>],
combiner: (res1: R1, res2: R2, res3: R3, res4: R4, res5: R5, res6: R6) => T,
): OutputParametricSelector<S, P, T, (res1: R1, res2: R2, res3: R3, res4: R4, res5: R5, res6: R6) => T>;
/* seven selectors */
export function createSelector<S, R1, R2, R3, R4, R5, R6, R7, T>(
selectors: [Selector<S, R1>,
Selector<S, R2>,
Selector<S, R3>,
Selector<S, R4>,
Selector<S, R5>,
Selector<S, R6>,
Selector<S, R7>],
combiner: (res1: R1, res2: R2, res3: R3, res4: R4, res5: R5, res6: R6,
res7: R7) => T,
): OutputSelector<S, T, (res1: R1, res2: R2, res3: R3, res4: R4, res5: R5, res6: R6,
res7: R7) => T>;
export function createSelector<S, P, R1, R2, R3, R4, R5, R6, R7, T>(
selectors: [ParametricSelector<S, P, R1>,
ParametricSelector<S, P, R2>,
ParametricSelector<S, P, R3>,
ParametricSelector<S, P, R4>,
ParametricSelector<S, P, R5>,
ParametricSelector<S, P, R6>,
ParametricSelector<S, P, R7>],
combiner: (res1: R1, res2: R2, res3: R3, res4: R4, res5: R5, res6: R6,
res7: R7) => T,
): OutputParametricSelector<S, P, T, (res1: R1, res2: R2, res3: R3, res4: R4, res5: R5, res6: R6,
res7: R7) => T>;
/* eight selectors */
export function createSelector<S, R1, R2, R3, R4, R5, R6, R7, R8, T>(
selectors: [Selector<S, R1>,
Selector<S, R2>,
Selector<S, R3>,
Selector<S, R4>,
Selector<S, R5>,
Selector<S, R6>,
Selector<S, R7>,
Selector<S, R8>],
combiner: (res1: R1, res2: R2, res3: R3, res4: R4, res5: R5, res6: R6,
res7: R7, res8: R8) => T,
): OutputSelector<S, T, (res1: R1, res2: R2, res3: R3, res4: R4, res5: R5, res6: R6,
res7: R7, res8: R8) => T>;
export function createSelector<S, P, R1, R2, R3, R4, R5, R6, R7, R8, T>(
selectors: [ParametricSelector<S, P, R1>,
ParametricSelector<S, P, R2>,
ParametricSelector<S, P, R3>,
ParametricSelector<S, P, R4>,
ParametricSelector<S, P, R5>,
ParametricSelector<S, P, R6>,
ParametricSelector<S, P, R7>,
ParametricSelector<S, P, R8>],
combiner: (res1: R1, res2: R2, res3: R3, res4: R4, res5: R5, res6: R6,
res7: R7, res8: R8) => T,
): OutputParametricSelector<S, P, T, (res1: R1, res2: R2, res3: R3, res4: R4, res5: R5, res6: R6,
res7: R7, res8: R8) => T>;
/* nine selectors */
export function createSelector<S, R1, R2, R3, R4, R5, R6, R7, R8, R9, T>(
selectors: [Selector<S, R1>,
Selector<S, R2>,
Selector<S, R3>,
Selector<S, R4>,
Selector<S, R5>,
Selector<S, R6>,
Selector<S, R7>,
Selector<S, R8>,
Selector<S, R9>],
combiner: (res1: R1, res2: R2, res3: R3, res4: R4, res5: R5, res6: R6,
res7: R7, res8: R8, res9: R9) => T,
): OutputSelector<S, T, (res1: R1, res2: R2, res3: R3, res4: R4, res5: R5, res6: R6,
res7: R7, res8: R8, res9: R9) => T>;
export function createSelector<S, P, R1, R2, R3, R4, R5, R6, R7, R8, R9, T>(
selectors: [ParametricSelector<S, P, R1>,
ParametricSelector<S, P, R2>,
ParametricSelector<S, P, R3>,
ParametricSelector<S, P, R4>,
ParametricSelector<S, P, R5>,
ParametricSelector<S, P, R6>,
ParametricSelector<S, P, R7>,
ParametricSelector<S, P, R8>,
ParametricSelector<S, P, R9>],
combiner: (res1: R1, res2: R2, res3: R3, res4: R4, res5: R5, res6: R6,
res7: R7, res8: R8, res9: R9) => T,
): OutputParametricSelector<S, P, T, (res1: R1, res2: R2, res3: R3, res4: R4, res5: R5, res6: R6,
res7: R7, res8: R8, res9: R9) => T>;
/* ten selectors */
export function createSelector<S, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, T>(
selectors: [Selector<S, R1>,
Selector<S, R2>,
Selector<S, R3>,
Selector<S, R4>,
Selector<S, R5>,
Selector<S, R6>,
Selector<S, R7>,
Selector<S, R8>,
Selector<S, R9>,
Selector<S, R10>],
combiner: (res1: R1, res2: R2, res3: R3, res4: R4, res5: R5, res6: R6,
res7: R7, res8: R8, res9: R9, res10: R10) => T,
): OutputSelector<S, T, (res1: R1, res2: R2, res3: R3, res4: R4, res5: R5, res6: R6,
res7: R7, res8: R8, res9: R9, res10: R10) => T>;
export function createSelector<S, P, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, T>(
selectors: [ParametricSelector<S, P, R1>,
ParametricSelector<S, P, R2>,
ParametricSelector<S, P, R3>,
ParametricSelector<S, P, R4>,
ParametricSelector<S, P, R5>,
ParametricSelector<S, P, R6>,
ParametricSelector<S, P, R7>,
ParametricSelector<S, P, R8>,
ParametricSelector<S, P, R9>,
ParametricSelector<S, P, R10>],
combiner: (res1: R1, res2: R2, res3: R3, res4: R4, res5: R5, res6: R6,
res7: R7, res8: R8, res9: R9, res10: R10) => T,
): OutputParametricSelector<S, P, T, (res1: R1, res2: R2, res3: R3, res4: R4, res5: R5, res6: R6,
res7: R7, res8: R8, res9: R9, res10: R10) => T>;
/* eleven selectors */
export function createSelector<S, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, T>(
selectors: [Selector<S, R1>,
Selector<S, R2>,
Selector<S, R3>,
Selector<S, R4>,
Selector<S, R5>,
Selector<S, R6>,
Selector<S, R7>,
Selector<S, R8>,
Selector<S, R9>,
Selector<S, R10>,
Selector<S, R11>],
combiner: (res1: R1, res2: R2, res3: R3, res4: R4, res5: R5, res6: R6,
res7: R7, res8: R8, res9: R9, res10: R10, res11: R11) => T,
): OutputSelector<S, T, (res1: R1, res2: R2, res3: R3, res4: R4, res5: R5, res6: R6,
res7: R7, res8: R8, res9: R9, res10: R10, res11: R11) => T>;
export function createSelector<S, P, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, T>(
selectors: [ParametricSelector<S, P, R1>,
ParametricSelector<S, P, R2>,
ParametricSelector<S, P, R3>,
ParametricSelector<S, P, R4>,
ParametricSelector<S, P, R5>,
ParametricSelector<S, P, R6>,
ParametricSelector<S, P, R7>,
ParametricSelector<S, P, R8>,
ParametricSelector<S, P, R9>,
ParametricSelector<S, P, R10>,
ParametricSelector<S, P, R11>],
combiner: (res1: R1, res2: R2, res3: R3, res4: R4, res5: R5, res6: R6,
res7: R7, res8: R8, res9: R9, res10: R10, res11: R11) => T,
): OutputParametricSelector<S, P, T, (res1: R1, res2: R2, res3: R3, res4: R4, res5: R5, res6: R6,
res7: R7, res8: R8, res9: R9, res10: R10, res11: R11) => T>;
/* twelve selectors */
export function createSelector<S, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, T>(
selectors: [Selector<S, R1>,
Selector<S, R2>,
Selector<S, R3>,
Selector<S, R4>,
Selector<S, R5>,
Selector<S, R6>,
Selector<S, R7>,
Selector<S, R8>,
Selector<S, R9>,
Selector<S, R10>,
Selector<S, R11>,
Selector<S, R12>],
combiner: (res1: R1, res2: R2, res3: R3, res4: R4, res5: R5, res6: R6,
res7: R7, res8: R8, res9: R9, res10: R10, res11: R11, res12: R12) => T,
): OutputSelector<S, T, (res1: R1, res2: R2, res3: R3, res4: R4, res5: R5, res6: R6,
res7: R7, res8: R8, res9: R9, res10: R10, res11: R11, res12: R12) => T>;
export function createSelector<S, P, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, T>(
selectors: [ParametricSelector<S, P, R1>,
ParametricSelector<S, P, R2>,
ParametricSelector<S, P, R3>,
ParametricSelector<S, P, R4>,
ParametricSelector<S, P, R5>,
ParametricSelector<S, P, R6>,
ParametricSelector<S, P, R7>,
ParametricSelector<S, P, R8>,
ParametricSelector<S, P, R9>,
ParametricSelector<S, P, R10>,
ParametricSelector<S, P, R11>,
ParametricSelector<S, P, R12>],
combiner: (res1: R1, res2: R2, res3: R3, res4: R4, res5: R5, res6: R6,
res7: R7, res8: R8, res9: R9, res10: R10, res11: R11, res12: R12) => T,
): OutputParametricSelector<S, P, T, (res1: R1, res2: R2, res3: R3, res4: R4, res5: R5, res6: R6,
res7: R7, res8: R8, res9: R9, res10: R10, res11: R11, res12: R12) => T>;
export function defaultMemoize<F extends Function>(
func: F, equalityCheck?: <T>(a: T, b: T, index: number) => boolean,
): F;
export function createSelectorCreator(
memoize: <F extends Function>(func: F) => F,
): typeof createSelector;
export function createSelectorCreator<O1>(
memoize: <F extends Function>(func: F,
option1: O1) => F,
option1: O1,
): typeof createSelector;
export function createSelectorCreator<O1, O2>(
memoize: <F extends Function>(func: F,
option1: O1,
option2: O2) => F,
option1: O1,
option2: O2,
): typeof createSelector;
export function createSelectorCreator<O1, O2, O3>(
memoize: <F extends Function>(func: F,
option1: O1,
option2: O2,
option3: O3,
...rest: any[]) => F,
option1: O1,
option2: O2,
option3: O3,
...rest: any[],
): typeof createSelector;
export function createStructuredSelector<S, T>(
selectors: {[K in keyof T]: Selector<S, T[K]>},
selectorCreator?: typeof createSelector,
): Selector<S, T>;
export function createStructuredSelector<S, P, T>(
selectors: {[K in keyof T]: ParametricSelector<S, P, T[K]>},
selectorCreator?: typeof createSelector,
): ParametricSelector<S, P, T>;

107
node_modules/reselect/src/index.js generated vendored Normal file
View File

@ -0,0 +1,107 @@
function defaultEqualityCheck(a, b) {
return a === b
}
function areArgumentsShallowlyEqual(equalityCheck, prev, next) {
if (prev === null || next === null || prev.length !== next.length) {
return false
}
// Do this in a for loop (and not a `forEach` or an `every`) so we can determine equality as fast as possible.
const length = prev.length
for (let i = 0; i < length; i++) {
if (!equalityCheck(prev[i], next[i])) {
return false
}
}
return true
}
export function defaultMemoize(func, equalityCheck = defaultEqualityCheck) {
let lastArgs = null
let lastResult = null
// we reference arguments instead of spreading them for performance reasons
return function () {
if (!areArgumentsShallowlyEqual(equalityCheck, lastArgs, arguments)) {
// apply arguments instead of spreading for performance.
lastResult = func.apply(null, arguments)
}
lastArgs = arguments
return lastResult
}
}
function getDependencies(funcs) {
const dependencies = Array.isArray(funcs[0]) ? funcs[0] : funcs
if (!dependencies.every(dep => typeof dep === 'function')) {
const dependencyTypes = dependencies.map(
dep => typeof dep
).join(', ')
throw new Error(
'Selector creators expect all input-selectors to be functions, ' +
`instead received the following types: [${dependencyTypes}]`
)
}
return dependencies
}
export function createSelectorCreator(memoize, ...memoizeOptions) {
return (...funcs) => {
let recomputations = 0
const resultFunc = funcs.pop()
const dependencies = getDependencies(funcs)
const memoizedResultFunc = memoize(
function () {
recomputations++
// apply arguments instead of spreading for performance.
return resultFunc.apply(null, arguments)
},
...memoizeOptions
)
// If a selector is called with the exact same arguments we don't need to traverse our dependencies again.
const selector = defaultMemoize(function () {
const params = []
const length = dependencies.length
for (let i = 0; i < length; i++) {
// apply arguments instead of spreading and mutate a local list of params for performance.
params.push(dependencies[i].apply(null, arguments))
}
// apply arguments instead of spreading for performance.
return memoizedResultFunc.apply(null, params)
})
selector.resultFunc = resultFunc
selector.recomputations = () => recomputations
selector.resetRecomputations = () => recomputations = 0
return selector
}
}
export const createSelector = createSelectorCreator(defaultMemoize)
export function createStructuredSelector(selectors, selectorCreator = createSelector) {
if (typeof selectors !== 'object') {
throw new Error(
'createStructuredSelector expects first argument to be an object ' +
`where each property is a selector, instead received a ${typeof selectors}`
)
}
const objectKeys = Object.keys(selectors)
return selectorCreator(
objectKeys.map(key => selectors[key]),
(...values) => {
return values.reduce((composition, value, index) => {
composition[objectKeys[index]] = value
return composition
}, {})
}
)
}