Skip to main content

Functions

Defined in: js-api/src/functions.ts:132

Grok functions

Constructors

Constructor

new Functions(): Functions

Returns

Functions

Accessors

clientCache

Get Signature

get clientCache(): ClientCache

Defined in: js-api/src/functions.ts:135

Controls client caching.

Returns

ClientCache


onAfterRunAction

Get Signature

get onAfterRunAction(): Observable<FuncCall>

Defined in: js-api/src/functions.ts:202

Returns

Observable<FuncCall>


onBeforeRunAction

Get Signature

get onBeforeRunAction(): Observable<FuncCall>

Defined in: js-api/src/functions.ts:201

Returns

Observable<FuncCall>


onParamsUpdated

Get Signature

get onParamsUpdated(): Observable<FuncCall>

Defined in: js-api/src/functions.ts:203

Returns

Observable<FuncCall>

Methods

call()

call(name, parameters?, showProgress?, progress?): Promise<any>

Defined in: js-api/src/functions.ts:155

Calls the function [name] (namespace-qualified, such as 'Chem:SmilesToMw') with the named [parameters], loading the owning package first if necessary. The result depends on the number of declared outputs: exactly one output resolves to that value (for instance a DataFrame); several outputs resolve to an object keyed by output name (res.result1, res.result2); no outputs resolve to undefined.

Parameters

ParameterTypeDefault value
namestringundefined
parametersobject{}
showProgressbooleanfalse
progressProgressIndicator | nullnull

Returns

Promise<any>

Example

const mw = await grok.functions.call('Chem:SmilesToMw', {smiles: 'CCO'});

eval()

eval(name, context?): Promise<any>

Defined in: js-api/src/functions.ts:161

Evaluates a GrokScript expression (or a bare function name) in [context] and returns the result; for a bare function name that is the Func itself (see find).

Parameters

ParameterType
namestring
context?Context

Returns

Promise<any>


find()

find(name): Promise<Func | null>

Defined in: js-api/src/functions.ts:184

Returns a function with the specified name, or null if not found. See also find.

Parameters

ParameterType
namestring

Returns

Promise<Func | null>


get()

get(name): Promise<Func>

Defined in: js-api/src/functions.ts:175

Returns a function with the specified name, or throws an error if there is no such function. See also find.

Parameters

ParameterType
namestring

Returns

Promise<Func>


getCurrentCall()

getCurrentCall(): FuncCall

Defined in: js-api/src/functions.ts:197

Returns

FuncCall


handleOuterBracketsInColName()

handleOuterBracketsInColName(name, escape): string

Defined in: js-api/src/functions.ts:169

Parameters

ParameterType
namestring
escapeboolean

Returns

string


parse()

parse(command, safe?): any

Defined in: js-api/src/functions.ts:165

Parameters

ParameterTypeDefault value
commandstringundefined
safebooleantrue

Returns

any


register()

register(func): Func

Defined in: js-api/src/functions.ts:138

Registers a function globally.

Parameters

ParameterType
funcIFunctionRegistrationData

Returns

Func


registerParamFunc()

registerParamFunc(name, type, run, check?, description?): void

Defined in: js-api/src/functions.ts:144

Registers a function of one parameter of the specified [type]. It is offered for matching objects in context menus and in the "Actions" pane; [check] is an optional applicability predicate.

Parameters

ParameterTypeDefault value
namestringundefined
type"string" | "bigint" | "object" | "map" | "file" | "bool" | "int" | "double" | "byte_array" | "datetime" | "qnum" | "dataframe" | "numerical" | "categorical" | "num" | "string_list" | "dataframe_list" | "cell" | "column" | "column_list" | "graphics" | "blob" | "tablerowfiltercall" | "colfiltercall" | "bitset" | "dynamic" | "viewer" | "list" | "semantic_value" | "func" | "funccall" | "property" | "GridCellRenderArgs" | "element" | "view" | "TableView" | "User" | "Menu" | "Project" | "event_data" | "progressindicator" | "Credentials" | "ScriptEnvironment" | "Notebook" | string & objectundefined
run(x) => anyundefined
checkboolean | ((x) => boolean) | nullnull
descriptionstring | nullnull

Returns

void


scriptSync()

scriptSync(s, variables?): any

Defined in: js-api/src/functions.ts:193

Synchronously evaluates a GrokScript expression. When variables is provided, the expression is evaluated over a fresh context built from that map only (shell variables are not visible); when omitted, it is evaluated over the shell context, as before.

Parameters

ParameterType
sstring
variables?{[name: string]: any; }

Returns

any