Namespace: encode
References​
IS_BROWSER​
Re-exports IS_BROWSER
Functions​
arrayBufferToString​
â–¸ arrayBufferToString(array
): string
Convert array buffer to string
[internal usage]
Parameters​
Name | Type |
---|---|
array | ArrayBuffer |
Returns​
string
Defined in​
utf8ToArray​
â–¸ utf8ToArray(str
): Uint8Array
Convert utf8-string to Uint8Array
[internal usage]
Parameters​
Name | Type |
---|---|
str | string |
Returns​
Uint8Array
Defined in​
stringToArrayBuffer​
â–¸ stringToArrayBuffer(str
): Uint8Array
Convert utf8-string to Uint8Array
Deprecated
equivalent to 'utf8ToArray', alias will be removed
Parameters​
Name | Type |
---|---|
str | string |
Returns​
Uint8Array
Defined in​
atobUniversal​
â–¸ atobUniversal(a
): Uint8Array
Convert string to array buffer (browser and node compatible)
Parameters​
Name | Type |
---|---|
a | string |
Returns​
Uint8Array
Defined in​
btoaUniversal​
â–¸ btoaUniversal(b
): string
Convert array buffer to string (browser and node compatible)
Parameters​
Name | Type |
---|---|
b | ArrayBuffer |
Returns​
string
Defined in​
buf2hex​
â–¸ buf2hex(buffer
): string
Convert array buffer to hex-string
Parameters​
Name | Type |
---|---|
buffer | Uint8Array |
Returns​
string
format: hex-string
Defined in​
removeHexPrefix​
â–¸ removeHexPrefix(hex
): string
Remove hex prefix '0x' from hex-string
Parameters​
Name | Type | Description |
---|---|---|
hex | string | hex-string |
Returns​
string
format: base16-string
Defined in​
addHexPrefix​
â–¸ addHexPrefix(hex
): string
Add hex prefix '0x' to base16-string
Parameters​
Name | Type | Description |
---|---|---|
hex | string | base16-string |
Returns​
string
format: hex-string
Defined in​
padLeft​
â–¸ padLeft(str
, length
, padding?
): string
Prepend string (default with '0')
Parameters​
Name | Type | Default value |
---|---|---|
str | string | undefined |
length | number | undefined |
padding | string | STRING_ZERO |
Returns​
string
Defined in​
calcByteLength​
â–¸ calcByteLength(str
, byteSize?
): number
Calculate byte length of string
[no internal usage]
Parameters​
Name | Type | Default value |
---|---|---|
str | string | undefined |
byteSize | number | 8 |
Returns​
number
Defined in​
sanitizeBytes​
â–¸ sanitizeBytes(str
, byteSize?
, padding?
): string
Prepend '0' to string bytes
[no internal usage]
Parameters​
Name | Type | Default value |
---|---|---|
str | string | undefined |
byteSize | number | 8 |
padding | string | STRING_ZERO |
Returns​
string
Defined in​
sanitizeHex​
â–¸ sanitizeHex(hex
): string
Prepend '0' to hex-string bytes
[no internal usage]
Parameters​
Name | Type | Description |
---|---|---|
hex | string | hex-string |
Returns​
string
format: hex-string
Defined in​
pascalToSnake​
â–¸ pascalToSnake(text
): string
String transformation util
Pascal case to screaming snake case
Parameters​
Name | Type |
---|---|
text | string |
Returns​
string