Skip to content

The CustomType interface is the base interface for all custom types in the SDK. It provides methods for comparing, converting, and cloning objects.

Defined in: packages/bitbadgesjs-sdk/src/common/base.ts:40

The CustomType interface is the base interface for all custom types in the SDK. It provides methods for comparing, converting, and cloning objects.

Type Parameters

T

T extends CustomType<T>

Methods

clone()

clone(): T

Defined in: packages/bitbadgesjs-sdk/src/common/base.ts:58

Deep copies the object and returns a new instance.

Returns

T


convert()

convert<U>(convertFunction?): CustomType<any>

Defined in: packages/bitbadgesjs-sdk/src/common/base.ts:66

Converts the object to a different NumberType equivalent.

Type Parameters

U

U extends NumberType

Parameters

convertFunction?

(val) => U

Returns

CustomType<any>


equals()

equals<U>(other, normalizeNumberTypes?): boolean

Defined in: packages/bitbadgesjs-sdk/src/common/base.ts:46

Compares this object's fields to another object's fields for equality. Equality is determined by comparing the JSON representations of the objects.

If normalizeNumberTypes is true, then all number types will be compared as strings (i.e. "1n" === "1" === 1). Else, they will be compared as their native types (i.e. 1n !== 1 !== "1").

Type Parameters

U

U extends CustomType<U>

Parameters

other

CustomType<U> | null | undefined

normalizeNumberTypes?

boolean

Returns

boolean


getNumberFieldNames()

getNumberFieldNames(): string[]

Defined in: packages/bitbadgesjs-sdk/src/common/base.ts:62

Internal helper method to convert the number fields of the object to a different NumberType equivalent.

Returns

string[]


hasNumberFields()

hasNumberFields(): boolean

Defined in: packages/bitbadgesjs-sdk/src/common/base.ts:70

Checks if the object has number fields.

Returns

boolean


toJson()

toJson(): JsonObject

Defined in: packages/bitbadgesjs-sdk/src/common/base.ts:50

Converts the object to a JSON object with all primitive types.

Returns

JsonObject


toJsonString()

toJsonString(): string

Defined in: packages/bitbadgesjs-sdk/src/common/base.ts:54

Converts the object to a JSON string.

Returns

string

Edit this page on GitHub