# Class: LibraryUtils

## LibraryUtils

Collection of helper utilities for the library.

Source:
  - src/main/js/common/LibraryUtils.js, line 11

### Methods

#### (static) deserializeError()

Source:
  - src/main/js/common/LibraryUtils.js, line 229

#### (static) getLogLevel() → {int}

Get the library's log level.

Source:
  - src/main/js/common/LibraryUtils.js, line 41

##### Returns:

the library's log level

Type
  int

#### (async, static) getWasmMemoryUsed() → {int}

Get the total memory used by WebAssembly.

Source:
  - src/main/js/common/LibraryUtils.js, line 50

##### Returns:

the total memory used by WebAssembly

Type
  int

#### (static) getWasmModule()

Get the WebAssembly module in the current context (nodejs, browser main thread or worker).

Source:
  - src/main/js/common/LibraryUtils.js, line 60

#### (async, static) getWorker() → {Worker}

Get a singleton instance of a worker to share.

Source:
  - src/main/js/common/LibraryUtils.js, line 151

##### Returns:

a worker to share among wallet instances

Type
  Worker

#### (async, static) invokeWorker(objectId, fnName, args) → {any}

Invoke a worker function and get the result with error handling.

##### Parameters:

Name | Type | Description
--- | --- | ---
`objectId` | string | identifies the worker object to invoke (default random id)
`fnName` | string | is the name of the function to invoke
`args` | Array.<any> | are function arguments to invoke with

Source:
  - src/main/js/common/LibraryUtils.js, line 206

##### Returns:

resolves with response payload from the worker or an error

Type
  any

#### (static) isRejectUnauthorized(fnId)

Indicate if unauthorized requests should be rejected.

##### Parameters:

Name | Type | Description
--- | --- | ---
`fnId` | string | uniquely identifies the function

Source:
  - src/main/js/common/LibraryUtils.js, line 129

#### (async, static) loadFullModule()

Load the WebAssembly full module with caching. The full module is a superset of the keys module and overrides it. TODO: this is separate static function from loadKeysModule() because webpack cannot bundle worker using runtime param for conditional import

Source:
  - src/main/js/common/LibraryUtils.js, line 92

#### (async, static) loadKeysModule()

Load the WebAssembly keys module with caching.

Source:
  - src/main/js/common/LibraryUtils.js, line 67

#### (static) log(level, msg)

Log a message.

##### Parameters:

Name | Type | Description
--- | --- | ---
`level` | int | log level of the message
`msg` | string | message to log

Source:
  - src/main/js/common/LibraryUtils.js, line 19

#### (static) serializeError()

Source:
  - src/main/js/common/LibraryUtils.js, line 223

#### (async, static) setLogLevel(level)

Set the library's log level with 0 being least verbose.

##### Parameters:

Name | Type | Description
--- | --- | ---
`level` | int | the library's log level

Source:
  - src/main/js/common/LibraryUtils.js, line 29

#### (static) setRejectUnauthorizedFn(fnId, fn)

Register a function by id which informs if unauthorized requests (e.g. self-signed certificates) should be rejected.

##### Parameters:

Name | Type | Description
--- | --- | ---
`fnId` | string | unique identifier for the function
`fn` | function | function to inform if unauthorized requests should be rejected

Source:
  - src/main/js/common/LibraryUtils.js, line 118

#### (static) setWorkerDistPath(workerDistPath)

Set the path to load the worker. Defaults to "/monero_web_worker.js" in the browser and "./MoneroWebWorker.js" in node.

##### Parameters:

Name | Type | Description
--- | --- | ---
`workerDistPath` | string | path to load the worker

Source:
  - src/main/js/common/LibraryUtils.js, line 140

#### (async, static) terminateWorker()

Terminate monero-javascript's singleton worker.

Source:
  - src/main/js/common/LibraryUtils.js, line 190