bare-script 2.2.8 → 2.2.9

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.
Files changed (2) hide show
  1. package/lib/parser.js +2 -16
  2. package/package.json +1 -1
package/lib/parser.js CHANGED
@@ -346,7 +346,7 @@ export function parseScript(scriptText, startLineNumber = 1) {
346
346
  const matchBreak = line.match(rScriptBreak);
347
347
  if (matchBreak !== null) {
348
348
  // Get the loop definition
349
- const labelDef = (labelDefs.length > 0 ? arrayFindLast(labelDefs, (def) => !('if' in def)) : null);
349
+ const labelDef = (labelDefs.length > 0 ? (labelDefs.findLast((def) => !('if' in def)) ?? null) : null);
350
350
  if (labelDef === null) {
351
351
  throw new BareScriptParserError('Break statement outside of loop', line, 1, startLineNumber + ixLine);
352
352
  }
@@ -362,7 +362,7 @@ export function parseScript(scriptText, startLineNumber = 1) {
362
362
  const matchContinue = line.match(rScriptContinue);
363
363
  if (matchContinue !== null) {
364
364
  // Get the loop definition
365
- const labelDef = (labelDefs.length > 0 ? arrayFindLast(labelDefs, (def) => !('if' in def)) : null);
365
+ const labelDef = (labelDefs.length > 0 ? (labelDefs.findLast((def) => !('if' in def)) ?? null) : null);
366
366
  if (labelDef === null) {
367
367
  throw new BareScriptParserError('Continue statement outside of loop', line, 1, startLineNumber + ixLine);
368
368
  }
@@ -449,20 +449,6 @@ export function parseScript(scriptText, startLineNumber = 1) {
449
449
  }
450
450
 
451
451
 
452
- // Firefox versions prior to 103 are missing Array.findLast - Debian Bookworm has Firefox 102
453
- function arrayFindLast(array, findFn) {
454
- let ixValue = array.length - 1;
455
- while (ixValue >= 0) {
456
- const value = array[ixValue];
457
- if (findFn(value)) {
458
- return value;
459
- }
460
- ixValue -= 1;
461
- }
462
- return null;
463
- }
464
-
465
-
466
452
  // BareScript expression regex
467
453
  const rExprBinaryOp = /^\s*(\*\*|\*|\/|%|\+|-|<=|<|>=|>|==|!=|&&|\|\|)/;
468
454
  const rExprUnaryOp = /^\s*(!|-)/;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "bare-script",
4
- "version": "2.2.8",
4
+ "version": "2.2.9",
5
5
  "description": "BareScript; a lightweight scripting and expression language",
6
6
  "keywords": [
7
7
  "expression",