Class: Util

Util

Utilities for the openEO JS Client.
Source:

Methods

(static) base64encode(str) → {string}

Encodes a string into Base64 encoding.
Parameters:
Name Type Description
str string String to encode.
Source:
Returns:
String encoded in Base64.
Type
string

(static) compareVersionNumbers(v1, v2) → {integer|null}

Compares two version number. Handles only numeric version numbers separated by dots, doesn't allow wildcards or pre-release strings as `alpha` or `beta`.
Parameters:
Name Type Description
v1 string A version number.
v2 string Another version number.
Source:
See:
  • Util.validateVersionNumber()
Returns:
- `1` if v1 is greater than v2, `-1` if v1 is less than v2 and `0` if v1 and v2 are equal. Returns `null` if any of the version numbers is invalid.
Type
integer | null

(static) hash(o) → {string}

Non-crypthographic (unsafe) hashing for objects. Internally uses Jenkins one_at_a_time hash function.
Parameters:
Name Type Description
o * A value to encode. Only supported objects, arrays, strings, numbers and booleans. Can't encode functions or other data types.
Source:
See:
Returns:
The generated hash.
Type
string

(static) hashString(b) → {string}

Generates a hash for a string using Jenkins one_at_a_time hash function.
Parameters:
Name Type Description
b string string to encode.
Source:
See:
Returns:
The generated hash.
Type
string

(static) isObject(obj) → {boolean}

Checks whether a variable is a real object or not. This is a more strict version of `typeof x === 'object'` as this example would also succeeds for arrays and `null`. This function only returns `true` for real objects and not for arrays, `null` or any other data types.
Parameters:
Name Type Description
obj * A variable to check.
Source:
Returns:
- `true` is the given variable is an object, `false` otherwise.
Type
boolean

(static) mostCompatible(versions) → {Array.<object>}

Tries to guess the most suitable version from a well-known discovery document that this client is compatible to.
Parameters:
Name Type Description
versions object A well-known discovery document compliant to the API specification.
Source:
Returns:
- Gives a list that lists all compatible versions (as still API compliant objects) ordered from the most suitable to the least suitable.
Type
Array.<object>

(static) normalizeUrl(baseUrl, path) → {string}

Normalize a URL (mostly handling slashes).
Parameters:
Name Type Default Description
baseUrl string The URL to normalize
path string null An optional path to add to the URL
Source:
Returns:
Normalized URL.
Type
string

(async, static) saveToFileNode(data, filename)

Streams data into a file. NOTE: Only supported in a NodeJS environment.
Parameters:
Name Type Description
data Stream Data stream to read from.
filename string File path to store the data at.
Source:
Throws:
Error

(static) validateVersionNumber(v) → {boolean}

Validates a version number. Handles only numeric version numbers separated by dots, doesn't allow wildcards or pre-release strings as `alpha` or `beta`.
Parameters:
Name Type Description
v string A version number.
Source:
Returns:
- `true` if valid, `false` otherwise.
Type
boolean