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