Members
(static, constant) vt
Colors constants for changing Console appearance ala DEC's VT52 + VT100 + VT220.
Example
ANSI Color Escape Sequence
\x1b[***m -- where '***' is a series of command codes separated by semi-colons (;).
Code Effect -- notes
------------------------------------------------------------------------------
0 Reset / Normal -- all attributes off
1 Bold -- increased intensity
2 Faint -- decreased intensity - not widely supported
3 Italic -- not widely supported, sometimes treated as inverse
4 Underline
5 Slow Blink -- less than 150 per minute
6 Rapid Blink -- MS-DOS ANSI.SYS; 150+ per minute; not widely supported
7 Reverse video -- swap foreground and background colors
8 Conceal -- not widely supported.
9 Crossed-out -- characters legible, but marked for deletion. Not widely supported
10 Primary font (default)
11–19 Alternate font -- select alternate font n-10
20 Fraktur -- hardly ever supported
21 Bold off or Double Underline -- bold off not widely supported; double underline hardly ever supported
22 Normal color or intensity -- neither bold nor faint
23 Not italic, not Fraktur
24 Underline roundOff -- not singly or doubly underlined
25 Blink off
27 Inverse off
28 Reveal conceal off
29 Not crossed out
30–37 Set foreground color -- see color table below
38 Set foreground color -- next arguments are 5;<n> or 2;<r>;<g>;<b>, see below
39 Default foreground color -- implementation defined (according to standard)
40–47 Set background color -- see color table below
48 Set background color -- next arguments are 5;<n> or 2;<r>;<g>;<b>, see below
49 Default background color -- implementation defined (according to standard)
51 Framed
52 Encircled
53 Overlined
54 Not framed or encircled
55 Not overlined
60 ideogram underline -- hardly ever supported
61 ideogram double underline -- hardly ever supported
62 ideogram overline -- hardly ever supported
63 ideogram double overline -- hardly ever supported
64 ideogram stress marking hardly ever supported
65 ideogram attributes off reset the effects of all of 60-64
90–97 Set bright foreground color aixterm (not in standard)
100–107 Set bright background color aixterm (not in standard)
Methods
(static) exp(message, source, exception) → {string}
logs an exception to the Console in a standardized format and a stack dump.
Parameters:
| Name | Type | Description |
|---|---|---|
message |
object | pre-formatted message to be logged. |
source |
string | where the message orginated. |
exception |
string | the underlying exception message that was caught. |
Returns:
"message: {message} - exception: {exception}" for display in UI.
- Type
- string
(static) extractId(objectName) → {string}
Extracts an alpha-numberic ID Field from a string, intended to be a unique portion of a common string.
Parameters:
| Name | Type | Description |
|---|---|---|
objectName |
string | typically a file name, but can be any string, to extract an ID Field from. |
Returns:
the extracted ID Field.
Rules for extracting the ID Field:
----------------------------------
1. The ID Field is assumed to be the first alpha-numeric field in the string.
2. The ID Field is assumed to be Letters + Numbers, with no spaces or special characters.
3. The ID Field is assumed to be either at the beginning or end of the string, or separated by non-alpha-numeric characters.
4. The ID Field cound have lowercase 'placeholders' for numbers, like 'PxCy' or 'PnCn' for 'P1C2'.
- Type
- string
Example
const str1 = "CG_BRKE01_20231116.L5K";
const str2 = "CG_BRKE03_20231116.L5K";
console.log(extractIdField(str1)); // Expected output: "BRKE01"
console.log(extractIdField(str2)); // Expected output: "BRKE03"
const str1 = "EP_GPT13TZ1_20231115_0800.L5K";
const str2 = "EP_GPT13TZ2_20231113_1600.L5K";
console.log(extractIdField(str1)); // Expected output: "GPT13TZ1"
console.log(extractIdField(str2)); // Expected output: "GPT13TZ2"
const str1 = "SEP_P1C2_GMP_ARL.L5K";
const str2 = "SEP_P3C0_GMP_ARL.L5K";
console.log(extractIdField(str1)); // Expected output: "P1C2"
console.log(extractIdField(str2)); // Expected output: "P3C0"
const str1 = "SEP_P1C2_GMP_ARL.L5K";
const str2 = "SEP_PxCy_GMP.L5K";
console.log(extractIdField(str1)); // Expected output: "P1C2"
console.log(extractIdField(str2)); // Expected output: "PxCy"
(static) fnc(message, source)
logs 'function call' showing call patterns to the Console in a standardized format.
Parameters:
| Name | Type | Description |
|---|---|---|
message |
object | pre-formatted message to be logged. |
source |
string | where the message orginated. |
Returns:
nothing.
(static) isJson(object) → {boolean}
Checks a string for embedded JSON data.
Parameters:
| Name | Type | Description |
|---|---|---|
object |
object | string to be tested |
Returns:
a value indicating whether or not the object contains a JSON string
- Type
- boolean
(static) isNumber(numberToCheck) → {boolean}
Checks for NaN.
Parameters:
| Name | Type | Description |
|---|---|---|
numberToCheck |
any | as a number of some type |
Returns:
a value indicating whether or not it is NaN.
- Type
- boolean
(static) isObject(jsObject) → {boolean}
Checks whether or not a string is a JS Object.
Parameters:
| Name | Type | Description |
|---|---|---|
jsObject |
object | string to be tested |
Returns:
a value indicating whether or not the string is a JS Object.
- Type
- boolean
(static) isString(object) → {boolean}
Checks the type of an Object for String.
Parameters:
| Name | Type | Description |
|---|---|---|
object |
object | to be tested |
Returns:
a value indicating whether or not the object is a string
- Type
- boolean
(static) isUndefined(objectToCheck) → {boolean}
Checks for undefined.
Parameters:
| Name | Type | Description |
|---|---|---|
objectToCheck |
any | as a variable of some type |
Returns:
a value indicating whether or not it is UNDEFINED.
- Type
- boolean
(static) listifyArray(arrayToListify, outputType) → {string}
Converts an array of text items into a HTML or JSX List.
Parameters:
| Name | Type | Description |
|---|---|---|
arrayToListify |
Array.<any> | the array to be convert to a HTML List. |
outputType |
string | how to out the list: 'html' or 'jsx'. |
Returns:
the HTML List code.
- Type
- string
(static) log(message, source, severity, error) → {string}
Logs App Events to the Console in a standardized format.
Parameters:
| Name | Type | Description |
|---|---|---|
message |
object | pre-formatted message to be logged. |
source |
string | where the message orginated. |
severity |
string | Event.Severity: 'info', 'warn', 'error', 'exception', and 'success'. |
error |
string | [Optional] error message from another source. |
Returns:
"{severiy}: {message}" for display in UI.
- Type
- string
Example
From our other MicroCODE Apps:
++
Message: 'Station SYNCHRONIZED to new Job from TRACKING IMAGE'
Class: JobIdZone Audience: Operator
Object: 8 Condition: Takt=[0%] Memory in use=[1,659,216.00]
Event: 14 Severity: Confirmation
Targets: AppLog, AppBanner, AppDatabase, AppSound
Event: (see 'Message:' above) Time: Tuesday, August 10, 2021 06:57:47.623 AM
Class: MicroCODE.AppBanner Type: App.Information CSN:[1GA4174210 ]
--
(static) logify(textToLogify) → {string}
Formats a string of BRACES, BRACKETS, QUOTES, for display in the EVENT LOG.
No formatting occurs until the opening brace '{' of the JSON Data. VT Escape sequences are stripped.
Parameters:
| Name | Type | Description |
|---|---|---|
textToLogify |
string | the string to be formatted for the event log |
Returns:
the logified text
- Type
- string
(static) logifyObject(objectToLogify) → {string}
Converts a JSON Object into loggable text, like JSON.stringify() but with more control.
Parameters:
| Name | Type | Description |
|---|---|---|
objectToLogify |
object |
Returns:
the logified object
- Type
- string
(static) simplify(object) → {string}
Strips a string of BRACES, BRACKETS, QUOTES, etc.
Parameters:
| Name | Type | Description |
|---|---|---|
object |
object | the string to be simplified to data |
Returns:
the simplified text
- Type
- string
(static) simplifyObject(objectToSimplify) → {string}
Strips an object of BRACES, BRACKETS, QUOTES, etc.
Parameters:
| Name | Type | Description |
|---|---|---|
objectToSimplify |
object | the object to be formatted for the event log |
Returns:
the simplified object
- Type
- string
(static) timestamp(local) → {string}
Generates timestamp string: YYYY-MM-DD Day HH:MM:SS.mmm.
Parameters:
| Name | Type | Description |
|---|---|---|
local |
boolean | [Optional] determines whether or not local time is used, if not it returns use UTC. |
Returns:
"YYYY-MM-DD Day HH:MM:SS.mmm UTC|Local".
- Type
- string