Utilities
Hat & Tree ID Utils
Following are utility functions to handle various hat & tree ID formats. More information about hat IDs can be found here.
hatIdDecimalToHex
Convert a hat ID from decimal to hex.
Arguments:
hatId
- Hat ID in decimal format.
Response:
Hat ID in a hex format.
hatIdHexToDecimal
Convert a hat ID from hex to decimal.
Arguments:
hatId
- Hat ID in hex format.
Response:
Hat ID in a decimal format.
treeIdDecimalToHex
Convert a tree ID from decimal to hex. A tree ID is the first 4 bytes in a hat ID.
Arguments:
treeId
- Tree ID in decimal format.
Response:
Tree ID in a hex format.
treeIdHexToDecimal
Convert a tree ID from hex to decimal. A tree ID is the first 4 bytes in a hat ID.
Arguments:
treeId
- Tree ID in hex format.
Response:
Tree ID in a decimal format.
treeIdToTopHatId
Convert a tree ID to its top-hat ID. A tree ID is the first 4 bytes in a hat ID.
Arguments:
treeId
- Tree ID in decimal format.
Response:
Top-hat ID in decimal format.
hatIdToTreeId
Convert a hat ID to its tree ID. A tree ID is the first 4 bytes in a hat ID.
Arguments:
hatId
- Hat ID in decimal format.
Response:
Tree ID of the hat, in a decimal format.
hatIdDecimalToIp
The IP format may be used as a "pretty" hat ID format for presenting.
For example, a hat with a hex ID of:
0x00000001000a0002000000000000000000000000000000000000000000000000
will have an IP format of 1.10.2 - Each level is separated by a dot and presented as a decimal number, excluding zeros.
Arguments:
hatId
- Hat ID in decimal format.
Response:
Hat ID in IP format.
hatIdIpToDecimal
Convert a hat ID from an IP format, to a decimal format.
Arguments:
hatId
- Hat ID in IP format.
Response:
Hat ID in decimal format.
Constants
Following are Hats-specific exported constant values.
Last updated