bare-script 3.8.18 → 3.8.20
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/args.bare +1 -1
- package/lib/include/diff.bare +2 -6
- package/lib/include/qrcode.bare +2 -2
- package/lib/library.js +65 -0
- package/package.json +5 -3
package/lib/include/args.bare
CHANGED
|
@@ -232,7 +232,7 @@ function argsGlobalName(argument):
|
|
|
232
232
|
global = objectGet(argument, 'global')
|
|
233
233
|
if global == null:
|
|
234
234
|
name = objectGet(argument, 'name')
|
|
235
|
-
global = 'v' + stringUpper(
|
|
235
|
+
global = 'v' + stringUpper(stringCharAt(name, 0)) + stringSlice(name, 1)
|
|
236
236
|
endif
|
|
237
237
|
return global
|
|
238
238
|
endfunction
|
package/lib/include/diff.bare
CHANGED
|
@@ -132,19 +132,15 @@ function diffLinesToArray(input):
|
|
|
132
132
|
if systemType(input) == 'array':
|
|
133
133
|
lines = []
|
|
134
134
|
for part in input:
|
|
135
|
-
arrayExtend(lines,
|
|
135
|
+
arrayExtend(lines, stringSplitLines(part))
|
|
136
136
|
endfor
|
|
137
137
|
return lines
|
|
138
138
|
endif
|
|
139
139
|
|
|
140
140
|
# String input
|
|
141
|
-
lines =
|
|
141
|
+
lines = stringSplitLines(input)
|
|
142
142
|
if arrayLength(lines) == 1 && arrayGet(lines, 0) == '':
|
|
143
143
|
return []
|
|
144
144
|
endif
|
|
145
145
|
return lines
|
|
146
146
|
endfunction
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
# Regex for splitting lines
|
|
150
|
-
diffRegexLineSplit = regexNew('\r?\n')
|
package/lib/include/qrcode.bare
CHANGED
|
@@ -583,8 +583,8 @@ function qrcodeModeAlphanumericBits(message):
|
|
|
583
583
|
messageLengthMinusOne = messageLength - 1
|
|
584
584
|
ixChar = 0
|
|
585
585
|
while ixChar < messageLength:
|
|
586
|
-
value1 = stringIndexOf(qrcodeModeAlphanumericStr,
|
|
587
|
-
value2 = if(ixChar < messageLengthMinusOne, stringIndexOf(qrcodeModeAlphanumericStr,
|
|
586
|
+
value1 = stringIndexOf(qrcodeModeAlphanumericStr, stringCharAt(message, ixChar))
|
|
587
|
+
value2 = if(ixChar < messageLengthMinusOne, stringIndexOf(qrcodeModeAlphanumericStr, stringCharAt(message, ixChar + 1)))
|
|
588
588
|
if value2 == null:
|
|
589
589
|
arrayExtend(messageBits, qrcodeBytesToBits([value1], 6))
|
|
590
590
|
else:
|
package/lib/library.js
CHANGED
|
@@ -9,8 +9,11 @@ import {
|
|
|
9
9
|
addCalculatedField, aggregateData, filterData, joinData, parseCSV, sortData, topData, validateData
|
|
10
10
|
} from './data.js';
|
|
11
11
|
import {validateType, validateTypeModel} from 'schema-markdown/lib/schema.js';
|
|
12
|
+
import {evaluateExpression} from './runtime.js';
|
|
13
|
+
import {parseExpression} from './parser.js';
|
|
12
14
|
import {parseSchemaMarkdown} from 'schema-markdown/lib/parser.js';
|
|
13
15
|
import {typeModel} from 'schema-markdown/lib/typeModel.js';
|
|
16
|
+
import {validateExpression} from './model.js';
|
|
14
17
|
|
|
15
18
|
|
|
16
19
|
/* eslint-disable id-length */
|
|
@@ -385,6 +388,48 @@ const arraySortArgs = valueArgsModel([
|
|
|
385
388
|
]);
|
|
386
389
|
|
|
387
390
|
|
|
391
|
+
//
|
|
392
|
+
// BareScript functions
|
|
393
|
+
//
|
|
394
|
+
|
|
395
|
+
|
|
396
|
+
// $function: barescriptEvaluateExpression
|
|
397
|
+
// $group: barescript
|
|
398
|
+
// $doc: Evaluate a [BareScript expression model](../model/#var.vName='Expression')
|
|
399
|
+
// $arg expr: The [BareScript expression model](../model/#var.vName='Expression')
|
|
400
|
+
// $arg locals: Optional (default is null). The local variables object.
|
|
401
|
+
// $arg builtins: Optional (default is true). If true, include the [built-in expression functions](expression.html).
|
|
402
|
+
// $return: The expression result
|
|
403
|
+
function barescriptEvaluateExpression(args, options) {
|
|
404
|
+
const [expr, locals_, builtins] = valueArgsValidate(barescriptEvaluateExpressionArgs, args);
|
|
405
|
+
validateExpression(expr);
|
|
406
|
+
return evaluateExpression(expr, options, locals_, builtins);
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
const barescriptEvaluateExpressionArgs = valueArgsModel([
|
|
410
|
+
{'name': 'expr', 'type': 'object'},
|
|
411
|
+
{'name': 'locals', 'type': 'object', 'nullable': true},
|
|
412
|
+
{'name': 'builtins', 'type': 'boolean', 'default': true}
|
|
413
|
+
]);
|
|
414
|
+
|
|
415
|
+
|
|
416
|
+
// $function: barescriptParseExpression
|
|
417
|
+
// $group: barescript
|
|
418
|
+
// $doc: Parse a BareScript expression
|
|
419
|
+
// $arg exprStr: The expression string
|
|
420
|
+
// $arg arrayLiterals: Optional (default is true). If true, allow array literals.
|
|
421
|
+
// $return: The [BareScript expression model](../model/#var.vName='Expression')
|
|
422
|
+
function barescriptParseExpression(args) {
|
|
423
|
+
const [exprStr, arrayLiterals] = valueArgsValidate(barescriptParseExpressionArgs, args);
|
|
424
|
+
return parseExpression(exprStr, null, null, arrayLiterals);
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
const barescriptParseExpressionArgs = valueArgsModel([
|
|
428
|
+
{'name': 'exprStr', 'type': 'string'},
|
|
429
|
+
{'name': 'arrayLiterals', 'type': 'boolean', 'default': true}
|
|
430
|
+
]);
|
|
431
|
+
|
|
432
|
+
|
|
388
433
|
//
|
|
389
434
|
// Coverage functions
|
|
390
435
|
//
|
|
@@ -1918,6 +1963,23 @@ const stringSplitArgs = valueArgsModel([
|
|
|
1918
1963
|
]);
|
|
1919
1964
|
|
|
1920
1965
|
|
|
1966
|
+
// $function: stringSplitLines
|
|
1967
|
+
// $group: string
|
|
1968
|
+
// $doc: Split a string at line boundaries
|
|
1969
|
+
// $arg string: The string to split
|
|
1970
|
+
// $return: The array of line strings
|
|
1971
|
+
function stringSplitLines(args) {
|
|
1972
|
+
const [string] = valueArgsValidate(stringSplitLinesArgs, args);
|
|
1973
|
+
return string.split(stringSplitLinesRegex);
|
|
1974
|
+
}
|
|
1975
|
+
|
|
1976
|
+
const stringSplitLinesArgs = valueArgsModel([
|
|
1977
|
+
{'name': 'string', 'type': 'string'}
|
|
1978
|
+
]);
|
|
1979
|
+
|
|
1980
|
+
const stringSplitLinesRegex = /\r?\n/;
|
|
1981
|
+
|
|
1982
|
+
|
|
1921
1983
|
// $function: stringStartsWith
|
|
1922
1984
|
// $group: string
|
|
1923
1985
|
// $doc: Determine if a string starts with a search string
|
|
@@ -2282,6 +2344,8 @@ export const scriptFunctions = {
|
|
|
2282
2344
|
arrayShift,
|
|
2283
2345
|
arraySlice,
|
|
2284
2346
|
arraySort,
|
|
2347
|
+
barescriptEvaluateExpression,
|
|
2348
|
+
barescriptParseExpression,
|
|
2285
2349
|
coverageGlobalGet,
|
|
2286
2350
|
'coverageGlobalName': coverageGlobalNameFn,
|
|
2287
2351
|
coverageStart,
|
|
@@ -2366,6 +2430,7 @@ export const scriptFunctions = {
|
|
|
2366
2430
|
stringReplace,
|
|
2367
2431
|
stringSlice,
|
|
2368
2432
|
stringSplit,
|
|
2433
|
+
stringSplitLines,
|
|
2369
2434
|
stringStartsWith,
|
|
2370
2435
|
stringTrim,
|
|
2371
2436
|
stringUpper,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"type": "module",
|
|
3
3
|
"name": "bare-script",
|
|
4
|
-
"version": "3.8.
|
|
4
|
+
"version": "3.8.20",
|
|
5
5
|
"description": "BareScript; a lightweight scripting and expression language",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"expression",
|
|
@@ -31,8 +31,10 @@
|
|
|
31
31
|
"schema-markdown": "~1.2"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
|
-
"
|
|
35
|
-
"
|
|
34
|
+
"@eslint/js": "~10.0",
|
|
35
|
+
"c8": "~11.0",
|
|
36
|
+
"eslint": "~10.0",
|
|
37
|
+
"globals": "~17.4",
|
|
36
38
|
"jsdoc": "~4.0"
|
|
37
39
|
}
|
|
38
40
|
}
|