Utils

@liskhq/lisk-utils is a library providing various utilities for handling data structures, objects, and jobs.

Installation

npm install @liskhq/lisk-utils

Update

To perform an upgrade, execute the following command:

npm update @liskhq/lisk-utils

Method reference

bufferArrayContains

Checks, if a Buffer array(arr1) contains another Buffer array(arr2).

Syntax

objects.bufferArrayContains(arr1,arr2)

Parameters

  1. arr1(Buffer[]): A buffer array.

  2. arr2(Buffer[]): Another buffer array.

Return value

boolean: true if arr1 contains arr2, false otherwise.

bufferArrayContainsSome

Checks, if a Buffer array(arr1) contains parts of another Buffer array(arr2).

Syntax

objects.bufferArrayContainsSome(arr1,arr2)

Parameters

  1. arr1(Buffer[]): A buffer array.

  2. arr2(Buffer[]): Another buffer array.

Return value

boolean: true if arr1 contains some parts of arr2, false otherwise.

bufferArrayEqual

Checks if two given Buffer arrays are identical.

Syntax

objects.bufferArrayEqual(arr1,arr2)

Parameters

  1. arr1(Buffer[]): A buffer array.

  2. arr2(Buffer[]): Another buffer array.

Return value

boolean: true if arr1 is equal to arr2, false otherwise.

bufferArrayIncludes

Checks, if a Buffer array includes a certain value.

Syntax

objects.bufferArrayIncludes(arr,val)

Parameters

  1. arr(Buffer[]): A buffer array.

  2. val(Buffer): A buffer value.

Return value

boolean: true if arr includes val, false otherwise.

bufferArrayOrderByLex

Checks if a given buffer array is sorted in lexicographical order.

Syntax

objects.bufferArrayOrderByLex(arr1)

Parameters

  1. arr1(Buffer[]): A buffer array.

Return value

boolean: true if arr1 is sorted in lexicographical order, false otherwise.

bufferArraySubtract

Substracts one buffer array from another buffer array.

Syntax

objects.bufferArraySubtract(arr1,arr2)

Parameters

  1. arr1(Buffer[]): A buffer array.

  2. arr2(Buffer[]): Another buffer array.

Return value

Buffer[]: A new buffer array, which contains the values of arr1 excluding the values of arr2, if present in arr1.

bufferArrayUniqueItems

Checks if all items of a buffer array are unique.

Syntax

objects.bufferArrayUniqueItems(arr1)

Parameters

  1. arr1(Buffer[]): A buffer array.

Return value

boolean: true if all items in the buffer array are unique, false otherwise.

mergeDeep

Merges objects into one object.

Removes properties which are null or undefined during the merge.

Syntax

objects.mergeDeep(dest, obj1, obj2, ...)

Parameters

  1. dest(object): The other objects will be merged into this one.

  2. obj1(object): An object.

  3. obj2(object): An object.

Return value

object: The merged object.