# 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 228

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

Get the library's log level.

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

##### 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 49

##### 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 59

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

Get a singleton instance of a worker to share.

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

##### Returns:

a worker to share among wallet instances

Type
  Worker

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

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

##### Parameters:

Name | Type | Description
--- | --- | ---
`identifies` | objectId | the worker object to invoke
`fnName` | string | is the name of the function to invoke
`args` | Array.<Object> | are function arguments to invoke with

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

##### 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 128

#### (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 91

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

Load the WebAssembly keys module with caching.

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

#### (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 222

#### (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 117

#### (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 139

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

Terminate monero-javascript's singleton worker.

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