UNPKG

6.42 kBTypeScriptView Raw
1import { Event, StateValue, ActionType, Action, EventObject, PropertyMapper, Mapper, EventType, HistoryValue, AssignAction, Condition, Subscribable, ConditionPredicate, SCXML, StateLike, EventData, TransitionConfig, TransitionConfigTarget, NullEvent, SingleOrArray, Guard, InvokeSourceDefinition, Observer, Behavior, RaiseActionObject, SendActionObject } from './types';
2import { StateNode } from './StateNode';
3import { State } from './State';
4import { Actor } from './Actor';
5import { ActionObject, AnyStateMachine } from '.';
6export declare function keys<T extends object>(value: T): Array<keyof T & string>;
7export declare function matchesState(parentStateId: StateValue, childStateId: StateValue, delimiter?: string): boolean;
8export declare function getEventType<TEvent extends EventObject = EventObject>(event: Event<TEvent>): TEvent['type'];
9export declare function getActionType(action: Action<any, any>): ActionType;
10export declare function toStatePath(stateId: string | string[], delimiter: string): string[];
11export declare function isStateLike(state: any): state is StateLike<any>;
12export declare function toStateValue(stateValue: StateLike<any> | StateValue | string[], delimiter: string): StateValue;
13export declare function pathToStateValue(statePath: string[]): StateValue;
14export declare function mapValues<P, O extends Record<string, unknown>>(collection: O, iteratee: (item: O[keyof O], key: keyof O, collection: O, i: number) => P): {
15 [key in keyof O]: P;
16};
17export declare function mapFilterValues<T, P>(collection: {
18 [key: string]: T;
19}, iteratee: (item: T, key: string, collection: {
20 [key: string]: T;
21}) => P, predicate: (item: T) => boolean): {
22 [key: string]: P;
23};
24/**
25 * Retrieves a value at the given path.
26 * @param props The deep path to the prop of the desired value
27 */
28export declare const path: <T extends Record<string, any>>(props: string[]) => any;
29/**
30 * Retrieves a value at the given path via the nested accessor prop.
31 * @param props The deep path to the prop of the desired value
32 */
33export declare function nestedPath<T extends Record<string, any>>(props: string[], accessorProp: keyof T): (object: T) => T;
34export declare function toStatePaths(stateValue: StateValue | undefined): string[][];
35export declare function pathsToStateValue(paths: string[][]): StateValue;
36export declare function flatten<T>(array: Array<T | T[]>): T[];
37export declare function toArrayStrict<T>(value: T[] | T): T[];
38export declare function toArray<T>(value: T[] | T | undefined): T[];
39export declare function mapContext<TContext, TEvent extends EventObject>(mapper: Mapper<TContext, TEvent, any> | PropertyMapper<TContext, TEvent, any>, context: TContext, _event: SCXML.Event<TEvent>): any;
40export declare function isBuiltInEvent(eventType: EventType): boolean;
41export declare function isPromiseLike(value: any): value is PromiseLike<any>;
42export declare function isBehavior(value: any): value is Behavior<any, any>;
43export declare function partition<T, A extends T, B extends T>(items: T[], predicate: (item: T) => item is A): [A[], B[]];
44export declare function updateHistoryStates(hist: HistoryValue, stateValue: StateValue): Record<string, HistoryValue | undefined>;
45export declare function updateHistoryValue(hist: HistoryValue, stateValue: StateValue): HistoryValue;
46export declare function updateContext<TContext, TEvent extends EventObject>(context: TContext, _event: SCXML.Event<TEvent>, assignActions: Array<AssignAction<TContext, TEvent>>, state?: State<TContext, TEvent>): TContext;
47declare let warn: (condition: boolean | Error, message: string) => void;
48export { warn };
49export declare function isArray(value: any): value is any[];
50export declare function isFunction(value: any): value is Function;
51export declare function isString(value: any): value is string;
52export declare function toGuard<TContext, TEvent extends EventObject>(condition?: Condition<TContext, TEvent>, guardMap?: Record<string, ConditionPredicate<TContext, TEvent>>): Guard<TContext, TEvent> | undefined;
53export declare function isObservable<T>(value: any): value is Subscribable<T>;
54export declare const symbolObservable: typeof Symbol.observable;
55export declare const interopSymbols: {
56 [Symbol.observable]: () => any;
57};
58export declare function isMachine(value: any): value is AnyStateMachine;
59export declare function isActor(value: any): value is Actor;
60export declare const uniqueId: () => string;
61export declare function toEventObject<TEvent extends EventObject>(event: Event<TEvent>, payload?: EventData): TEvent;
62export declare function toSCXMLEvent<TEvent extends EventObject>(event: Event<TEvent> | SCXML.Event<TEvent>, scxmlEvent?: Partial<SCXML.Event<TEvent>>): SCXML.Event<TEvent>;
63export declare function toTransitionConfigArray<TContext, TEvent extends EventObject>(event: TEvent['type'] | NullEvent['type'] | '*', configLike: SingleOrArray<TransitionConfig<TContext, TEvent> | TransitionConfigTarget<TContext, TEvent>>): Array<TransitionConfig<TContext, TEvent> & {
64 event: TEvent['type'] | NullEvent['type'] | '*';
65}>;
66export declare function normalizeTarget<TContext, TEvent extends EventObject>(target: SingleOrArray<string | StateNode<TContext, any, TEvent>> | undefined): Array<string | StateNode<TContext, any, TEvent>> | undefined;
67export declare function reportUnhandledExceptionOnInvocation(originalError: any, currentError: any, id: string): void;
68export declare function evaluateGuard<TContext, TEvent extends EventObject>(machine: StateNode<TContext, any, TEvent, any, any>, guard: Guard<TContext, TEvent>, context: TContext, _event: SCXML.Event<TEvent>, state: State<TContext, TEvent>): boolean;
69export declare function toInvokeSource(src: string | InvokeSourceDefinition): InvokeSourceDefinition;
70export declare function toObserver<T>(nextHandler?: Partial<Observer<T>> | ((value: T) => void), errorHandler?: (error: any) => void, completionHandler?: () => void): Observer<T>;
71export declare function createInvokeId(stateNodeId: string, index: number): string;
72export declare function isRaisableAction<TContext, TExpressionEvent extends EventObject, TEvent extends EventObject>(action: ActionObject<TContext, TExpressionEvent, TEvent>): action is RaiseActionObject<TContext, TExpressionEvent, TEvent> | SendActionObject<TContext, TExpressionEvent, TEvent>;
73//# sourceMappingURL=utils.d.ts.map
\No newline at end of file