Skip to main content

Utils

Defined in: src/utils.ts:171

Constructors

Constructor

new Utils(): Utils

Returns

Utils

Methods

createResultsCsv()

static createResultsCsv(resultDF?): string

Defined in: src/utils.ts:395

Parameters

ParameterType
resultDF?DataFrame

Returns

string


detectColumnHierarchy()

static detectColumnHierarchy(columns, maxDepth?): string[]

Defined in: src/utils.ts:391

Detects natural hierarchy in the list of categorical columns based on their values. Mind that the function can be n^2 in the worst case scenario, although in most cases, it is quite fast as it exits early if missmatch is found.

Parameters

ParameterTypeDefault valueDescription
columnsColumn<any, any>[]undefinedList of columns to detect hierarchy in.
maxDepthnumber3Maximum depth of the hierarchy to detect.

Returns

string[]


download()

static download(filename, content, contentType?): void

Defined in: src/utils.ts:230

Downloads the specified content locally

Parameters

ParameterType
filenamestring
contentBlobPart
contentType?string

Returns

void


executeTests()

static executeTests(testsParams, stopOnFail?): Promise<any>

Defined in: src/utils.ts:289

Parameters

ParameterType
testsParamsobject[]
stopOnFail?boolean

Returns

Promise<any>


firstOrNull()

static firstOrNull<T>(iterable): T | null

Defined in: src/utils.ts:173

Type Parameters

Type Parameter
T

Parameters

ParameterTypeDescription
iterableIterable<T>-

Returns

T | null


getJsonValueType()

static getJsonValueType(x): "string" | "bigint" | "object" | "int" | "double" | "bool" | "byte_array" | "datetime" | "qnum" | "dataframe" | null

Defined in: src/utils.ts:260

Parameters

ParameterType
xany

Returns

"string" | "bigint" | "object" | "int" | "double" | "bool" | "byte_array" | "datetime" | "qnum" | "dataframe" | null


identity()

static identity(length): Uint32Array<ArrayBuffer>

Defined in: src/utils.ts:179

Returns an 'identity' array where the element in idx-th position is equals to idx.

Parameters

ParameterType
lengthnumber

Returns

Uint32Array<ArrayBuffer>


isEmpty()

static isEmpty(s?): boolean

Defined in: src/utils.ts:195

Parameters

ParameterType
s?string

Returns

boolean


jsonToColumns()

static jsonToColumns(column): void

Defined in: src/utils.ts:274

Expands a column of JSON strings into multiple columns, one per unique key

Parameters

ParameterType
columnColumn<string>

Returns

void


loadJsCss()

static loadJsCss(files): Promise<null>

Defined in: src/utils.ts:243

Loads the specified common libraries, if they were not loaded already. Use it in plugins when a big JS dependency is used infrequently, such as exporting to Excel, or showing a 3d structure. Example: loadJsCss(['common/exceljs.min.js', 'common/exceljs.min.css'])

Parameters

ParameterType
filesstring[]

Returns

Promise<null>


nullIfEmpty()

static nullIfEmpty(s?): string | null | undefined

Defined in: src/utils.ts:199

Parameters

ParameterType
s?string

Returns

string | null | undefined


openFile()

static openFile(options): void

Defined in: src/utils.ts:204

Shows "Open File" dialog, and lets you process the result.

Parameters

ParameterType
options{ accept: string; open: (file) => void; }
options.acceptstring
options.open(file) => void

Returns

void


openFileBytes()

static openFileBytes(options): void

Defined in: src/utils.ts:216

Shows "Open File" dialog, and lets you process the result.

Parameters

ParameterType
options{ accept: string; open: (bytes) => void; }
options.acceptstring
options.open(bytes) => void

Returns

void


random()

static random<T>(items): T

Defined in: src/utils.ts:187

Returns random element from the array. Useful for demo data, tests, etc.

Type Parameters

Type Parameter
T

Parameters

ParameterType
itemsT[]

Returns

T


randomString()

static randomString(length): string

Defined in: src/utils.ts:410

Parameters

ParameterType
lengthnumber

Returns

string


replaceAll()

static replaceAll(string, search, replace): string

Defined in: src/utils.ts:191

Parameters

ParameterType
stringstring
searchstring
replacestring

Returns

string


streamToObservable()

static streamToObservable<T>(dartStream): Observable<T>

Defined in: src/utils.ts:247

Type Parameters

Type ParameterDefault type
Tany

Parameters

ParameterType
dartStreamany

Returns

Observable<T>