Methods
(static) batches(path) → {Array}
A function to read the contents of a directory and to extract all files with the file extension *.json.
| Name | Type | Description |
|---|---|---|
path | String | A given path as string. |
Returns all JSON files contained in path.
- Type:
- Array
(static) cookie(r)
A function to retrieve all cookie fields of an HTTP/S request.
| Name | Type | Description |
|---|---|---|
r | Object | An HTTP/S request retrieved from the |
Returns an array of all cookie fields in the format:
[ [field_1, value_1], [field_2, value_2], ..., [field_n, value_n] ]
Returns an empty array in case no cookie is present.
(static) count(condition, value) → {Number}
Implementation of a conditional counter.
| Name | Type | Description |
|---|---|---|
condition | Boolean | Either true or false. Note, the condition is not evaluated in the function. |
value | Number | The current count (of a certain feature). |
Returns value + 1 in case condition == true or value otherwise.
- Type:
- Number
(static) header(headers, key) → {Object}
A function to extract a header field from the HTTP/S header of a request. NOTE: The matching is case insensitive.
| Name | Type | Description |
|---|---|---|
headers | Array | An array of HTTP/S header fields in the format |
key | String | An HTTP/S header key like |
The requested HTTP/S header in the format:
{ name: "key", value: "value" }
Returns undefined in case header with name === key is not present.
- Type:
- Object
(static) isDir(path) → {Boolean}
A function to check whether a path is a directory. This is a wrapper function for fs.lstatSync(path).isDirectory().
| Name | Type | Description |
|---|---|---|
path | String | A given path as string. |
- Type:
- Boolean
(static) max(x, y) → {Number}
A wrapper function for Math.max().
| Name | Type | Description |
|---|---|---|
x | Number | The first number. |
y | Number | The second number. |
Returns the greater number.
- Type:
- Number
(static) params(r) → {Array}
A function to retrieve all query parameters of an HTTP/S request.
| Name | Type | Description |
|---|---|---|
r | Object | An HTTP/S request retrieved from the |
Returns an array of all query parameters in the format:
[ [param_1, value_1], [param_2, value_2], ..., [param_n, value_n] ]
Returns an empty array in case no query parameters are present.
- Type:
- Array
(static) path(dir) → {String}
A function to check whether an absolute or relative path exists.
| Name | Type | Description |
|---|---|---|
dir | String | A given path as string. |
Returns the path in case it exists. Returns null otherwise.
- Type:
- String
(static) ratio(dividend, divisor) → {Number}
A function to compute the ratio of two numbers. NOTE: Returns 0 in case that the divisor is 0.
| Name | Type | Description |
|---|---|---|
dividend | Number | The dividend of the ratio. |
divisor | Number | The divisor of the ratio. |
The ratio between two numbers.
- Type:
- Number
(static) source(r) → {String}
A function to extract the source of an HTTP/S request. The function will use the initiator property of the request. If this property is absent, the function tries to extract the source from the referer or origin HTTP/S header.
| Name | Type | Description |
|---|---|---|
r | Object | An HTTP/S request retrieved from the |
Returns the full source URL as string. Returns undefined in case no source could be extracted.
- Type:
- String
(static) target(r) → {String}
A function to extract the target URL of an HTTP/S request. The function will extract the url property of the request and falls back to the url property of the response in case no url property is present in the request.
| Name | Type | Description |
|---|---|---|
r | Object | An HTTP/S request retrieved from the |
Returns the full target URL as string. Returns undefined in case the url property is neither present in the request nor the response.
- Type:
- String
(static) zeroOrOne(condition) → {Number}
A function to encode boolean values as number (1 for true, 0 for false). The encoding is later needed, when the data is fed into the classifier.
| Name | Type | Description |
|---|---|---|
condition | Boolean | Either |
Returns 1 in case true is passed, 0 otherwise.
- Type:
- Number