@runtime-type-inspector/transpiler 2.0.10 → 2.0.12

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 (3) hide show
  1. package/index.cjs +17 -3
  2. package/index.mjs +17 -4
  3. package/package.json +1 -1
package/index.cjs CHANGED
@@ -1938,15 +1938,15 @@
1938
1938
  i--;
1939
1939
  while (i >= 0) {
1940
1940
  parent = parents[i];
1941
- if (parent.leadingComments) {
1942
- return parent;
1943
- }
1944
1941
  if (parent.type === 'CallExpression') {
1945
1942
  break;
1946
1943
  }
1947
1944
  if (nodeIsFunction(parent)) {
1948
1945
  break;
1949
1946
  }
1947
+ if (parent.leadingComments) {
1948
+ return parent;
1949
+ }
1950
1950
  i--;
1951
1951
  }
1952
1952
  }
@@ -2355,6 +2355,19 @@
2355
2355
  return out;
2356
2356
  }
2357
2357
 
2358
+ function compareAST(left, right) {
2359
+ var l = parser.parse(left, {
2360
+ sourceType: 'module'
2361
+ });
2362
+ var r = parser.parse(right, {
2363
+ sourceType: 'module'
2364
+ });
2365
+ var ljson = ast2jsonForComparison(l);
2366
+ var rjson = ast2jsonForComparison(r);
2367
+ var test = ljson === rjson;
2368
+ return test;
2369
+ }
2370
+
2358
2371
  function expandType(type) {
2359
2372
  var ast = parseType(type);
2360
2373
  return toSourceTS(ast);
@@ -2700,6 +2713,7 @@
2700
2713
  exports.ast2json = ast2json;
2701
2714
  exports.ast2jsonForComparison = ast2jsonForComparison;
2702
2715
  exports.code2ast2code = code2ast2code;
2716
+ exports.compareAST = compareAST;
2703
2717
  exports.expandType = expandType;
2704
2718
  exports.expandTypeBabelTS = expandTypeBabelTS;
2705
2719
  exports.expandTypeDepFree = expandTypeDepFree;
package/index.mjs CHANGED
@@ -1607,15 +1607,15 @@ class Asserter extends Stringifier {
1607
1607
  i--;
1608
1608
  while (i >= 0) {
1609
1609
  parent = parents[i];
1610
- if (parent.leadingComments) {
1611
- return parent;
1612
- }
1613
1610
  if (parent.type === 'CallExpression') {
1614
1611
  break;
1615
1612
  }
1616
1613
  if (nodeIsFunction(parent)) {
1617
1614
  break;
1618
1615
  }
1616
+ if (parent.leadingComments) {
1617
+ return parent;
1618
+ }
1619
1619
  i--;
1620
1620
  }
1621
1621
  }
@@ -1983,6 +1983,19 @@ function code2ast2code(code) {
1983
1983
  return out;
1984
1984
  }
1985
1985
 
1986
+ function compareAST(left, right) {
1987
+ const l = parse(left, {
1988
+ sourceType: 'module'
1989
+ });
1990
+ const r = parse(right, {
1991
+ sourceType: 'module'
1992
+ });
1993
+ const ljson = ast2jsonForComparison(l);
1994
+ const rjson = ast2jsonForComparison(r);
1995
+ const test = ljson === rjson;
1996
+ return test;
1997
+ }
1998
+
1986
1999
  function expandType(type) {
1987
2000
  const ast = parseType(type);
1988
2001
  return toSourceTS(ast);
@@ -2325,4 +2338,4 @@ function toSourceBabelTS(node) {
2325
2338
  }
2326
2339
  }
2327
2340
 
2328
- export { Asserter, Stringifier, addTypeChecks, ast2json, ast2jsonForComparison, code2ast2code, expandType, expandTypeBabelTS, expandTypeDepFree, extractCurlyContent, extractNameAndOptionality, nodeIsFunction, parseJSDoc, parseJSDocSetter, parseJSDocTypedef, parseType, parseTypeBabelTS, simplifyType, toSourceBabelTS, toSourceTS, trimEndSpaces };
2341
+ export { Asserter, Stringifier, addTypeChecks, ast2json, ast2jsonForComparison, code2ast2code, compareAST, expandType, expandTypeBabelTS, expandTypeDepFree, extractCurlyContent, extractNameAndOptionality, nodeIsFunction, parseJSDoc, parseJSDocSetter, parseJSDocTypedef, parseType, parseTypeBabelTS, simplifyType, toSourceBabelTS, toSourceTS, trimEndSpaces };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@runtime-type-inspector/transpiler",
3
- "version": "2.0.10",
3
+ "version": "2.0.12",
4
4
  "description": "Validating JSDoc types at runtime for high-quality types - Trust is good, control is better.",
5
5
  "main": "./index.cjs",
6
6
  "module": "./index.mjs",