Classes
Methods
(static) barescriptLintUnboundGlobals(model, globalsopt, nullable) → {Array.<string>}
Compute the unbound global variables of a BareScript script or expression model - the global variables and functions it uses that it does not define
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
model |
Object | The BareScript model or expression model |
||
globals |
Object |
<optional> <nullable> |
null | The bound global variables object (name to value), such as the host's built-in functions |
- Source:
Returns:
The sorted array of unbound global variable names
- Type
- Array.<string>
(static) barescriptTypeModel() → {Object}
Get the BareScript type model
- Source:
Returns:
The BareScript type model
- Type
- Object
(static) barescriptValidateExpression(expr) → {Object}
Validate an expression model
Parameters:
| Name | Type | Description |
|---|---|---|
expr |
Object | The expression model |
- Source:
Throws:
Returns:
The validated expression model
- Type
- Object
(static) barescriptValidateScript(script) → {Object}
Validate a BareScript model
Parameters:
| Name | Type | Description |
|---|---|---|
script |
Object | The BareScript model |
- Source:
Throws:
Returns:
The validated BareScript model
- Type
- Object
(static) base64Decode(text) → (nullable) {Array.<number>}
Decode a base64 string to a byte value array
Parameters:
| Name | Type | Description |
|---|---|---|
text |
string | The base64-encoded string |
- Source:
Returns:
The byte value array, or null if decoding fails
- Type
- Array.<number>
(static) base64Encode(bytes) → (nullable) {string}
Encode a byte value array (or a string, as UTF-8) as a base64 string
Parameters:
| Name | Type | Description |
|---|---|---|
bytes |
Array.<number> | string | The byte value array (integers 0 to 255) or string |
- Source:
Returns:
The base64-encoded string, or null if encoding fails
- Type
- string
(static) dataAggregate(data, aggregation) → {Array.<Object>}
Aggregate a data array
Parameters:
| Name | Type | Description |
|---|---|---|
data |
Array.<Object> | The data array |
aggregation |
Object | The aggregation model |
- Source:
Returns:
The aggregated data array
- Type
- Array.<Object>
(static) dataCalculatedField(data, fieldName, expr, variablesopt, nullable) → {Array.<Object>}
Add a calculated field to a data array
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
data |
Array.<Object> | The data array |
||
fieldName |
string | The calculated field name |
||
expr |
string | The calculated field expression |
||
variables |
Object |
<optional> <nullable> |
null | The expression variables object |
- Source:
Returns:
The updated data array
- Type
- Array.<Object>
(static) dataFilter(data, expr, variablesopt, nullable) → {Array.<Object>}
Filter a data array
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
data |
Array.<Object> | The data array |
||
expr |
string | The filter expression |
||
variables |
Object |
<optional> <nullable> |
null | The expression variables object |
- Source:
Returns:
The filtered data array
- Type
- Array.<Object>
(static) dataJoin(leftData, rightData, joinExpr, rightExpropt, nullable, isLeftJoinopt, nullable, variablesopt, nullable) → {Array.<Object>}
Join two data arrays
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
leftData |
Array.<Object> | The left data array |
||
rightData |
Array.<Object> | The right data array |
||
joinExpr |
string | The join expression |
||
rightExpr |
string |
<optional> <nullable> |
null | The right join expression |
isLeftJoin |
boolean |
<optional> <nullable> |
null | If true, perform a left join (always include left row) |
variables |
Object |
<optional> <nullable> |
null | The join expression variables object |
- Source:
Returns:
The joined data array
- Type
- Array.<Object>
(static) dataLineChartElements(data, lineChart, optionsopt, nullable) → {Object}
Render a line chart as an element model
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
data |
Array.<Object> | The data array |
||
lineChart |
Object | The line chart model |
||
options |
Object |
<optional> <nullable> |
null | The line chart options object |
- Source:
Returns:
The line chart element model
- Type
- Object
(static) dataLineChartValidate(lineChart) → {Object}
Validate a line chart model
Parameters:
| Name | Type | Description |
|---|---|---|
lineChart |
Object | The line chart model |
- Source:
Throws:
Returns:
The validated line chart model
- Type
- Object
(static) dataParseCSV(text) → {Array.<Object>}
Parse CSV text to a data array
Parameters:
| Name | Type | Description |
|---|---|---|
text |
string | Array.<string> | The CSV text or array of CSV text |
- Source:
Returns:
The data array
- Type
- Array.<Object>
(static) dataSort(data, sorts) → {Array.<Object>}
Sort a data array
Parameters:
| Name | Type | Description |
|---|---|---|
data |
Array.<Object> | The data array |
sorts |
Array.<Array> | The array of sort tuples, [field] or [field, descending] |
- Source:
Returns:
The sorted data array
- Type
- Array.<Object>
(static) dataTableElements(data, dataTableopt, nullable) → {Object}
Render a data table as an element model
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
data |
Array.<Object> | The data array |
||
dataTable |
Object |
<optional> <nullable> |
null | The data table model |
- Source:
Returns:
The data table element model
- Type
- Object
(static) dataTableMarkdown(data, modelopt, nullable) → {Array.<string>}
Create the array of Markdown table line strings
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
data |
Array.<Object> | The array of row objects |
||
model |
Object |
<optional> <nullable> |
null | The data table model |
- Source:
Returns:
The array of Markdown table line strings
- Type
- Array.<string>
(static) dataTableValidate(dataTable) → {Object}
Validate a data table model
Parameters:
| Name | Type | Description |
|---|---|---|
dataTable |
Object | The data table model |
- Source:
Throws:
Returns:
The validated data table model
- Type
- Object
(static) dataTop(data, countopt, nullable, categoryFieldsopt, nullable) → {Array.<Object>}
Keep the top rows for each category
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
data |
Array.<Object> | The data array |
||
count |
number |
<optional> <nullable> |
null | The number of rows to keep (default is 1) |
categoryFields |
Array.<string> |
<optional> <nullable> |
null | The category fields |
- Source:
Returns:
The top data array
- Type
- Array.<Object>
(static) dataValidate(data, csvopt, nullable) → {Object}
Validate a data array
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
data |
Array.<Object> | The data array |
||
csv |
boolean |
<optional> <nullable> |
null | If true, parse value strings |
- Source:
Throws:
Returns:
The map of field name to field type
- Type
- Object
(static) elementModelToString(elementsnullable, indentopt, nullable) → {string}
Render an element model to an HTML or SVG string
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
elements |
Object | Array |
<nullable> |
The element model |
|
indent |
string | number |
<optional> <nullable> |
null | The indentation string or number of spaces |
- Source:
Returns:
The HTML or SVG string
- Type
- string
(static) elementModelValidate(elementsnullable) → (nullable) {Object|Array}
Validate an element model
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
elements |
Object | Array |
<nullable> |
The element model |
- Source:
Throws:
Returns:
The validated element model
- Type
- Object | Array
(static) gzipCompress(bytes, levelopt, nullable) → (nullable) {Array.<number>}
Compress a byte value array (or a string, as UTF-8) with gzip
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
bytes |
Array.<number> | string | The byte value array (integers 0 to 255) or string |
||
level |
number |
<optional> <nullable> |
null | The compression level, 0 (store) through 9 (best); default is 6 |
- Source:
Returns:
The gzip-compressed byte value array, or null if compression fails
- Type
- Array.<number>
(static) gzipUncompress(bytes) → (nullable) {Array.<number>}
Uncompress a gzip-compressed byte value array
Parameters:
| Name | Type | Description |
|---|---|---|
bytes |
Array.<number> | The gzip-compressed byte value array (integers 0 to 255) |
- Source:
Returns:
The uncompressed byte value array, or null if uncompression fails
- Type
- Array.<number>
(static) hashEqual(left, right) → (nullable) {boolean}
Compare two values (e.g. message authentication codes) in constant time - every byte is compared, so the time taken doesn't reveal how much of a guessed value is right
Parameters:
| Name | Type | Description |
|---|---|---|
left |
Array.<number> | string | The first byte value array or string |
right |
Array.<number> | string | The second byte value array or string |
- Source:
Returns:
true if the values are equal, false if not, or null if an argument is invalid
- Type
- boolean
(static) hashHMACSHA256(key, message) → (nullable) {Array.<number>}
Compute the HMAC-SHA256 message authentication code of a message (e.g. a JWT HS256 signature)
Parameters:
| Name | Type | Description |
|---|---|---|
key |
Array.<number> | string | The key byte value array or string |
message |
Array.<number> | string | The message byte value array or string |
- Source:
Returns:
The 32-byte message authentication code byte value array, or null if an argument is invalid
- Type
- Array.<number>
(static) hashHex(bytes) → (nullable) {string}
Format a byte value array (e.g. a hash) as a lowercase hexadecimal string
Parameters:
| Name | Type | Description |
|---|---|---|
bytes |
Array.<number> | string | The byte value array or string |
- Source:
Returns:
The hexadecimal string, or null if the argument is invalid
- Type
- string
(static) hashSHA256(bytes) → (nullable) {Array.<number>}
Compute the SHA-256 hash of a byte value array (or a string, as UTF-8)
Parameters:
| Name | Type | Description |
|---|---|---|
bytes |
Array.<number> | string | The byte value array (integers 0 to 255) or string |
- Source:
Returns:
The 32-byte hash byte value array, or null if the argument is invalid
- Type
- Array.<number>
(static) includeSetLogFn(logFnnullable)
Set the include library stub function log function. Include library logging is debug-level, so setting a log function also enables debug logging for the stub function calls.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
logFn |
function |
<nullable> |
The log function, or null to disable logging |
- Source:
(static) markdownElements(markdown, optionsopt, nullable) → {Array.<Object>}
Generate an element model from a Markdown model
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
markdown |
Object | The Markdown model |
||
options |
Object |
<optional> <nullable> |
null | The Markdown elements options object |
- Source:
Returns:
The Markdown's element model
- Type
- Array.<Object>
(static) markdownElementsAsync(markdown, optionsopt, nullable) → {Array.<Object>}
Generate an element model from a Markdown model
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
markdown |
Object | The Markdown model |
||
options |
Object |
<optional> <nullable> |
null | The Markdown elements options object |
- Source:
Returns:
The Markdown's element model
- Type
- Array.<Object>
(static) markdownEscape(text) → {string}
Escape a string for inclusion in Markdown text
Parameters:
| Name | Type | Description |
|---|---|---|
text |
string | The text to escape |
- Source:
Returns:
The escaped text
- Type
- string
(static) markdownHeaderId(text) → {string}
Generate a Markdown header ID from text
Parameters:
| Name | Type | Description |
|---|---|---|
text |
string | The text |
- Source:
Returns:
The header element ID
- Type
- string
(static) markdownParagraphText(paragraph) → {string}
Get a Markdown paragraph model's text
Parameters:
| Name | Type | Description |
|---|---|---|
paragraph |
Object | The Markdown paragraph model |
- Source:
Returns:
The paragraph text string
- Type
- string
(static) markdownParse(text) → {Object}
Parse Markdown text into a Markdown model
Parameters:
| Name | Type | Description |
|---|---|---|
text |
string | Array.<string> | The Markdown text |
- Source:
Returns:
The Markdown model
- Type
- Object
(static) markdownTitle(markdown) → (nullable) {string}
Get a Markdown model's title
Parameters:
| Name | Type | Description |
|---|---|---|
markdown |
Object | The Markdown model |
- Source:
Returns:
The title string or null
- Type
- string
(static) markdownToString(markdown, wrapWidthopt, refCountopt) → {string}
Render a Markdown model as Markdown text
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
markdown |
Object | The Markdown model |
||
wrapWidth |
number |
<optional> |
100 | The text wrap width. If zero or less, text is not wrapped. |
refCount |
number |
<optional> |
0 | The minimum number of occurrences of a link/image URL for which a link/image reference is rendered. If zero or less, all links/images are rendered inline. |
- Source:
Returns:
The Markdown text
- Type
- string
(static) markdownValidate(markdown) → {Object}
Validate a Markdown model
Parameters:
| Name | Type | Description |
|---|---|---|
markdown |
Object | The Markdown model |
- Source:
Throws:
Returns:
The validated Markdown model
- Type
- Object
(static) qrcodeElements(message, size, levelopt, nullable) → {Object}
Generate the element model for a QR code
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
message |
string | Array.<Array> | The QR code message or the QR code matrix |
||
size |
number | The size of the QR code, in pixels |
||
level |
string |
<optional> <nullable> |
null | The error correction level: 'low', 'medium', 'quartile', or 'high' |
- Source:
Returns:
The QR code SVG element model
- Type
- Object
(static) qrcodeMatrix(message, levelopt, nullable) → {Array.<Array>}
Generate a QR code pixel matrix
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
message |
string | The QR code message |
||
level |
string |
<optional> <nullable> |
null | The error correction level: 'low', 'medium', 'quartile', or 'high' |
- Source:
Returns:
The QR code pixel matrix
- Type
- Array.<Array>
(static) schemaDocMarkdown(types, typeName, optionsopt, nullable) → {Array.<string>}
Generate the Schema Markdown user type documentation as an array of Markdown text lines
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
types |
Object | The schema's type model |
||
typeName |
string | The type name |
||
options |
Object |
<optional> <nullable> |
null | The schema documentation options object |
- Source:
Returns:
The array of Markdown text lines
- Type
- Array.<string>
(static) schemaGetEnumValues(types, enumModel) → {Array.<Object>}
Get an enum's values (inherited values first)
Parameters:
| Name | Type | Description |
|---|---|---|
types |
Object | The schema's type model |
enumModel |
Object | The enum model |
- Source:
Returns:
The array of enum value models
- Type
- Array.<Object>
(static) schemaGetReferencedTypes(types, typeName, referencedTypesopt, nullable) → {Object}
Get a user type's referenced type model
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
types |
Object | The schema's type model |
||
typeName |
string | The type name |
||
referencedTypes |
Object |
<optional> <nullable> |
null | A map of referenced user type name to user type model to update |
- Source:
Returns:
The referenced type model
- Type
- Object
(static) schemaGetStructMembers(types, struct) → {Array.<Object>}
Get a struct's members (inherited members first)
Parameters:
| Name | Type | Description |
|---|---|---|
types |
Object | The schema's type model |
struct |
Object | The struct model |
- Source:
Returns:
The array of struct member models
- Type
- Array.<Object>
(static) schemaParse(text, typesopt, nullable, filenameopt, nullable, validateopt, nullable) → {Object}
Parse Schema Markdown text
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
text |
string | Array.<string> | The Schema Markdown text |
||
types |
Object |
<optional> <nullable> |
null | The schema's type model to update |
filename |
string |
<optional> <nullable> |
null | The file name (for error messages) |
validate |
boolean |
<optional> <nullable> |
null | If true (the default), validate the type model after parsing |
- Source:
Throws:
Returns:
The schema's type model
- Type
- Object
(static) schemaTypeModel() → {Object}
Get the Schema Markdown type model
- Source:
Returns:
The Schema Markdown type model
- Type
- Object
(static) schemaTypeModelValidate(types) → {Object}
Validate a Schema Markdown type model
Parameters:
| Name | Type | Description |
|---|---|---|
types |
Object | The schema's type model to validate |
- Source:
Throws:
Returns:
The validated type model
- Type
- Object
(static) schemaValidate(types, typeName, value, memberFqnopt, nullable) → {*}
Validate a value using a schema type model
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
types |
Object | The schema's type model |
||
typeName |
string | The type name |
||
value |
* | The value to validate |
||
memberFqn |
string |
<optional> <nullable> |
null | The fully-qualified member name (for error messages) |
- Source:
Throws:
Returns:
The validated, transformed value
- Type
- *
(static) tarCreate(files) → (nullable) {Array.<number>}
Create a tar archive (USTAR format) from an array of regular files. Each file has mode 644, and no directory entries are written.
Parameters:
| Name | Type | Description |
|---|---|---|
files |
Array.<Object> | The array of file objects. Each file object has the following members: - "name" - the file path - "bytes" - the file content byte value array (integers 0 to 255) or string (as UTF-8) - "mtime" - the optional file modification datetime (default is the Unix epoch) |
- Source:
Returns:
The tar archive byte value array, or null if creation fails
- Type
- Array.<number>
(static) tarExtract(bytes) → (nullable) {Array.<Object>}
Extract the regular files of a tar archive (USTAR, GNU, or PAX format)
Parameters:
| Name | Type | Description |
|---|---|---|
bytes |
Array.<number> | The tar archive byte value array (integers 0 to 255) |
- Source:
Returns:
The array of file objects, each with "name", "bytes", and "mtime" (the modification datetime) members, or null if extraction fails
- Type
- Array.<Object>
(static) urlDecodeComponent(string) → (nullable) {string}
Decode a percent-encoded string component
Parameters:
| Name | Type | Description |
|---|---|---|
string |
string | The string component to decode |
- Source:
Returns:
The decoded string, or null on failure
- Type
- string
(static) urlDecodeQueryString(queryString) → (nullable) {Object}
Decode a URL query string to an object
Parameters:
| Name | Type | Description |
|---|---|---|
queryString |
string | The query string to decode |
- Source:
Returns:
The decoded query string object, or null on failure
- Type
- Object
(static) urlEncode(url) → {string}
Encode a URL
Parameters:
| Name | Type | Description |
|---|---|---|
url |
string | The URL to encode |
- Source:
Returns:
The encoded URL
- Type
- string
(static) urlEncodeComponent(url) → {string}
Encode a URL component
Parameters:
| Name | Type | Description |
|---|---|---|
url |
string | The URL component to encode |
- Source:
Returns:
The encoded URL component
- Type
- string
(static) urlEncodeQueryString(obj) → {string}
Encode an object as a URL query string
Parameters:
| Name | Type | Description |
|---|---|---|
obj |
Object | The object to encode |
- Source:
Returns:
The encoded query string
- Type
- string