bare-script 3.8.4 → 3.8.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/include/dataTable.bare +12 -1
- package/lib/model.js +20 -14
- package/package.json +1 -1
|
@@ -127,7 +127,7 @@ function dataTableMarkdown(data, model):
|
|
|
127
127
|
value = objectGet(row, field)
|
|
128
128
|
valueType = systemType(value)
|
|
129
129
|
if valueType == 'string':
|
|
130
|
-
valueFormat = value
|
|
130
|
+
valueFormat = stringTrim(value)
|
|
131
131
|
elif valueType == 'number':
|
|
132
132
|
valueFormat = numberToFixed(value, precisionNumber, precisionTrim)
|
|
133
133
|
elif valueType == 'datetime':
|
|
@@ -135,6 +135,12 @@ function dataTableMarkdown(data, model):
|
|
|
135
135
|
else:
|
|
136
136
|
valueFormat = stringNew(value)
|
|
137
137
|
endif
|
|
138
|
+
|
|
139
|
+
# Eliminate value string newlines
|
|
140
|
+
valueFormat = regexReplace(dataTableMarkdownRegexMultipleNewline, valueFormat, '<br><br>')
|
|
141
|
+
valueFormat = regexReplace(dataTableMarkdownRegexSingleNewline, valueFormat, ' ')
|
|
142
|
+
|
|
143
|
+
# Set the field value string
|
|
138
144
|
objectSet(rowFormat, field, valueFormat)
|
|
139
145
|
|
|
140
146
|
# Update the field width
|
|
@@ -190,6 +196,11 @@ function dataTableMarkdown(data, model):
|
|
|
190
196
|
endfunction
|
|
191
197
|
|
|
192
198
|
|
|
199
|
+
# Field value newline replacement regular expressions
|
|
200
|
+
dataTableMarkdownRegexMultipleNewline = regexNew('\r?\n(?:\r?\n)+')
|
|
201
|
+
dataTableMarkdownRegexSingleNewline = regexNew('\r?\n')
|
|
202
|
+
|
|
203
|
+
|
|
193
204
|
# Helper to generate the Markdown field text
|
|
194
205
|
function dataTableMarkdownField(value, width, align, fill):
|
|
195
206
|
spaces = width - stringLength(value)
|
package/lib/model.js
CHANGED
|
@@ -565,37 +565,43 @@ function isPointlessExpression(expr) {
|
|
|
565
565
|
|
|
566
566
|
|
|
567
567
|
// Helper function to determine if a statement requires async
|
|
568
|
-
function isAsyncStatement(statement, globals,
|
|
568
|
+
function isAsyncStatement(statement, globals, isAsyncScope) {
|
|
569
569
|
const [statementKey] = Object.keys(statement);
|
|
570
570
|
if (statementKey === 'expr') {
|
|
571
|
-
return isAsyncExpression(statement.expr.expr, globals,
|
|
571
|
+
return isAsyncExpression(statement.expr.expr, globals, isAsyncScope);
|
|
572
572
|
} else if (statementKey === 'jump') {
|
|
573
|
-
return 'expr' in statement.jump ? isAsyncExpression(statement.jump.expr, globals,
|
|
573
|
+
return 'expr' in statement.jump ? isAsyncExpression(statement.jump.expr, globals, isAsyncScope) : false;
|
|
574
574
|
} else if (statementKey === 'return') {
|
|
575
|
-
return 'expr' in statement.return ? isAsyncExpression(statement.return.expr, globals,
|
|
575
|
+
return 'expr' in statement.return ? isAsyncExpression(statement.return.expr, globals, isAsyncScope) : false;
|
|
576
576
|
}
|
|
577
577
|
return false;
|
|
578
578
|
}
|
|
579
579
|
|
|
580
580
|
|
|
581
581
|
// Helper function to determine if an expression statement requires async
|
|
582
|
-
function isAsyncExpression(expr, globals,
|
|
582
|
+
function isAsyncExpression(expr, globals, isAsyncScope) {
|
|
583
583
|
const [exprKey] = Object.keys(expr);
|
|
584
584
|
if (exprKey === 'function') {
|
|
585
|
-
//
|
|
586
|
-
const
|
|
587
|
-
if (
|
|
588
|
-
return
|
|
585
|
+
// Builtin function?
|
|
586
|
+
const funcName = expr.function.name;
|
|
587
|
+
if (builtinGlobals.has(funcName)) {
|
|
588
|
+
return false;
|
|
589
589
|
}
|
|
590
590
|
|
|
591
|
-
// Is function async?
|
|
592
|
-
|
|
591
|
+
// Is function async? Assume unknown OK for the scope
|
|
592
|
+
let isAsync = isAsyncScope;
|
|
593
|
+
const funcValue = globals[funcName] ?? null;
|
|
594
|
+
if (typeof funcValue === 'function') {
|
|
595
|
+
isAsync = (funcValue.constructor.name === 'AsyncFunction') ||
|
|
596
|
+
('args' in expr.function && expr.function.args.some((argExpr) => isAsyncExpression(argExpr, globals, isAsyncScope)));
|
|
597
|
+
}
|
|
598
|
+
return isAsync;
|
|
593
599
|
} else if (exprKey === 'binary') {
|
|
594
|
-
return isAsyncExpression(expr.binary.left, globals,
|
|
600
|
+
return isAsyncExpression(expr.binary.left, globals, isAsyncScope) || isAsyncExpression(expr.binary.right, globals, isAsyncScope);
|
|
595
601
|
} else if (exprKey === 'unary') {
|
|
596
|
-
return isAsyncExpression(expr.unary.expr, globals,
|
|
602
|
+
return isAsyncExpression(expr.unary.expr, globals, isAsyncScope);
|
|
597
603
|
} else if (exprKey === 'group') {
|
|
598
|
-
return isAsyncExpression(expr.group, globals,
|
|
604
|
+
return isAsyncExpression(expr.group, globals, isAsyncScope);
|
|
599
605
|
}
|
|
600
606
|
return false;
|
|
601
607
|
}
|