Skip to content

Documentation / @cashconnect-js/core / primitives/bytes

Bytes ​

Defined in: cashconnect-js/packages/core/src/primitives/bytes.ts:21

Bytes Primitive.

Extends ​

  • Uint8Array

Indexable ​

ts
[index: number]: number

Methods ​

from() ​

ts
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 ​
ParameterType
uint8ArrayUint8Array
Returns ​

Bytes

Overrides ​
ts
Uint8Array.from

fromBytes() ​

ts
static fromBytes(bytes): Bytes;

Defined in: cashconnect-js/packages/core/src/primitives/bytes.ts:45

Instantiates bytes from an Uint8Array.

Parameters ​
ParameterTypeDescription
bytesUint8ArrayThe bytes as a Uint8Array.
Returns ​

Bytes

Instance of Bytes.

Throws ​

If Base64 is invalid.

fromBase64() ​

ts
static fromBase64(base64): Bytes;

Defined in: cashconnect-js/packages/core/src/primitives/bytes.ts:58

Instantiates bytes from a Base64 string.

Parameters ​
ParameterTypeDescription
base64stringThe Base64 string.
Returns ​

Bytes

Instance of Bytes.

Throws ​

If Base64 is invalid.

fromBigInt() ​

ts
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 ​
ParameterTypeDescription
numberbigintThe bigint number.
size?numberPad the VM number to the given size.
Returns ​

Bytes

Instance of Bytes.

Throws ​

If number does not fit within the size given.

fromBigInt64() ​

ts
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 ​
ParameterTypeDescription
numberbigintThe bigint number.
Returns ​

Bytes

Instance of Bytes.

Throws ​

If number is invalid.

fromDate() ​

ts
static fromDate(date, size?): Bytes;

Defined in: cashconnect-js/packages/core/src/primitives/bytes.ts:108

Parameters ​
ParameterType
dateDate
size?number
Returns ​

Bytes

fromHex() ​

ts
static fromHex(hex): Bytes;

Defined in: cashconnect-js/packages/core/src/primitives/bytes.ts:123

Instantiates bytes from a hex string.

Parameters ​
ParameterTypeDescription
hexstringThe hex string.
Returns ​

Bytes

Instance of Bytes.

Throws ​

If hex is invalid.

fromNumber() ​

ts
static fromNumber(number, size?): Bytes;

Defined in: cashconnect-js/packages/core/src/primitives/bytes.ts:132

Parameters ​
ParameterType
numbernumber | bigint
size?number
Returns ​

Bytes

fromUtf8() ​

ts
static fromUtf8(utf8): Bytes;

Defined in: cashconnect-js/packages/core/src/primitives/bytes.ts:143

Instantiates bytes from a UTF8 string.

Parameters ​
ParameterTypeDescription
utf8stringThe UTF8 string.
Returns ​

Bytes

Instance of Bytes.

generateRandom() ​

ts
static generateRandom(length): Bytes;

Defined in: cashconnect-js/packages/core/src/primitives/bytes.ts:147

Parameters ​
ParameterTypeDefault value
lengthnumber32
Returns ​

Bytes

areEqual() ​

ts
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 ​
ParameterTypeDescription
aUint8ArrayThe first Bytes/Uint8array
bUint8ArrayThe second Bytes/Uint8array
Returns ​

boolean

True if both are equal, false otherwise.

slice() ​

ts
slice(start, end): Bytes;

Defined in: cashconnect-js/packages/core/src/primitives/bytes.ts:165

Returns a section of an array.

Parameters ​
ParameterTypeDescription
startnumberThe beginning of the specified portion of the array.
endnumberThe end of the specified portion of the array. This is exclusive of the element at the index 'end'.
Returns ​

Bytes

Overrides ​
ts
Uint8Array.slice

toBase64() ​

ts
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() ​

ts
toBigInt(): bigint;

Defined in: cashconnect-js/packages/core/src/primitives/bytes.ts:178

Returns ​

bigint

toDate() ​

ts
toDate(): Date;

Defined in: cashconnect-js/packages/core/src/primitives/bytes.ts:206

Returns ​

Date

toNumber() ​

ts
toNumber(): number;

Defined in: cashconnect-js/packages/core/src/primitives/bytes.ts:212

Returns ​

number

toHex() ​

ts
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() ​

ts
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() ​

ts
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() ​

ts
invert(): Bytes;

Defined in: cashconnect-js/packages/core/src/primitives/bytes.ts:244

Returns ​

Bytes