1 | import type { Selector, GetParamsFromSelectors, OutputSelector, SelectorArray, SelectorResultArray, DropFirst, MergeParameters, Expand, ObjValueTuple, Head, Tail } from './types';
|
2 | export type { Selector, GetParamsFromSelectors, GetStateFromSelectors, OutputSelector, EqualityFn, SelectorArray, SelectorResultArray, ParametricSelector, OutputParametricSelector, OutputSelectorFields } from './types';
|
3 | import { defaultMemoize, defaultEqualityCheck, DefaultMemoizeOptions } from './defaultMemoize';
|
4 | export { defaultMemoize, defaultEqualityCheck };
|
5 | export type { DefaultMemoizeOptions };
|
6 | export declare function createSelectorCreator<
|
7 | /** Selectors will eventually accept some function to be memoized */
|
8 | F extends (...args: unknown[]) => unknown,
|
9 | /** A memoizer such as defaultMemoize that accepts a function + some possible options */
|
10 | MemoizeFunction extends (func: F, ...options: any[]) => F,
|
11 | /** The additional options arguments to the memoizer */
|
12 | MemoizeOptions extends unknown[] = DropFirst<Parameters<MemoizeFunction>>>(memoize: MemoizeFunction, ...memoizeOptionsFromArgs: DropFirst<Parameters<MemoizeFunction>>): CreateSelectorFunction<F, MemoizeFunction, MemoizeOptions, Expand<Pick<ReturnType<MemoizeFunction>, keyof ReturnType<MemoizeFunction>>>>;
|
13 | export interface CreateSelectorOptions<MemoizeOptions extends unknown[]> {
|
14 | memoizeOptions: MemoizeOptions[0] | MemoizeOptions;
|
15 | }
|
16 |
|
17 |
|
18 |
|
19 | export interface CreateSelectorFunction<F extends (...args: unknown[]) => unknown, MemoizeFunction extends (func: F, ...options: any[]) => F, MemoizeOptions extends unknown[] = DropFirst<Parameters<MemoizeFunction>>, Keys = Expand<Pick<ReturnType<MemoizeFunction>, keyof ReturnType<MemoizeFunction>>>> {
|
20 |
|
21 | <Selectors extends SelectorArray, Result>(...items: [
|
22 | ...Selectors,
|
23 | (...args: SelectorResultArray<Selectors>) => Result
|
24 | ]): OutputSelector<Selectors, Result, (...args: SelectorResultArray<Selectors>) => Result, GetParamsFromSelectors<Selectors>, Keys> & Keys;
|
25 |
|
26 | <Selectors extends SelectorArray, Result>(...items: [
|
27 | ...Selectors,
|
28 | (...args: SelectorResultArray<Selectors>) => Result,
|
29 | CreateSelectorOptions<MemoizeOptions>
|
30 | ]): OutputSelector<Selectors, Result, ((...args: SelectorResultArray<Selectors>) => Result), GetParamsFromSelectors<Selectors>, Keys> & Keys;
|
31 | /** Input selectors as a separate array */
|
32 | <Selectors extends SelectorArray, Result>(selectors: [...Selectors], combiner: (...args: SelectorResultArray<Selectors>) => Result, options?: CreateSelectorOptions<MemoizeOptions>): OutputSelector<Selectors, Result, (...args: SelectorResultArray<Selectors>) => Result, GetParamsFromSelectors<Selectors>, Keys> & Keys;
|
33 | }
|
34 | export declare const createSelector: CreateSelectorFunction<(...args: unknown[]) => unknown, typeof defaultMemoize, [equalityCheckOrOptions?: import("./types").EqualityFn | DefaultMemoizeOptions | undefined], {
|
35 | clearCache: () => void;
|
36 | }>;
|
37 | type SelectorsObject = {
|
38 | [key: string]: (...args: any[]) => any;
|
39 | };
|
40 | export interface StructuredSelectorCreator {
|
41 | <SelectorMap extends SelectorsObject, SelectorParams = MergeParameters<ObjValueTuple<SelectorMap>>>(selectorMap: SelectorMap, selectorCreator?: CreateSelectorFunction<any, any, any>): (state: Head<SelectorParams>, ...params: Tail<SelectorParams>) => {
|
42 | [Key in keyof SelectorMap]: ReturnType<SelectorMap[Key]>;
|
43 | };
|
44 | <State, Result = State>(selectors: {
|
45 | [K in keyof Result]: Selector<State, Result[K], never>;
|
46 | }, selectorCreator?: CreateSelectorFunction<any, any, any>): Selector<State, Result, never>;
|
47 | }
|
48 | export declare const createStructuredSelector: StructuredSelectorCreator;
|