@runtime-type-inspector/transpiler 2.0.4 → 2.0.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.
Files changed (3) hide show
  1. package/index.cjs +18 -5
  2. package/index.mjs +18 -5
  3. package/package.json +1 -1
package/index.cjs CHANGED
@@ -587,7 +587,7 @@
587
587
  try {
588
588
  for (_iterator.s(); !(_step = _iterator.n()).done;) {
589
589
  var trailingComment = _step.value;
590
- out += ' ' + this.toSource(trailingComment).trim();
590
+ out += this.toSource(trailingComment);
591
591
  }
592
592
  } catch (err) {
593
593
  _iterator.e(err);
@@ -1581,11 +1581,16 @@
1581
1581
  }, {
1582
1582
  key: "CommentBlock",
1583
1583
  value: function CommentBlock(node) {
1584
- var value = node.value;
1584
+ var value = node.value,
1585
+ loc = node.loc;
1585
1586
  var spaces = this.spaces,
1586
1587
  parents = this.parents;
1587
1588
  var par = parents[parents.length - 3];
1588
- var out = "".concat(spaces, "/*");
1589
+ var out = '';
1590
+ if (!loc.start.column) {
1591
+ out += '\n' + this.spaces;
1592
+ }
1593
+ out += "".concat(spaces, "/*");
1589
1594
  if (value.includes('\n')) {
1590
1595
  value = trimEndSpaces(value.replace(/^\s*\*/gm, '*')).split('\n').filter(function (_) {
1591
1596
  return _.length;
@@ -1604,8 +1609,16 @@
1604
1609
  }, {
1605
1610
  key: "CommentLine",
1606
1611
  value: function CommentLine(node) {
1607
- var value = node.value;
1608
- return "".concat(this.spaces.slice(2), "//").concat(value, "\n");
1612
+ var value = node.value,
1613
+ loc = node.loc;
1614
+ var out = '';
1615
+ if (!loc.start.column) {
1616
+ out += '\n' + this.spaces;
1617
+ } else {
1618
+ out += ' ';
1619
+ }
1620
+ out += "//".concat(value, "\n");
1621
+ return out;
1609
1622
  }
1610
1623
  }, {
1611
1624
  key: "Import",
package/index.mjs CHANGED
@@ -306,7 +306,7 @@ class Stringifier {
306
306
  }
307
307
  if (trailingComments) {
308
308
  for (const trailingComment of trailingComments) {
309
- out += ' ' + this.toSource(trailingComment).trim();
309
+ out += this.toSource(trailingComment);
310
310
  }
311
311
  }
312
312
  this.parents.pop();
@@ -1280,14 +1280,19 @@ class Stringifier {
1280
1280
  }
1281
1281
  CommentBlock(node) {
1282
1282
  let {
1283
- value
1283
+ value,
1284
+ loc
1284
1285
  } = node;
1285
1286
  const {
1286
1287
  spaces,
1287
1288
  parents
1288
1289
  } = this;
1289
1290
  const par = parents[parents.length - 3];
1290
- let out = `${spaces}/*`;
1291
+ let out = '';
1292
+ if (!loc.start.column) {
1293
+ out += '\n' + this.spaces;
1294
+ }
1295
+ out += `${spaces}/*`;
1291
1296
  if (value.includes('\n')) {
1292
1297
  value = trimEndSpaces(value.replace(/^\s*\*/gm, '*')).split('\n').filter(_ => _.length).map((line, i) => (i ? spaces + ' ' : '') + line).join('\n');
1293
1298
  out += `${value}\n${spaces} */`;
@@ -1301,9 +1306,17 @@ class Stringifier {
1301
1306
  }
1302
1307
  CommentLine(node) {
1303
1308
  const {
1304
- value
1309
+ value,
1310
+ loc
1305
1311
  } = node;
1306
- return `${this.spaces.slice(2)}//${value}\n`;
1312
+ let out = '';
1313
+ if (!loc.start.column) {
1314
+ out += '\n' + this.spaces;
1315
+ } else {
1316
+ out += ' ';
1317
+ }
1318
+ out += `//${value}\n`;
1319
+ return out;
1307
1320
  }
1308
1321
  Import(node) {
1309
1322
  return 'import';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@runtime-type-inspector/transpiler",
3
- "version": "2.0.4",
3
+ "version": "2.0.5",
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",