Skip to content
This repository has been archived by the owner on Jun 7, 2023. It is now read-only.

Latest commit

 

History

History
330 lines (187 loc) · 5.03 KB

TrytesHelper.md

File metadata and controls

330 lines (187 loc) · 5.03 KB

Class: TrytesHelper

Helper functions for use with trytes.

Table of contents

Properties

Methods

Constructors

Properties

ALPHABET

Static ALPHABET: string = "9ABCDEFGHIJKLMNOPQRSTUVWXYZ"

All the characters that can be used in trytes.

Methods

isHash

Static isHash(trytes): boolean

Is the string trytes length 81.

Parameters

Name Type Description
trytes string The trytes to test.

Returns

boolean

True if it is trytes 81 chars long.


isTag

Static isTag(trytes): boolean

Is the string trytes length 27.

Parameters

Name Type Description
trytes string The trytes to test.

Returns

boolean

True if it is trytes 27 chars long.


isTrytes

Static isTrytes(trytes): boolean

Is the string trytes of any length.

Parameters

Name Type Description
trytes string The trytes to test.

Returns

boolean

True if it is trytes.


toTrits

Static toTrits(value): Int8Array

Create a trits array from trytes.

Parameters

Name Type Description
value string Trytes used to create trits.

Returns

Int8Array

The trits array.


fromTrits

Static fromTrits(trits): string

Get trytes from trits array.

Parameters

Name Type Description
trits Int8Array The trits to convert to trytes.

Returns

string

Trytes.


tritsValue

Static tritsValue(trits): number

Convert trits to an integer.

Parameters

Name Type Description
trits Int8Array The trits to convert.

Returns

number

The trits converted to number.


fromAscii

Static fromAscii(value): string

Convert a string value into trytes.

Parameters

Name Type Description
value string The value to convert into trytes.

Returns

string

The trytes representation of the value.


toAscii

Static toAscii(trytes): string

Convert trytes into a string value.

Parameters

Name Type Description
trytes string The trytes to convert into a string value.

Returns

string

The string value converted from the trytes.


objectToTrytes

Static objectToTrytes(obj): string

Convert an object to Trytes.

Parameters

Name Type Description
obj unknown The obj to encode.

Returns

string

The encoded trytes value.


objectFromTrytes

Static objectFromTrytes<T>(trytes): undefined | T

Convert an object from Trytes.

Type parameters

Name
T

Parameters

Name Type Description
trytes string The trytes to decode.

Returns

undefined | T

The decoded object.


stringToTrytes

Static stringToTrytes(str): string

Convert a string to Trytes.

Parameters

Name Type Description
str string The string to encode.

Returns

string

The encoded trytes value.


stringFromTrytes

Static stringFromTrytes(trytes): undefined | string

Convert a string from Trytes.

Parameters

Name Type Description
trytes string The trytes to decode.

Returns

undefined | string

The decoded string.


packTrytes

Static packTrytes(trytes): Uint8Array

Pack trytes into bytes.

Parameters

Name Type Description
trytes string The trytes to pack.

Returns

Uint8Array

The packed trytes.


unpackTrytes

Static unpackTrytes(packed): string

Unpack bytes into trytes.

Parameters

Name Type Description
packed Uint8Array The packed trytes to unpack.

Returns

string

The unpacked trytes.

Constructors

constructor

new TrytesHelper()