@nudojs/parser 1.1.5 → 1.1.8

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/dist/index.js +9 -22
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -210,12 +210,12 @@ function absLit(v) {
210
210
  if (v === null) return absNullLit();
211
211
  return absUndefLit();
212
212
  }
213
- var CASE_NAME_REGEX = /@nudo:case\s+"([^"]+)"\s*\(/g;
214
- var MOCK_INLINE_REGEX = /@nudo:mock\s+(\w+)\s*=\s*(.+)/g;
215
- var MOCK_FROM_REGEX = /@nudo:mock\s+(\w+)\s+from\s+"([^"]+)"/g;
216
- var PURE_REGEX = /@nudo:pure\b/g;
217
- var SKIP_REGEX = /@nudo:skip(?:\s+(.+))?/g;
218
- var SAMPLE_REGEX = /@nudo:sample\s+(\d+)/g;
213
+ var CASE_NAME_REGEX = /(?:^|\n)[ \t]*(?:\*[ \t]*)?@nudo:case\s+"([^"]+)"\s*\(/g;
214
+ var MOCK_INLINE_REGEX = /(?:^|\n)[ \t]*(?:\*[ \t]*)?@nudo:mock\s+(\w+)\s*=\s*(.+)/g;
215
+ var MOCK_FROM_REGEX = /(?:^|\n)[ \t]*(?:\*[ \t]*)?@nudo:mock\s+(\w+)\s+from\s+"([^"]+)"/g;
216
+ var PURE_REGEX = /(?:^|\n)[ \t]*(?:\*[ \t]*)?@nudo:pure\b/g;
217
+ var SKIP_REGEX = /(?:^|\n)[ \t]*(?:\*[ \t]*)?@nudo:skip\b(?:[ \t]+(\S[^\n]*))?/g;
218
+ var SAMPLE_REGEX = /(?:^|\n)[ \t]*(?:\*[ \t]*)?@nudo:sample[ \t]+(\d+)/g;
219
219
  var CONSTRAINT_EXPR_RE = /^(number|string|boolean|any|array|shape|lit|union|fn|partial|pick|omit|record|required|readonly|nonNullable|and)\s*\(/;
220
220
  function tryParseConstraint(expr) {
221
221
  const s = expr.trim();
@@ -350,11 +350,6 @@ function scanWithStrings(s, onChar, onStructural) {
350
350
  const ch = s[i];
351
351
  if (inString) {
352
352
  onChar(ch, i);
353
- if (ch === "\\") {
354
- i++;
355
- if (i < s.length) onChar(s[i], i);
356
- continue;
357
- }
358
353
  if (ch === inString) inString = null;
359
354
  continue;
360
355
  }
@@ -388,11 +383,6 @@ function splitTopLevelArgs(s) {
388
383
  const ch = s[i];
389
384
  if (inString) {
390
385
  current += ch;
391
- if (ch === "\\") {
392
- i++;
393
- if (i < s.length) current += s[i];
394
- continue;
395
- }
396
386
  if (ch === inString) inString = null;
397
387
  continue;
398
388
  }
@@ -455,10 +445,6 @@ function extractBalancedParens(text, startIdx) {
455
445
  for (let i = startIdx; i < text.length; i++) {
456
446
  const ch = text[i];
457
447
  if (inString) {
458
- if (ch === "\\") {
459
- i++;
460
- continue;
461
- }
462
448
  if (ch === inString) inString = null;
463
449
  continue;
464
450
  }
@@ -726,7 +712,8 @@ function parseDirectivesFromComments(comments) {
726
712
  const restLine = text.slice(afterParen).split("\n")[0].trim();
727
713
  const arrowMatch = restLine.match(/^=>\s*(.+)/);
728
714
  const expected = arrowMatch ? parseCaseArgExpr(arrowMatch[1].trim()) : void 0;
729
- const linesBeforeMatch = text.slice(0, match.index).split("\n").length - 1;
715
+ const tagOffset = match.index + match[0].indexOf("@nudo:case");
716
+ const linesBeforeMatch = text.slice(0, tagOffset).split("\n").length - 1;
730
717
  const commentLine = commentStartLine + linesBeforeMatch;
731
718
  directives.push({
732
719
  kind: "case",
@@ -822,7 +809,7 @@ function findReplaceSeparator(raw) {
822
809
  for (let i = 0; i < raw.length; i++) {
823
810
  const ch = raw[i];
824
811
  if (inString) {
825
- if (ch === inString && raw[i - 1] !== "\\") inString = null;
812
+ if (ch === inString) inString = null;
826
813
  continue;
827
814
  }
828
815
  if (ch === '"' || ch === "'") {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nudojs/parser",
3
- "version": "1.1.5",
3
+ "version": "1.1.8",
4
4
  "engines": {
5
5
  "node": ">=20"
6
6
  },
@@ -39,7 +39,7 @@
39
39
  "registry": "https://registry.npmjs.org"
40
40
  },
41
41
  "dependencies": {
42
- "@nudojs/core": "1.2.0",
42
+ "@nudojs/core": "1.3.0",
43
43
  "@babel/types": "^8.0.6"
44
44
  },
45
45
  "scripts": {