Functions

encodeName(name)string.<uint64>

Encode a name (a base32 string) to a number.

For performance reasons, the blockchain uses the numerical encoding of strings for very common types like account names.

decodeName(value)string
DecimalString()string

Normalize and validate decimal string (potentially large values). Should avoid internationalization issues if possible but will be safe and throw an error for an invalid number.

Normalization removes extra zeros or decimal.

DecimalPad(value, precision)string

Ensure a fixed number of decimal places. Safe for large numbers.

DecimalImply()

Ensures proper trailing zeros then removes decimal place.

DecimalUnimply(value, precision)number

Put the decimal place back in its position and return the normalized number string (with any unnecessary zeros or an unnecessary decimal removed).

encodeName(name) ⇒ string.<uint64>

Encode a name (a base32 string) to a number.

For performance reasons, the blockchain uses the numerical encoding of strings for very common types like account names.

Kind: global function
Returns: string.<uint64> - - compressed string (from name arg). A string is always used because a number could exceed JavaScript's 52 bit limit.
See: types.hpp string_to_name

Param Type Description
name string A string to encode, up to 12 characters long.

decodeName(value) ⇒ string

Kind: global function

Param Type Description
value Long | String | number uint64

DecimalString() ⇒ string

Normalize and validate decimal string (potentially large values). Should avoid internationalization issues if possible but will be safe and throw an error for an invalid number.

Normalization removes extra zeros or decimal.

Kind: global function
Returns: string - value

DecimalPad(value, precision) ⇒ string

Ensure a fixed number of decimal places. Safe for large numbers.

Kind: global function
Returns: string - decimal part is added and zero padded to match precision
See: ./format.test.js

Param Type Description
value number | string | object.toString
precision number number of decimal places

Example

DecimalPad(10.2, 3) === '10.200'

  

DecimalImply()

Ensures proper trailing zeros then removes decimal place.

Kind: global function

DecimalUnimply(value, precision) ⇒ number

Put the decimal place back in its position and return the normalized number string (with any unnecessary zeros or an unnecessary decimal removed).

Kind: global function
Returns: number - 1.0000

Param Type Description
value string | number | value.toString 10000
precision number 4