Helper functions for use with trytes.
- isHash
- isTag
- isTrytes
- toTrits
- fromTrits
- tritsValue
- fromAscii
- toAscii
- objectToTrytes
- objectFromTrytes
- stringToTrytes
- stringFromTrytes
- packTrytes
- unpackTrytes
▪ Static
ALPHABET: string
= "9ABCDEFGHIJKLMNOPQRSTUVWXYZ"
All the characters that can be used in trytes.
▸ Static
isHash(trytes
): boolean
Is the string trytes length 81.
Name | Type | Description |
---|---|---|
trytes |
string |
The trytes to test. |
boolean
True if it is trytes 81 chars long.
▸ Static
isTag(trytes
): boolean
Is the string trytes length 27.
Name | Type | Description |
---|---|---|
trytes |
string |
The trytes to test. |
boolean
True if it is trytes 27 chars long.
▸ Static
isTrytes(trytes
): boolean
Is the string trytes of any length.
Name | Type | Description |
---|---|---|
trytes |
string |
The trytes to test. |
boolean
True if it is trytes.
▸ Static
toTrits(value
): Int8Array
Create a trits array from trytes.
Name | Type | Description |
---|---|---|
value |
string |
Trytes used to create trits. |
Int8Array
The trits array.
▸ Static
fromTrits(trits
): string
Get trytes from trits array.
Name | Type | Description |
---|---|---|
trits |
Int8Array |
The trits to convert to trytes. |
string
Trytes.
▸ Static
tritsValue(trits
): number
Convert trits to an integer.
Name | Type | Description |
---|---|---|
trits |
Int8Array |
The trits to convert. |
number
The trits converted to number.
▸ Static
fromAscii(value
): string
Convert a string value into trytes.
Name | Type | Description |
---|---|---|
value |
string |
The value to convert into trytes. |
string
The trytes representation of the value.
▸ Static
toAscii(trytes
): string
Convert trytes into a string value.
Name | Type | Description |
---|---|---|
trytes |
string |
The trytes to convert into a string value. |
string
The string value converted from the trytes.
▸ Static
objectToTrytes(obj
): string
Convert an object to Trytes.
Name | Type | Description |
---|---|---|
obj |
unknown |
The obj to encode. |
string
The encoded trytes value.
▸ Static
objectFromTrytes<T
>(trytes
): undefined
| T
Convert an object from Trytes.
Name |
---|
T |
Name | Type | Description |
---|---|---|
trytes |
string |
The trytes to decode. |
undefined
| T
The decoded object.
▸ Static
stringToTrytes(str
): string
Convert a string to Trytes.
Name | Type | Description |
---|---|---|
str |
string |
The string to encode. |
string
The encoded trytes value.
▸ Static
stringFromTrytes(trytes
): undefined
| string
Convert a string from Trytes.
Name | Type | Description |
---|---|---|
trytes |
string |
The trytes to decode. |
undefined
| string
The decoded string.
▸ Static
packTrytes(trytes
): Uint8Array
Pack trytes into bytes.
Name | Type | Description |
---|---|---|
trytes |
string |
The trytes to pack. |
Uint8Array
The packed trytes.
▸ Static
unpackTrytes(packed
): string
Unpack bytes into trytes.
Name | Type | Description |
---|---|---|
packed |
Uint8Array |
The packed trytes to unpack. |
string
The unpacked trytes.
• new TrytesHelper()