@descope/sdk-helpers
Version:
Descope JavaScript SDK helpers
47 lines (41 loc) • 5.5 kB
TypeScript
declare function compose<Input, A1>(fn1: (input: Input) => A1): (input: Input) => A1;
declare function compose<Input, A1, A2>(fn1: (input: Input) => A1, fn2: (input: A1) => A2): (input: Input) => A2;
declare function compose<Input, A1, A2, A3>(fn1: (input: Input) => A1, fn2: (input: A1) => A2, fn3: (input: A2) => A3): (input: Input) => A3;
declare function compose<Input, A1, A2, A3, A4>(fn1: (input: Input) => A1, fn2: (input: A1) => A2, fn3: (input: A2) => A3, fn4: (input: A3) => A4): (input: Input) => A4;
declare function compose<Input, A1, A2, A3, A4, A5>(fn1: (input: Input) => A1, fn2: (input: A1) => A2, fn3: (input: A2) => A3, fn4: (input: A3) => A4, fn5: (input: A4) => A5): (input: Input) => A5;
declare function compose<Input, A1, A2, A3, A4, A5, A6>(fn1: (input: Input) => A1, fn2: (input: A1) => A2, fn3: (input: A2) => A3, fn4: (input: A3) => A4, fn5: (input: A4) => A5, fn6: (input: A5) => A6): (input: Input) => A6;
declare function compose<Input, A1, A2, A3, A4, A5, A6, A7>(fn1: (input: Input) => A1, fn2: (input: A1) => A2, fn3: (input: A2) => A3, fn4: (input: A3) => A4, fn5: (input: A4) => A5, fn6: (input: A5) => A6, fn7: (input: A6) => A7): (input: Input) => A7;
declare function compose<Input, A1, A2, A3, A4, A5, A6, A7, A8>(fn1: (input: Input) => A1, fn2: (input: A1) => A2, fn3: (input: A2) => A3, fn4: (input: A3) => A4, fn5: (input: A4) => A5, fn6: (input: A5) => A6, fn7: (input: A6) => A7, fn8: (input: A7) => A8): (input: Input) => A8;
declare function compose<Input, A1, A2, A3, A4, A5, A6, A7, A8, A9>(fn1: (input: Input) => A1, fn2: (input: A1) => A2, fn3: (input: A2) => A3, fn4: (input: A3) => A4, fn5: (input: A4) => A5, fn6: (input: A5) => A6, fn7: (input: A6) => A7, fn8: (input: A7) => A8, fn9: (input: A8) => A9): (input: Input) => A9;
declare function compose<Input, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10>(fn1: (input: Input) => A1, fn2: (input: A1) => A2, fn3: (input: A2) => A3, fn4: (input: A3) => A4, fn5: (input: A4) => A5, fn6: (input: A5) => A6, fn7: (input: A6) => A7, fn8: (input: A7) => A8, fn9: (input: A8) => A9, fn10: (input: A9) => A10): (input: Input) => A10;
declare function compose<Input, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11>(fn1: (input: Input) => A1, fn2: (input: A1) => A2, fn3: (input: A2) => A3, fn4: (input: A3) => A4, fn5: (input: A4) => A5, fn6: (input: A5) => A6, fn7: (input: A6) => A7, fn8: (input: A7) => A8, fn9: (input: A8) => A9, fn10: (input: A9) => A10, fn11: (input: A10) => A11): (input: Input) => A11;
declare function compose<Input, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12>(fn1: (input: Input) => A1, fn2: (input: A1) => A2, fn3: (input: A2) => A3, fn4: (input: A3) => A4, fn5: (input: A4) => A5, fn6: (input: A5) => A6, fn7: (input: A6) => A7, fn8: (input: A7) => A8, fn9: (input: A8) => A9, fn10: (input: A9) => A10, fn11: (input: A10) => A11, fn12: (input: A11) => A12): (input: Input) => A12;
declare function compose<Input, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13>(fn1: (input: Input) => A1, fn2: (input: A1) => A2, fn3: (input: A2) => A3, fn4: (input: A3) => A4, fn5: (input: A4) => A5, fn6: (input: A5) => A6, fn7: (input: A6) => A7, fn8: (input: A7) => A8, fn9: (input: A8) => A9, fn10: (input: A9) => A10, fn11: (input: A10) => A11, fn12: (input: A11) => A12, fn13: (input: A12) => A13): (input: Input) => A13;
declare function compose<Input, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14>(fn1: (input: Input) => A1, fn2: (input: A1) => A2, fn3: (input: A2) => A3, fn4: (input: A3) => A4, fn5: (input: A4) => A5, fn6: (input: A5) => A6, fn7: (input: A6) => A7, fn8: (input: A7) => A8, fn9: (input: A8) => A9, fn10: (input: A9) => A10, fn11: (input: A10) => A11, fn12: (input: A11) => A12, fn13: (input: A12) => A13, fn14: (input: A13) => A14): (input: Input) => A14;
declare const createTemplate: (templateString: string) => HTMLTemplateElement;
declare const pathJoin: (...paths: string[]) => string;
declare const compareArrays: (array1: any[], array2: any[]) => boolean;
declare const withMemCache: <I extends any[], O>(fn: (...args: I) => O) => (...args: I) => O;
declare const kebabCase: (str: string) => string;
declare const isObjEmpty: (obj: object) => boolean;
declare const pluralize: (amount: number) => (strings: TemplateStringsArray, ...expressions: (string | number)[][]) => string;
declare const debounce: (fn: Function, ms?: number) => (this: any, ...args: any[]) => void;
type Mixin = (superclass: CustomElementConstructor) => CustomElementConstructor;
declare const createSingletonMixin: <T extends Mixin>(mixin: T) => T;
declare const createIsChanged: <T extends Record<string, any>>(state: T, prevState: T) => (attrName: keyof T) => boolean;
type StateObject = Record<string, any>;
type UpdateStateCb<T> = (state: T) => Partial<T>;
type SubscribeCb<T> = (state: T, prevState: T, isChanged: ReturnType<typeof createIsChanged>) => void | Promise<void>;
type IsChanged<T> = Parameters<SubscribeCb<T>>[2];
declare class State<T extends StateObject> {
#private;
constructor(init?: T, { forceUpdate }?: {
forceUpdate?: boolean;
});
get current(): T;
update: (newState: Partial<T> | UpdateStateCb<T>) => void;
subscribe(cb: SubscribeCb<T>): string;
unsubscribe(token: string): boolean;
unsubscribeAll(): boolean;
}
export { type IsChanged, State, type SubscribeCb, compareArrays, compose, createSingletonMixin, createTemplate, debounce, isObjEmpty, kebabCase, pathJoin, pluralize, withMemCache };