Platform independent universal utils that must be able to run in nodejs and in the browser.
Test the /bin scripts in the cli after making changes here to ensure the code is compatible
with both environments
- Source:
Methods
(static) base62encode(num) → {string}
The input number can be a bigInt, integer number or
a string representing a number. Non decimal strings
need to start with a prefix 0x (hex), 0o (octal) or 0b (binary)
Parameters:
Name | Type | Description |
---|---|---|
num |
number | string | input number |
Returns:
encoded string
- Type
- string
(static) createVEFLayerConfig(record) → {object}
Create an object that uses the VEF internal layer structure from the capabilitiesParser/catalog metadata
Parameters:
Name | Type | Description |
---|---|---|
record |
object | metadata from catalog or capabilitiesParser for a layer |
Returns:
object containing formatted layer metadata
- Type
- object
(static) generateLayerId(serviceType, url, layerName)
Helper function to create the ID for the catalog
Parameters:
Name | Type | Description |
---|---|---|
serviceType |
string | |
url |
string | |
layerName |
string |
(static) generateShortId(input, truncate)
Hashes the input with the sha256 algorithm and truncates the hexadecimal hash length
to the desired size. The result will be encoded to alphanumeric characters
using base62.
Truncating a sha2 hash is considered safe, but reducing the amount of bits
increases the risk of collision. Default truncation value is 12-hex which results
in a 48bit integer. The resulting base62 ID will moslty have a length of mostly 8 characters.
Parameters:
Name | Type | Description |
---|---|---|
input |
string | |
truncate |
number | default = 12 |
Returns:
encoded id