UNPKG

1.67 kBTypeScriptView Raw
1import type { IActionContext, IActionContextKey } from '@comunica/types';
2/**
3 * Implementation of {@link IActionContext} using Immutable.js.
4 */
5export declare class ActionContext implements IActionContext {
6 private readonly map;
7 constructor(data?: Record<string, any>);
8 /**
9 * Will only set the value if the key is not already set.
10 */
11 setDefault<V>(key: IActionContextKey<V>, value: V): IActionContext;
12 set<V>(key: IActionContextKey<V>, value: V): IActionContext;
13 setRaw(key: string, value: any): IActionContext;
14 delete<V>(key: IActionContextKey<V>): IActionContext;
15 get<V>(key: IActionContextKey<V>): V | undefined;
16 getRaw(key: string): any | undefined;
17 getSafe<V>(key: IActionContextKey<V>): V;
18 has<V>(key: IActionContextKey<V>): boolean;
19 hasRaw(key: string): boolean;
20 merge(...contexts: IActionContext[]): IActionContext;
21 keys(): IActionContextKey<any>[];
22 toJS(): any;
23 toString(): string;
24 /**
25 * Convert the given object to an action context object if it is not an action context object yet.
26 * If it already is an action context object, return the object as-is.
27 * @param maybeActionContext An action context or record.
28 * @return {ActionContext} An action context object.
29 */
30 static ensureActionContext(maybeActionContext?: IActionContext | Record<string, any>): IActionContext;
31}
32/**
33 * Simple implementation of {@link IActionContextKey}.
34 */
35export declare class ActionContextKey<V> implements IActionContextKey<V> {
36 /**
37 * A unique context key name.
38 */
39 readonly name: string;
40 readonly dummy: V | undefined;
41 constructor(name: string);
42}