Add overloads for context/flow/global set/get/keys

This commit is contained in:
Steve-Mcl 2021-06-23 22:27:13 +01:00
parent 0a8f7085f3
commit 3f27dc89d8
1 changed files with 190 additions and 17 deletions

View File

@ -64,28 +64,201 @@ declare class node {
public readonly outputCount:number;
}
declare class context {
/** Get a value from context */
static get(name:string, store?:string);
/** Store a value in context */
static set(name:string, value:any, store?:string);
/**
* Get one or multiple values from context (synchronous).
* @param name - Name of context variable
*/
static get(name: string | string[]);
/**
* Get one or multiple values from context (asynchronous).
* @param name - Name (or array of names) to get from context
* @param {function} callback - (optional) Callback function (`(err,value) => {}`)
*/
static get(name: string | string[], callback: Function);
/**
* Get one or multiple values from context (synchronous).
* @param name - Name (or array of names) to get from context
* @param store - Name of context store
*/
static get(name: string | string[], store: string);
/**
* Get one or multiple values from context (asynchronous).
* @param name - Name (or array of names) to get from context
* @param store - Name of context store
* @param {function} callback - (optional) Callback function (`(err,value) => {}`)
*/
static get(name: string | string[], store: string, callback: Function);
/**
* Set one or multiple values in context (synchronous).
* @param name - Name (or array of names) to set in context
* @param value - The value (or array of values) to store in context. If the value(s) are null/undefined, the context item(s) will be removed.
*/
static set(name: string | string[], value?: any | any[]);
/**
* Set one or multiple values in context (asynchronous).
* @param name - Name (or array of names) to set in context
* @param value - The value (or array of values) to store in context. If the value(s) are null/undefined, the context item(s) will be removed.
* @param callback - (optional) Callback function (`(err) => {}`)
*/
static set(name: string | string[], value?: any | any[], callback?: Function);
/**
* Set one or multiple values in context (synchronous).
* @param name - Name (or array of names) to set in context
* @param value - The value (or array of values) to store in context. If the value(s) are null/undefined, the context item(s) will be removed.
* @param store - (optional) Name of context store
*/
static set(name: string | string[], value?: any | any[], store?: string);
/**
* Set one or multiple values in context (asynchronous).
* @param name - Name (or array of names) to set in context
* @param value - The value (or array of values) to store in context. If the value(s) are null/undefined, the context item(s) will be removed.
* @param store - (optional) Name of context store
* @param callback - (optional) Callback function (`(err) => {}`)
*/
static set(name: string | string[], value?: any | any[], store?: string, callback?: Function);
/** Get an array of the keys in the context store */
static keys(store?:string):Array<string> ;
static keys(): Array<string>;
/** Get an array of the keys in the context store */
static keys(store: string): Array<string>;
/** Get an array of the keys in the context store */
static keys(callback: Function);
/** Get an array of the keys in the context store */
static keys(store: string, callback: Function);
}
declare class flow {
/** Get a value from flow context */
static get(name:string, store?:string);
/** Store a value in flow context */
static set(name:string, value:any, store?:string);
/** Get an array of the keys in the flow context store */
static keys(store?:string):Array<string> ;
/**
* Get one or multiple values from context (synchronous).
* @param name - Name of context variable
*/
static get(name: string | string[]);
/**
* Get one or multiple values from context (asynchronous).
* @param name - Name (or array of names) to get from context
* @param {function} callback - (optional) Callback function (`(err,value) => {}`)
*/
static get(name: string | string[], callback: Function);
/**
* Get one or multiple values from context (synchronous).
* @param name - Name (or array of names) to get from context
* @param store - Name of context store
*/
static get(name: string | string[], store: string);
/**
* Get one or multiple values from context (asynchronous).
* @param name - Name (or array of names) to get from context
* @param store - Name of context store
* @param {function} callback - (optional) Callback function (`(err,value) => {}`)
*/
static get(name: string | string[], store: string, callback: Function);
/**
* Set one or multiple values in context (synchronous).
* @param name - Name (or array of names) to set in context
* @param value - The value (or array of values) to store in context. If the value(s) are null/undefined, the context item(s) will be removed.
*/
static set(name: string | string[], value?: any | any[]);
/**
* Set one or multiple values in context (asynchronous).
* @param name - Name (or array of names) to set in context
* @param value - The value (or array of values) to store in context. If the value(s) are null/undefined, the context item(s) will be removed.
* @param callback - (optional) Callback function (`(err) => {}`)
*/
static set(name: string | string[], value?: any | any[], callback?: Function);
/**
* Set one or multiple values in context (synchronous).
* @param name - Name (or array of names) to set in context
* @param value - The value (or array of values) to store in context. If the value(s) are null/undefined, the context item(s) will be removed.
* @param store - (optional) Name of context store
*/
static set(name: string | string[], value?: any | any[], store?: string);
/**
* Set one or multiple values in context (asynchronous).
* @param name - Name (or array of names) to set in context
* @param value - The value (or array of values) to store in context. If the value(s) are null/undefined, the context item(s) will be removed.
* @param store - (optional) Name of context store
* @param callback - (optional) Callback function (`(err) => {}`)
*/
static set(name: string | string[], value?: any | any[], store?: string, callback?: Function);
/** Get an array of the keys in the context store */
static keys(): Array<string>;
/** Get an array of the keys in the context store */
static keys(store: string): Array<string>;
/** Get an array of the keys in the context store */
static keys(callback: Function);
/** Get an array of the keys in the context store */
static keys(store: string, callback: Function);
}
// @ts-ignore
declare class global {
/** Get a value from global context */
static get(name:string, store?:string);
/** Store a value in global context */
static set(name:string, value:any, store?:string);
/** Get an array of the keys in the global context store */
static keys(store?:string):Array<string> ;
/**
* Get one or multiple values from context (synchronous).
* @param name - Name of context variable
*/
static get(name: string | string[]);
/**
* Get one or multiple values from context (asynchronous).
* @param name - Name (or array of names) to get from context
* @param {function} callback - (optional) Callback function (`(err,value) => {}`)
*/
static get(name: string | string[], callback: Function);
/**
* Get one or multiple values from context (synchronous).
* @param name - Name (or array of names) to get from context
* @param store - Name of context store
*/
static get(name: string | string[], store: string);
/**
* Get one or multiple values from context (asynchronous).
* @param name - Name (or array of names) to get from context
* @param store - Name of context store
* @param {function} callback - (optional) Callback function (`(err,value) => {}`)
*/
static get(name: string | string[], store: string, callback: Function);
/**
* Set one or multiple values in context (synchronous).
* @param name - Name (or array of names) to set in context
* @param value - The value (or array of values) to store in context. If the value(s) are null/undefined, the context item(s) will be removed.
*/
static set(name: string | string[], value?: any | any[]);
/**
* Set one or multiple values in context (asynchronous).
* @param name - Name (or array of names) to set in context
* @param value - The value (or array of values) to store in context. If the value(s) are null/undefined, the context item(s) will be removed.
* @param callback - (optional) Callback function (`(err) => {}`)
*/
static set(name: string | string[], value?: any | any[], callback?: Function);
/**
* Set one or multiple values in context (synchronous).
* @param name - Name (or array of names) to set in context
* @param value - The value (or array of values) to store in context. If the value(s) are null/undefined, the context item(s) will be removed.
* @param store - (optional) Name of context store
*/
static set(name: string | string[], value?: any | any[], store?: string);
/**
* Set one or multiple values in context (asynchronous).
* @param name - Name (or array of names) to set in context
* @param value - The value (or array of values) to store in context. If the value(s) are null/undefined, the context item(s) will be removed.
* @param store - (optional) Name of context store
* @param callback - (optional) Callback function (`(err) => {}`)
*/
static set(name: string | string[], value?: any | any[], store?: string, callback?: Function);
/** Get an array of the keys in the context store */
static keys(): Array<string>;
/** Get an array of the keys in the context store */
static keys(store: string): Array<string>;
/** Get an array of the keys in the context store */
static keys(callback: Function);
/** Get an array of the keys in the context store */
static keys(store: string, callback: Function);
}
declare class env {
/** Get an environment variable value */