Documentation / @cashconnect-js/core / primitives/bytes
Bytes
Defined in: cashconnect-js/packages/core/src/primitives/bytes.ts:21
Bytes Primitive.
Extends
Uint8Array
Indexable
[index: number]: numberMethods
from()
static from(uint8Array): Bytes;Defined in: cashconnect-js/packages/core/src/primitives/bytes.ts:32
Creates an array from an array-like or iterable object.
Parameters
| Parameter | Type |
|---|---|
uint8Array | Uint8Array |
Returns
Overrides
Uint8Array.fromfromBytes()
static fromBytes(bytes): Bytes;Defined in: cashconnect-js/packages/core/src/primitives/bytes.ts:45
Instantiates bytes from an Uint8Array.
Parameters
| Parameter | Type | Description |
|---|---|---|
bytes | Uint8Array | The bytes as a Uint8Array. |
Returns
Instance of Bytes.
Throws
If Base64 is invalid.
fromBase64()
static fromBase64(base64): Bytes;Defined in: cashconnect-js/packages/core/src/primitives/bytes.ts:58
Instantiates bytes from a Base64 string.
Parameters
| Parameter | Type | Description |
|---|---|---|
base64 | string | The Base64 string. |
Returns
Instance of Bytes.
Throws
If Base64 is invalid.
fromBigInt()
static fromBigInt(number, size?): Bytes;Defined in: cashconnect-js/packages/core/src/primitives/bytes.ts:77
Instantiates VM Number bytes from the given BigInt.
Parameters
| Parameter | Type | Description |
|---|---|---|
number | bigint | The bigint number. |
size? | number | Pad the VM number to the given size. |
Returns
Instance of Bytes.
Throws
If number does not fit within the size given.
fromBigInt64()
static fromBigInt64(number): Bytes;Defined in: cashconnect-js/packages/core/src/primitives/bytes.ts:104
Instantiates bytes from a BigInt (64 Bit LE encoded).
Parameters
| Parameter | Type | Description |
|---|---|---|
number | bigint | The bigint number. |
Returns
Instance of Bytes.
Throws
If number is invalid.
fromDate()
static fromDate(date, size?): Bytes;Defined in: cashconnect-js/packages/core/src/primitives/bytes.ts:108
Parameters
| Parameter | Type |
|---|---|
date | Date |
size? | number |
Returns
fromHex()
static fromHex(hex): Bytes;Defined in: cashconnect-js/packages/core/src/primitives/bytes.ts:123
Instantiates bytes from a hex string.
Parameters
| Parameter | Type | Description |
|---|---|---|
hex | string | The hex string. |
Returns
Instance of Bytes.
Throws
If hex is invalid.
fromNumber()
static fromNumber(number, size?): Bytes;Defined in: cashconnect-js/packages/core/src/primitives/bytes.ts:132
Parameters
| Parameter | Type |
|---|---|
number | number | bigint |
size? | number |
Returns
fromUtf8()
static fromUtf8(utf8): Bytes;Defined in: cashconnect-js/packages/core/src/primitives/bytes.ts:143
Instantiates bytes from a UTF8 string.
Parameters
| Parameter | Type | Description |
|---|---|---|
utf8 | string | The UTF8 string. |
Returns
Instance of Bytes.
generateRandom()
static generateRandom(length): Bytes;Defined in: cashconnect-js/packages/core/src/primitives/bytes.ts:147
Parameters
| Parameter | Type | Default value |
|---|---|---|
length | number | 32 |
Returns
areEqual()
static areEqual(a, b): boolean;Defined in: cashconnect-js/packages/core/src/primitives/bytes.ts:161
Check whether a and b contain the same data.
Parameters
| Parameter | Type | Description |
|---|---|---|
a | Uint8Array | The first Bytes/Uint8array |
b | Uint8Array | The second Bytes/Uint8array |
Returns
boolean
True if both are equal, false otherwise.
slice()
slice(start, end): Bytes;Defined in: cashconnect-js/packages/core/src/primitives/bytes.ts:165
Returns a section of an array.
Parameters
| Parameter | Type | Description |
|---|---|---|
start | number | The beginning of the specified portion of the array. |
end | number | The end of the specified portion of the array. This is exclusive of the element at the index 'end'. |
Returns
Overrides
Uint8Array.slicetoBase64()
toBase64(): string;Defined in: cashconnect-js/packages/core/src/primitives/bytes.ts:174
Return bytes as a Base64 string.
Returns
string
Bytes as a Base64 string.
toBigInt()
toBigInt(): bigint;Defined in: cashconnect-js/packages/core/src/primitives/bytes.ts:178
Returns
bigint
toDate()
toDate(): Date;Defined in: cashconnect-js/packages/core/src/primitives/bytes.ts:206
Returns
Date
toNumber()
toNumber(): number;Defined in: cashconnect-js/packages/core/src/primitives/bytes.ts:212
Returns
number
toHex()
toHex(): string;Defined in: cashconnect-js/packages/core/src/primitives/bytes.ts:221
Return bytes as a hex string.
Returns
string
Bytes as a hex string.
toUtf8()
toUtf8(): string;Defined in: cashconnect-js/packages/core/src/primitives/bytes.ts:230
Return bytes as a UTF8 string
Returns
string
Bytes as a UTF8 string.
toUint8Array()
toUint8Array(): Uint8Array;Defined in: cashconnect-js/packages/core/src/primitives/bytes.ts:239
Return bytes as a Uint8Array
Returns
Uint8Array
Bytes as a Uint8Array.
invert()
invert(): Bytes;Defined in: cashconnect-js/packages/core/src/primitives/bytes.ts:244