bare-script 3.8.3 → 3.8.5

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.
@@ -1,6 +1,8 @@
1
1
  # Licensed under the MIT License
2
2
  # https://github.com/craigahobbs/bare-script/blob/main/LICENSE
3
3
 
4
+ include <dataTable.bare>
5
+
4
6
 
5
7
  # The URL arguments model
6
8
  argsTypes = schemaParse( \
@@ -179,8 +181,6 @@ endfunction
179
181
  # $function: argsHelp
180
182
  # $group: args.bare
181
183
  # $doc: Generate the [arguments model's](model.html#var.vName='ArgsArguments') help content
182
- # $doc:
183
- # $doc: **NOTE:** Calling this function requires `include <dataTable.bare>`
184
184
  # $arg arguments: The [arguments model](model.html#var.vName='ArgsArguments')
185
185
  # $return: The array of help Markdown line strings
186
186
  function argsHelp(arguments):
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, isAsync) {
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, isAsync);
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, isAsync) : false;
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, isAsync) : false;
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, isAsync) {
582
+ function isAsyncExpression(expr, globals, isAsyncScope) {
583
583
  const [exprKey] = Object.keys(expr);
584
584
  if (exprKey === 'function') {
585
- // Global function not exist? Assume its OK for the scope
586
- const funcValue = globals[expr.function.name] ?? null;
587
- if (funcValue === null) {
588
- return isAsync;
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
- return typeof funcValue === 'function' && funcValue.constructor.name === 'AsyncFunction';
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, isAsync) || isAsyncExpression(expr.binary.right, globals, isAsync);
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, isAsync);
602
+ return isAsyncExpression(expr.unary.expr, globals, isAsyncScope);
597
603
  } else if (exprKey === 'group') {
598
- return isAsyncExpression(expr.group, globals, isAsync);
604
+ return isAsyncExpression(expr.group, globals, isAsyncScope);
599
605
  }
600
606
  return false;
601
607
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "bare-script",
4
- "version": "3.8.3",
4
+ "version": "3.8.5",
5
5
  "description": "BareScript; a lightweight scripting and expression language",
6
6
  "keywords": [
7
7
  "expression",