Skip to main content

Class: Utils

dg.Utils

Constructors

constructor

new Utils()

Methods

download

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

Downloads the specified content locally

Parameters

NameType
filenamestring
contentBlobPart
contentType?string

Returns

void

Defined in

src/utils.ts:183


firstOrNull

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

Type parameters

Name
T

Parameters

NameType
iterableIterable<T>

Returns

null | T

Defined in

src/utils.ts:131


identity

Static identity(length): Uint32Array

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

Parameters

NameType
lengthnumber

Returns

Uint32Array

Defined in

src/utils.ts:137


isEmpty

Static isEmpty(s?): boolean

Parameters

NameType
s?string

Returns

boolean

Defined in

src/utils.ts:148


loadJsCss

Static loadJsCss(files): Promise<null>

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

NameType
filesstring[]

Returns

Promise<null>

Defined in

src/utils.ts:196


nullIfEmpty

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

Parameters

NameType
s?string

Returns

undefined | null | string

Defined in

src/utils.ts:152


openFile

Static openFile(options): void

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

Parameters

NameType
optionsObject
options.acceptstring
options.open(file: File) => void

Returns

void

Defined in

src/utils.ts:157


openFileBytes

Static openFileBytes(options): void

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

Parameters

NameType
optionsObject
options.acceptstring
options.open(bytes: Uint8Array) => void

Returns

void

Defined in

src/utils.ts:169


replaceAll

Static replaceAll(string, search, replace): string

Parameters

NameType
stringstring
searchstring
replacestring

Returns

string

Defined in

src/utils.ts:144