Skip to main content
Version: 5.14.1

Namespace: encode

References​

IS_BROWSER​

Re-exports IS_BROWSER

Functions​

arrayBufferToString​

â–¸ arrayBufferToString(array): string

Parameters​

NameType
arrayArrayBuffer

Returns​

string

Defined in​

src/utils/encode.ts:6


stringToArrayBuffer​

â–¸ stringToArrayBuffer(s): Uint8Array

Parameters​

NameType
sstring

Returns​

Uint8Array

Defined in​

src/utils/encode.ts:10


atobUniversal​

â–¸ atobUniversal(a): Uint8Array

Parameters​

NameType
astring

Returns​

Uint8Array

Defined in​

src/utils/encode.ts:14


btoaUniversal​

â–¸ btoaUniversal(b): string

Parameters​

NameType
bArrayBuffer

Returns​

string

Defined in​

src/utils/encode.ts:18


buf2hex​

â–¸ buf2hex(buffer): string

Parameters​

NameType
bufferUint8Array

Returns​

string

Defined in​

src/utils/encode.ts:22


removeHexPrefix​

â–¸ removeHexPrefix(hex): string

Some function imported from https://github.com/pedrouid/enc-utils/blob/master/src/index.ts enc-utils is no dependency to avoid using Buffer which just works in node and no browsers

Parameters​

NameType
hexstring

Returns​

string

Defined in​

src/utils/encode.ts:31


addHexPrefix​

â–¸ addHexPrefix(hex): string

Parameters​

NameType
hexstring

Returns​

string

Defined in​

src/utils/encode.ts:35


padLeft​

â–¸ padLeft(str, length, padding?): string

Parameters​

NameTypeDefault value
strstringundefined
lengthnumberundefined
paddingstringSTRING_ZERO

Returns​

string

Defined in​

src/utils/encode.ts:49


calcByteLength​

â–¸ calcByteLength(length, byteSize?): number

Parameters​

NameTypeDefault value
lengthnumberundefined
byteSizenumber8

Returns​

number

Defined in​

src/utils/encode.ts:53


sanitizeBytes​

â–¸ sanitizeBytes(str, byteSize?, padding?): string

Parameters​

NameTypeDefault value
strstringundefined
byteSizenumber8
paddingstringSTRING_ZERO

Returns​

string

Defined in​

src/utils/encode.ts:58


sanitizeHex​

â–¸ sanitizeHex(hex): string

Parameters​

NameType
hexstring

Returns​

string

Defined in​

src/utils/encode.ts:62


utf8ToArray​

â–¸ utf8ToArray(str): Uint8Array

Parameters​

NameType
strstring

Returns​

Uint8Array

Defined in​

src/utils/encode.ts:72