This commit is contained in:
11
node_modules/reselect/es/defaultMemoize.d.ts
generated
vendored
Normal file
11
node_modules/reselect/es/defaultMemoize.d.ts
generated
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
import type { EqualityFn } from './types';
|
||||
export declare const defaultEqualityCheck: EqualityFn;
|
||||
export declare function createCacheKeyComparator(equalityCheck: EqualityFn): (prev: unknown[] | IArguments | null, next: unknown[] | IArguments | null) => boolean;
|
||||
export interface DefaultMemoizeOptions {
|
||||
equalityCheck?: EqualityFn;
|
||||
resultEqualityCheck?: EqualityFn;
|
||||
maxSize?: number;
|
||||
}
|
||||
export declare function defaultMemoize<F extends (...args: any[]) => any>(func: F, equalityCheckOrOptions?: EqualityFn | DefaultMemoizeOptions): F & {
|
||||
clearCache: () => void;
|
||||
};
|
||||
147
node_modules/reselect/es/defaultMemoize.js
generated
vendored
Normal file
147
node_modules/reselect/es/defaultMemoize.js
generated
vendored
Normal file
@@ -0,0 +1,147 @@
|
||||
// Cache implementation based on Erik Rasmussen's `lru-memoize`:
|
||||
// https://github.com/erikras/lru-memoize
|
||||
var NOT_FOUND = 'NOT_FOUND';
|
||||
|
||||
function createSingletonCache(equals) {
|
||||
var entry;
|
||||
return {
|
||||
get: function get(key) {
|
||||
if (entry && equals(entry.key, key)) {
|
||||
return entry.value;
|
||||
}
|
||||
|
||||
return NOT_FOUND;
|
||||
},
|
||||
put: function put(key, value) {
|
||||
entry = {
|
||||
key: key,
|
||||
value: value
|
||||
};
|
||||
},
|
||||
getEntries: function getEntries() {
|
||||
return entry ? [entry] : [];
|
||||
},
|
||||
clear: function clear() {
|
||||
entry = undefined;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function createLruCache(maxSize, equals) {
|
||||
var entries = [];
|
||||
|
||||
function get(key) {
|
||||
var cacheIndex = entries.findIndex(function (entry) {
|
||||
return equals(key, entry.key);
|
||||
}); // We found a cached entry
|
||||
|
||||
if (cacheIndex > -1) {
|
||||
var entry = entries[cacheIndex]; // Cached entry not at top of cache, move it to the top
|
||||
|
||||
if (cacheIndex > 0) {
|
||||
entries.splice(cacheIndex, 1);
|
||||
entries.unshift(entry);
|
||||
}
|
||||
|
||||
return entry.value;
|
||||
} // No entry found in cache, return sentinel
|
||||
|
||||
|
||||
return NOT_FOUND;
|
||||
}
|
||||
|
||||
function put(key, value) {
|
||||
if (get(key) === NOT_FOUND) {
|
||||
// TODO Is unshift slow?
|
||||
entries.unshift({
|
||||
key: key,
|
||||
value: value
|
||||
});
|
||||
|
||||
if (entries.length > maxSize) {
|
||||
entries.pop();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function getEntries() {
|
||||
return entries;
|
||||
}
|
||||
|
||||
function clear() {
|
||||
entries = [];
|
||||
}
|
||||
|
||||
return {
|
||||
get: get,
|
||||
put: put,
|
||||
getEntries: getEntries,
|
||||
clear: clear
|
||||
};
|
||||
}
|
||||
|
||||
export var defaultEqualityCheck = function defaultEqualityCheck(a, b) {
|
||||
return a === b;
|
||||
};
|
||||
export function createCacheKeyComparator(equalityCheck) {
|
||||
return function areArgumentsShallowlyEqual(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;
|
||||
};
|
||||
}
|
||||
// defaultMemoize now supports a configurable cache size with LRU behavior,
|
||||
// and optional comparison of the result value with existing values
|
||||
export function defaultMemoize(func, equalityCheckOrOptions) {
|
||||
var providedOptions = typeof equalityCheckOrOptions === 'object' ? equalityCheckOrOptions : {
|
||||
equalityCheck: equalityCheckOrOptions
|
||||
};
|
||||
var _providedOptions$equa = providedOptions.equalityCheck,
|
||||
equalityCheck = _providedOptions$equa === void 0 ? defaultEqualityCheck : _providedOptions$equa,
|
||||
_providedOptions$maxS = providedOptions.maxSize,
|
||||
maxSize = _providedOptions$maxS === void 0 ? 1 : _providedOptions$maxS,
|
||||
resultEqualityCheck = providedOptions.resultEqualityCheck;
|
||||
var comparator = createCacheKeyComparator(equalityCheck);
|
||||
var cache = maxSize === 1 ? createSingletonCache(comparator) : createLruCache(maxSize, comparator); // we reference arguments instead of spreading them for performance reasons
|
||||
|
||||
function memoized() {
|
||||
var value = cache.get(arguments);
|
||||
|
||||
if (value === NOT_FOUND) {
|
||||
// @ts-ignore
|
||||
value = func.apply(null, arguments);
|
||||
|
||||
if (resultEqualityCheck) {
|
||||
var entries = cache.getEntries();
|
||||
var matchingEntry = entries.find(function (entry) {
|
||||
return resultEqualityCheck(entry.value, value);
|
||||
});
|
||||
|
||||
if (matchingEntry) {
|
||||
value = matchingEntry.value;
|
||||
}
|
||||
}
|
||||
|
||||
cache.put(arguments, value);
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
memoized.clearCache = function () {
|
||||
return cache.clear();
|
||||
};
|
||||
|
||||
return memoized;
|
||||
}
|
||||
48
node_modules/reselect/es/index.d.ts
generated
vendored
Normal file
48
node_modules/reselect/es/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,48 @@
|
||||
import type { Selector, GetParamsFromSelectors, OutputSelector, SelectorArray, SelectorResultArray, DropFirst, MergeParameters, Expand, ObjValueTuple, Head, Tail } from './types';
|
||||
export type { Selector, GetParamsFromSelectors, GetStateFromSelectors, OutputSelector, EqualityFn, SelectorArray, SelectorResultArray, ParametricSelector, OutputParametricSelector, OutputSelectorFields } from './types';
|
||||
import { defaultMemoize, defaultEqualityCheck, DefaultMemoizeOptions } from './defaultMemoize';
|
||||
export { defaultMemoize, defaultEqualityCheck };
|
||||
export type { DefaultMemoizeOptions };
|
||||
export declare function createSelectorCreator<
|
||||
/** Selectors will eventually accept some function to be memoized */
|
||||
F extends (...args: unknown[]) => unknown,
|
||||
/** A memoizer such as defaultMemoize that accepts a function + some possible options */
|
||||
MemoizeFunction extends (func: F, ...options: any[]) => F,
|
||||
/** The additional options arguments to the memoizer */
|
||||
MemoizeOptions extends unknown[] = DropFirst<Parameters<MemoizeFunction>>>(memoize: MemoizeFunction, ...memoizeOptionsFromArgs: DropFirst<Parameters<MemoizeFunction>>): CreateSelectorFunction<F, MemoizeFunction, MemoizeOptions, Expand<Pick<ReturnType<MemoizeFunction>, keyof ReturnType<MemoizeFunction>>>>;
|
||||
export interface CreateSelectorOptions<MemoizeOptions extends unknown[]> {
|
||||
memoizeOptions: MemoizeOptions[0] | MemoizeOptions;
|
||||
}
|
||||
/**
|
||||
* An instance of createSelector, customized with a given memoize implementation
|
||||
*/
|
||||
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>>>> {
|
||||
/** Input selectors as separate inline arguments */
|
||||
<Selectors extends SelectorArray, Result>(...items: [
|
||||
...Selectors,
|
||||
(...args: SelectorResultArray<Selectors>) => Result
|
||||
]): OutputSelector<Selectors, Result, (...args: SelectorResultArray<Selectors>) => Result, GetParamsFromSelectors<Selectors>, Keys> & Keys;
|
||||
/** Input selectors as separate inline arguments with memoizeOptions passed */
|
||||
<Selectors extends SelectorArray, Result>(...items: [
|
||||
...Selectors,
|
||||
(...args: SelectorResultArray<Selectors>) => Result,
|
||||
CreateSelectorOptions<MemoizeOptions>
|
||||
]): OutputSelector<Selectors, Result, ((...args: SelectorResultArray<Selectors>) => Result), GetParamsFromSelectors<Selectors>, Keys> & Keys;
|
||||
/** Input selectors as a separate array */
|
||||
<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;
|
||||
}
|
||||
export declare const createSelector: CreateSelectorFunction<(...args: unknown[]) => unknown, typeof defaultMemoize, [equalityCheckOrOptions?: import("./types").EqualityFn | DefaultMemoizeOptions | undefined], {
|
||||
clearCache: () => void;
|
||||
}>;
|
||||
type SelectorsObject = {
|
||||
[key: string]: (...args: any[]) => any;
|
||||
};
|
||||
export interface StructuredSelectorCreator {
|
||||
<SelectorMap extends SelectorsObject, SelectorParams = MergeParameters<ObjValueTuple<SelectorMap>>>(selectorMap: SelectorMap, selectorCreator?: CreateSelectorFunction<any, any, any>): (state: Head<SelectorParams>, ...params: Tail<SelectorParams>) => {
|
||||
[Key in keyof SelectorMap]: ReturnType<SelectorMap[Key]>;
|
||||
};
|
||||
<State, Result = State>(selectors: {
|
||||
[K in keyof Result]: Selector<State, Result[K], never>;
|
||||
}, selectorCreator?: CreateSelectorFunction<any, any, any>): Selector<State, Result, never>;
|
||||
}
|
||||
export declare const createStructuredSelector: StructuredSelectorCreator;
|
||||
130
node_modules/reselect/es/index.js
generated
vendored
Normal file
130
node_modules/reselect/es/index.js
generated
vendored
Normal file
@@ -0,0 +1,130 @@
|
||||
import { defaultMemoize, defaultEqualityCheck } from './defaultMemoize';
|
||||
export { defaultMemoize, defaultEqualityCheck };
|
||||
|
||||
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 === 'function' ? "function " + (dep.name || 'unnamed') + "()" : typeof dep;
|
||||
}).join(', ');
|
||||
throw new Error("createSelector expects all input-selectors to be functions, but received the following types: [" + dependencyTypes + "]");
|
||||
}
|
||||
|
||||
return dependencies;
|
||||
}
|
||||
|
||||
export function createSelectorCreator(memoize) {
|
||||
for (var _len = arguments.length, memoizeOptionsFromArgs = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
||||
memoizeOptionsFromArgs[_key - 1] = arguments[_key];
|
||||
}
|
||||
|
||||
var createSelector = function createSelector() {
|
||||
for (var _len2 = arguments.length, funcs = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
||||
funcs[_key2] = arguments[_key2];
|
||||
}
|
||||
|
||||
var _recomputations = 0;
|
||||
|
||||
var _lastResult; // Due to the intricacies of rest params, we can't do an optional arg after `...funcs`.
|
||||
// So, start by declaring the default value here.
|
||||
// (And yes, the words 'memoize' and 'options' appear too many times in this next sequence.)
|
||||
|
||||
|
||||
var directlyPassedOptions = {
|
||||
memoizeOptions: undefined
|
||||
}; // Normally, the result func or "output selector" is the last arg
|
||||
|
||||
var resultFunc = funcs.pop(); // If the result func is actually an _object_, assume it's our options object
|
||||
|
||||
if (typeof resultFunc === 'object') {
|
||||
directlyPassedOptions = resultFunc; // and pop the real result func off
|
||||
|
||||
resultFunc = funcs.pop();
|
||||
}
|
||||
|
||||
if (typeof resultFunc !== 'function') {
|
||||
throw new Error("createSelector expects an output function after the inputs, but received: [" + typeof resultFunc + "]");
|
||||
} // Determine which set of options we're using. Prefer options passed directly,
|
||||
// but fall back to options given to createSelectorCreator.
|
||||
|
||||
|
||||
var _directlyPassedOption = directlyPassedOptions,
|
||||
_directlyPassedOption2 = _directlyPassedOption.memoizeOptions,
|
||||
memoizeOptions = _directlyPassedOption2 === void 0 ? memoizeOptionsFromArgs : _directlyPassedOption2; // Simplifying assumption: it's unlikely that the first options arg of the provided memoizer
|
||||
// is an array. In most libs I've looked at, it's an equality function or options object.
|
||||
// Based on that, if `memoizeOptions` _is_ an array, we assume it's a full
|
||||
// user-provided array of options. Otherwise, it must be just the _first_ arg, and so
|
||||
// we wrap it in an array so we can apply it.
|
||||
|
||||
var finalMemoizeOptions = Array.isArray(memoizeOptions) ? memoizeOptions : [memoizeOptions];
|
||||
var dependencies = getDependencies(funcs);
|
||||
var memoizedResultFunc = memoize.apply(void 0, [function recomputationWrapper() {
|
||||
_recomputations++; // apply arguments instead of spreading for performance.
|
||||
|
||||
return resultFunc.apply(null, arguments);
|
||||
}].concat(finalMemoizeOptions)); // If a selector is called with the exact same arguments we don't need to traverse our dependencies again.
|
||||
|
||||
var selector = memoize(function dependenciesChecker() {
|
||||
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.
|
||||
// @ts-ignore
|
||||
params.push(dependencies[i].apply(null, arguments));
|
||||
} // apply arguments instead of spreading for performance.
|
||||
|
||||
|
||||
_lastResult = memoizedResultFunc.apply(null, params);
|
||||
return _lastResult;
|
||||
});
|
||||
Object.assign(selector, {
|
||||
resultFunc: resultFunc,
|
||||
memoizedResultFunc: memoizedResultFunc,
|
||||
dependencies: dependencies,
|
||||
lastResult: function lastResult() {
|
||||
return _lastResult;
|
||||
},
|
||||
recomputations: function recomputations() {
|
||||
return _recomputations;
|
||||
},
|
||||
resetRecomputations: function resetRecomputations() {
|
||||
return _recomputations = 0;
|
||||
}
|
||||
});
|
||||
return selector;
|
||||
}; // @ts-ignore
|
||||
|
||||
|
||||
return createSelector;
|
||||
}
|
||||
export var createSelector = /* #__PURE__ */createSelectorCreator(defaultMemoize);
|
||||
// Manual definition of state and output arguments
|
||||
export var createStructuredSelector = function createStructuredSelector(selectors, selectorCreator) {
|
||||
if (selectorCreator === void 0) {
|
||||
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));
|
||||
}
|
||||
|
||||
var objectKeys = Object.keys(selectors);
|
||||
var resultSelector = selectorCreator( // @ts-ignore
|
||||
objectKeys.map(function (key) {
|
||||
return selectors[key];
|
||||
}), function () {
|
||||
for (var _len3 = arguments.length, values = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
|
||||
values[_key3] = arguments[_key3];
|
||||
}
|
||||
|
||||
return values.reduce(function (composition, value, index) {
|
||||
composition[objectKeys[index]] = value;
|
||||
return composition;
|
||||
}, {});
|
||||
});
|
||||
return resultSelector;
|
||||
};
|
||||
142
node_modules/reselect/es/types.d.ts
generated
vendored
Normal file
142
node_modules/reselect/es/types.d.ts
generated
vendored
Normal file
@@ -0,0 +1,142 @@
|
||||
import type { MergeParameters } from './versionedTypes';
|
||||
export type { MergeParameters } from './versionedTypes';
|
||||
/** A standard selector function, which takes three generic type arguments:
|
||||
* @param State The first value, often a Redux root state object
|
||||
* @param Result The final result returned by the selector
|
||||
* @param Params All additional arguments passed into the selector
|
||||
*/
|
||||
export type Selector<State = any, Result = unknown, Params extends never | readonly any[] = any[]> = [Params] extends [never] ? (state: State) => Result : (state: State, ...params: Params) => Result;
|
||||
/** Selectors generated by Reselect have several additional fields attached: */
|
||||
export interface OutputSelectorFields<Combiner extends UnknownFunction, Keys> {
|
||||
/** The final function passed to `createSelector` */
|
||||
resultFunc: Combiner;
|
||||
/** The same function, memoized */
|
||||
memoizedResultFunc: Combiner & Keys;
|
||||
/** Returns the last result calculated by the selector */
|
||||
lastResult: () => ReturnType<Combiner>;
|
||||
/** An array of the input selectors */
|
||||
dependencies: SelectorArray;
|
||||
/** Counts the number of times the output has been recalculated */
|
||||
recomputations: () => number;
|
||||
/** Resets the count of recomputations count to 0 */
|
||||
resetRecomputations: () => number;
|
||||
}
|
||||
/** Represents the actual selectors generated by `createSelector`.
|
||||
* The selector is:
|
||||
* - "a function that takes this state + params and returns a result"
|
||||
* - plus the attached additional fields
|
||||
*/
|
||||
export type OutputSelector<S extends SelectorArray, Result, Combiner extends UnknownFunction, Params extends readonly any[] = never, // MergeParameters<S>
|
||||
Keys = {}> = Selector<GetStateFromSelectors<S>, Result, Params> & OutputSelectorFields<Combiner, Keys>;
|
||||
/** A selector that is assumed to have one additional argument, such as
|
||||
* the props from a React component
|
||||
*/
|
||||
export type ParametricSelector<State, Props, Result> = Selector<State, Result, [
|
||||
Props,
|
||||
...any
|
||||
]>;
|
||||
/** A generated selector that is assumed to have one additional argument */
|
||||
export type OutputParametricSelector<State, Props, Result, Combiner extends UnknownFunction, Keys = {}> = ParametricSelector<State, Props, Result> & OutputSelectorFields<Combiner, Keys>;
|
||||
/** An array of input selectors */
|
||||
export type SelectorArray = ReadonlyArray<Selector>;
|
||||
/** A standard function returning true if two values are considered equal */
|
||||
export type EqualityFn = (a: any, b: any) => boolean;
|
||||
/** Extracts an array of all return types from all input selectors */
|
||||
export type SelectorResultArray<Selectors extends SelectorArray> = ExtractReturnType<Selectors>;
|
||||
/** Determines the combined single "State" type (first arg) from all input selectors */
|
||||
export type GetStateFromSelectors<S extends SelectorArray> = MergeParameters<S>[0];
|
||||
/** Determines the combined "Params" type (all remaining args) from all input selectors */
|
||||
export type GetParamsFromSelectors<S extends SelectorArray, RemainingItems extends readonly unknown[] = Tail<MergeParameters<S>>> = RemainingItems;
|
||||
/** Any function with arguments */
|
||||
export type UnknownFunction = (...args: any[]) => any;
|
||||
/** Extract the return type from all functions as a tuple */
|
||||
export type ExtractReturnType<T extends readonly UnknownFunction[]> = {
|
||||
[index in keyof T]: T[index] extends T[number] ? ReturnType<T[index]> : never;
|
||||
};
|
||||
/** First item in an array */
|
||||
export type Head<T> = T extends [any, ...any[]] ? T[0] : never;
|
||||
/** All other items in an array */
|
||||
export type Tail<A> = A extends [any, ...infer Rest] ? Rest : never;
|
||||
/** Last item in an array. Recursion also enables this to work with rest syntax - where the type of rest is extracted */
|
||||
export type ReverseHead<S extends readonly unknown[][]> = Tail<S> extends [
|
||||
unknown
|
||||
] ? S : Tail<S> extends readonly unknown[][] ? ReverseHead<Tail<S>> : never;
|
||||
/** All elements in array except last
|
||||
*
|
||||
* Recursion makes this work also when rest syntax has been used
|
||||
* Runs _ReverseTail twice, because first pass turns last element into "never", and second pass removes it.
|
||||
**/
|
||||
export type ReverseTail<S> = _ReverseTail<_ReverseTail<S>>;
|
||||
type _ReverseTail<S> = Tail<S> extends [unknown] ? [Head<S>] : Tail<S> extends unknown[] ? [Head<S>, ..._ReverseTail<Tail<S>>] : never;
|
||||
/** Extract only numeric keys from an array type */
|
||||
export type AllArrayKeys<A extends readonly any[]> = A extends any ? {
|
||||
[K in keyof A]: K;
|
||||
}[number] : never;
|
||||
export type List<A = any> = ReadonlyArray<A>;
|
||||
export type Has<U, U1> = [U1] extends [U] ? 1 : 0;
|
||||
/** The infamous "convert a union type to an intersection type" hack
|
||||
* Source: https://github.com/sindresorhus/type-fest/blob/main/source/union-to-intersection.d.ts
|
||||
* Reference: https://github.com/microsoft/TypeScript/issues/29594
|
||||
*/
|
||||
export type UnionToIntersection<Union> = (Union extends unknown ? (distributedUnion: Union) => void : never) extends (mergedIntersection: infer Intersection) => void ? Intersection : never;
|
||||
/**
|
||||
* Assorted util types for type-level conditional logic
|
||||
* Source: https://github.com/KiaraGrouwstra/typical
|
||||
*/
|
||||
export type Bool = '0' | '1';
|
||||
export type Obj<T> = {
|
||||
[k: string]: T;
|
||||
};
|
||||
export type And<A extends Bool, B extends Bool> = ({
|
||||
1: {
|
||||
1: '1';
|
||||
} & Obj<'0'>;
|
||||
} & Obj<Obj<'0'>>)[A][B];
|
||||
export type Matches<V, T> = V extends T ? '1' : '0';
|
||||
export type IsArrayType<T> = Matches<T, any[]>;
|
||||
export type Not<T extends Bool> = {
|
||||
'1': '0';
|
||||
'0': '1';
|
||||
}[T];
|
||||
export type InstanceOf<V, T> = And<Matches<V, T>, Not<Matches<T, V>>>;
|
||||
export type IsTuple<T extends {
|
||||
length: number;
|
||||
}> = And<IsArrayType<T>, InstanceOf<T['length'], number>>;
|
||||
/**
|
||||
* Code to convert a union of values into a tuple.
|
||||
* Source: https://stackoverflow.com/a/55128956/62937
|
||||
*/
|
||||
type Push<T extends any[], V> = [...T, V];
|
||||
type LastOf<T> = UnionToIntersection<T extends any ? () => T : never> extends () => infer R ? R : never;
|
||||
export type TuplifyUnion<T, L = LastOf<T>, N = [T] extends [never] ? true : false> = true extends N ? [] : Push<TuplifyUnion<Exclude<T, L>>, L>;
|
||||
/**
|
||||
* Converts "the values of an object" into a tuple, like a type-level `Object.values()`
|
||||
* Source: https://stackoverflow.com/a/68695508/62937
|
||||
*/
|
||||
export type ObjValueTuple<T, KS extends any[] = TuplifyUnion<keyof T>, R extends any[] = []> = KS extends [infer K, ...infer KT] ? ObjValueTuple<T, KT, [...R, T[K & keyof T]]> : R;
|
||||
/** Utility type to infer the type of "all params of a function except the first", so we can determine what arguments a memoize function accepts */
|
||||
export type DropFirst<T extends unknown[]> = T extends [unknown, ...infer U] ? U : never;
|
||||
/**
|
||||
* Expand an item a single level, or recursively.
|
||||
* Source: https://stackoverflow.com/a/69288824/62937
|
||||
*/
|
||||
export type Expand<T> = T extends (...args: infer A) => infer R ? (...args: Expand<A>) => Expand<R> : T extends infer O ? {
|
||||
[K in keyof O]: O[K];
|
||||
} : never;
|
||||
export type ExpandRecursively<T> = T extends (...args: infer A) => infer R ? (...args: ExpandRecursively<A>) => ExpandRecursively<R> : T extends object ? T extends infer O ? {
|
||||
[K in keyof O]: ExpandRecursively<O[K]>;
|
||||
} : never : T;
|
||||
type Identity<T> = T;
|
||||
/**
|
||||
* Another form of type value expansion
|
||||
* Source: https://github.com/microsoft/TypeScript/issues/35247
|
||||
*/
|
||||
export type Mapped<T> = Identity<{
|
||||
[k in keyof T]: T[k];
|
||||
}>;
|
||||
export type If2<B extends Boolean2, Then, Else = never> = B extends 1 ? Then : Else;
|
||||
export type Boolean2 = 0 | 1;
|
||||
export type Key = string | number | symbol;
|
||||
export type BuiltIn = Function | Error | Date | {
|
||||
readonly [Symbol.toStringTag]: string;
|
||||
} | RegExp | Generator;
|
||||
1
node_modules/reselect/es/versionedTypes/index.d.ts
generated
vendored
Normal file
1
node_modules/reselect/es/versionedTypes/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export { MergeParameters } from './ts47-mergeParameters';
|
||||
14
node_modules/reselect/es/versionedTypes/package.json
generated
vendored
Normal file
14
node_modules/reselect/es/versionedTypes/package.json
generated
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"typesVersions": {
|
||||
">=4.7": {
|
||||
"index": [
|
||||
"./ts47-mergeParameters.d.ts"
|
||||
]
|
||||
},
|
||||
"<4.7": {
|
||||
"index": [
|
||||
"./ts46-mergeParameters.d.ts"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
61
node_modules/reselect/es/versionedTypes/ts46-mergeParameters.d.ts
generated
vendored
Normal file
61
node_modules/reselect/es/versionedTypes/ts46-mergeParameters.d.ts
generated
vendored
Normal file
@@ -0,0 +1,61 @@
|
||||
import type { UnknownFunction, Expand, TuplifyUnion, Has, List, IsTuple } from '../types';
|
||||
/** Given a set of input selectors, extracts the intersected parameters to determine
|
||||
* what values can actually be passed to all of the input selectors at once
|
||||
* WARNING: "you are not expected to understand this" :)
|
||||
*/
|
||||
export type MergeParameters<T extends readonly UnknownFunction[], ParamsArrays extends readonly any[][] = ExtractParams<T>, TransposedArrays = Transpose<ParamsArrays>, TuplifiedArrays extends any[] = TuplifyUnion<TransposedArrays>, LongestParamsArray extends readonly any[] = LongestArray<TuplifiedArrays>> = ExpandItems<RemoveNames<{
|
||||
[index in keyof LongestParamsArray]: LongestParamsArray[index] extends LongestParamsArray[number] ? IgnoreInvalidIntersections<IntersectAll<LongestParamsArray[index]>> : never;
|
||||
}>>;
|
||||
/** An object with no fields */
|
||||
type EmptyObject = {
|
||||
[K in any]: never;
|
||||
};
|
||||
type IgnoreInvalidIntersections<T> = T extends EmptyObject ? never : T;
|
||||
/** Extract the parameters from all functions as a tuple */
|
||||
export type ExtractParams<T extends readonly UnknownFunction[]> = {
|
||||
[index in keyof T]: T[index] extends T[number] ? Parameters<T[index]> : never;
|
||||
};
|
||||
/** Recursively expand all fields in an object for easier reading */
|
||||
export type ExpandItems<T extends readonly unknown[]> = {
|
||||
[index in keyof T]: T[index] extends T[number] ? Expand<T[index]> : never;
|
||||
};
|
||||
/** Select the longer of two arrays */
|
||||
export type Longest<L extends List, L1 extends List> = L extends unknown ? L1 extends unknown ? {
|
||||
0: L1;
|
||||
1: L;
|
||||
}[Has<keyof L, keyof L1>] : never : never;
|
||||
/** Recurse over a nested array to locate the longest one.
|
||||
* Acts like a type-level `reduce()`
|
||||
*/
|
||||
export type LongestArray<S extends readonly any[][]> = IsTuple<S> extends '0' ? S[0] : S extends [any[], any[]] ? Longest<S[0], S[1]> : S extends [any[], any[], ...infer Rest] ? Longest<Longest<S[0], S[1]>, Rest extends any[][] ? LongestArray<Rest> : []> : S extends [any[]] ? S[0] : never;
|
||||
/** Recursive type for intersecting together all items in a tuple, to determine
|
||||
* the final parameter type at a given argument index in the generated selector. */
|
||||
export type IntersectAll<T extends any[]> = IsTuple<T> extends '0' ? T[0] : _IntersectAll<T>;
|
||||
type IfJustNullish<T, True, False> = [T] extends [undefined | null] ? True : False;
|
||||
/** Intersect a pair of types together, for use in parameter type calculation.
|
||||
* This is made much more complex because we need to correctly handle cases
|
||||
* where a function has fewer parameters and the type is `undefined`, as well as
|
||||
* optional params or params that have `null` or `undefined` as part of a union.
|
||||
*
|
||||
* If the next type by itself is `null` or `undefined`, we exclude it and return
|
||||
* the other type. Otherwise, intersect them together.
|
||||
*/
|
||||
type _IntersectAll<T, R = unknown> = T extends [infer First, ...infer Rest] ? _IntersectAll<Rest, IfJustNullish<First, R, R & First>> : R;
|
||||
/**
|
||||
* Removes field names from a tuple
|
||||
* Source: https://stackoverflow.com/a/63571175/62937
|
||||
*/
|
||||
type RemoveNames<T extends readonly any[]> = [any, ...T] extends [
|
||||
any,
|
||||
...infer U
|
||||
] ? U : never;
|
||||
/**
|
||||
* Transposes nested arrays
|
||||
* Source: https://stackoverflow.com/a/66303933/62937
|
||||
*/
|
||||
type Transpose<T> = T[Extract<keyof T, T extends readonly any[] ? number : unknown>] extends infer V ? {
|
||||
[K in keyof V]: {
|
||||
[L in keyof T]: K extends keyof T[L] ? T[L][K] : undefined;
|
||||
};
|
||||
} : never;
|
||||
export {};
|
||||
24
node_modules/reselect/es/versionedTypes/ts47-mergeParameters.d.ts
generated
vendored
Normal file
24
node_modules/reselect/es/versionedTypes/ts47-mergeParameters.d.ts
generated
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
import { ReverseHead, ReverseTail } from '../types';
|
||||
type UnknownFunction = (...args: any[]) => any;
|
||||
type LongestTuple<T> = T extends [infer U extends unknown[]] ? U : T extends [infer U, ...infer R extends unknown[][]] ? MostProperties<U, LongestTuple<R>> : never;
|
||||
type MostProperties<T, U> = keyof U extends keyof T ? T : U;
|
||||
type ElementAt<T, N extends keyof any> = N extends keyof T ? T[N] : unknown;
|
||||
type ElementsAt<T, N extends keyof any> = {
|
||||
[K in keyof T]: ElementAt<T[K], N>;
|
||||
};
|
||||
type Intersect<T extends readonly unknown[]> = T extends [] ? unknown : T extends [infer H, ...infer T] ? H & Intersect<T> : T[number];
|
||||
type MergeTuples<T, L extends unknown[] = LongestTuple<T>> = {
|
||||
[K in keyof L]: Intersect<ElementsAt<T, K> extends readonly unknown[] ? ElementsAt<T, K> : never>;
|
||||
};
|
||||
type ExtractParameters<T extends readonly UnknownFunction[]> = {
|
||||
[K in keyof T]: Parameters<T[K]>;
|
||||
};
|
||||
export type MergeParameters<T extends readonly UnknownFunction[]> = '0' extends keyof T ? MergeTuples<MakeRestExplicit<ExtractParameters<T>>> : Parameters<T[number]>;
|
||||
type HasRest<S extends readonly unknown[]> = number extends S['length'] ? true : false;
|
||||
type HasExplicit<S extends readonly unknown[]> = '0' extends keyof S ? true : false;
|
||||
type HasCombined<S extends readonly unknown[]> = true extends HasExplicit<S> & HasRest<S> ? true : false;
|
||||
type MakeRestExplicit<T extends readonly unknown[][]> = true extends HasCombined<T> ? [
|
||||
...ReverseTail<T>,
|
||||
ReverseHead<T> extends readonly unknown[] ? ReverseHead<T>[number] : never
|
||||
] : true extends HasRest<T> ? [...T] : T;
|
||||
export {};
|
||||
Reference in New Issue
Block a user