yini-parser 1.0.0-alpha.7x → 1.0.1-beta

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.
@@ -1,30 +1,30 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const env_1 = require("../config/env");
4
- const system_1 = require("../utils/system");
4
+ const print_1 = require("../utils/print");
5
5
  const parseStringLiteral = (raw) => {
6
6
  var _a;
7
- (0, system_1.debugPrint)('-> Entered parseStringLiteral(..)');
8
- (0, system_1.debugPrint)('raw = >>>' + raw + '<<<');
7
+ (0, print_1.debugPrint)('-> Entered parseStringLiteral(..)');
8
+ (0, print_1.debugPrint)('raw = >>>' + raw + '<<<');
9
9
  /*
10
10
  Extracts an optional prefix (C, c, H, or h) and identifies whether
11
11
  the string is triple-quoted, double-quoted, or single-quoted.
12
12
  */
13
13
  const prefixMatch = raw.match(/^(C|c|H|h|R|r)?("""|"|')/);
14
- (0, system_1.debugPrint)('prefixMatch:');
14
+ (0, print_1.debugPrint)('prefixMatch:');
15
15
  if ((0, env_1.isDebug)()) {
16
16
  console.debug(prefixMatch);
17
17
  }
18
18
  let prefix = prefixMatch ? (_a = prefixMatch[1]) === null || _a === void 0 ? void 0 : _a.toUpperCase() : '';
19
- (0, system_1.debugPrint)(' prefix = ' + prefix);
19
+ (0, print_1.debugPrint)(' prefix = ' + prefix);
20
20
  let quoteType = prefixMatch ? prefixMatch[2] : '';
21
- (0, system_1.debugPrint)(' quoteType = ' + quoteType);
22
- (0, system_1.debugPrint)('quoteType.length = ' + quoteType.length);
21
+ (0, print_1.debugPrint)(' quoteType = ' + quoteType);
22
+ (0, print_1.debugPrint)('quoteType.length = ' + quoteType.length);
23
23
  // Extracts the substring after removing the initial prefix (if any)
24
24
  // and quotes at the start (prefix.length + quoteType.length) and the
25
25
  // quotes at the end (-quoteType.length).
26
26
  let inner = raw.slice(((prefix === null || prefix === void 0 ? void 0 : prefix.length) || 0) + quoteType.length, -quoteType.length);
27
- (0, system_1.debugPrint)('inner (raw) = ' + inner);
27
+ (0, print_1.debugPrint)('inner (raw) = ' + inner);
28
28
  if (prefix === 'C') {
29
29
  inner = inner
30
30
  .replace(/\\n/g, '\n')
@@ -34,7 +34,7 @@ const parseStringLiteral = (raw) => {
34
34
  else if (prefix === 'H') {
35
35
  inner = inner.replace(/[\s\n\r]+/g, ' ').trim();
36
36
  }
37
- (0, system_1.debugPrint)('inner (reformat) = ' + inner);
37
+ (0, print_1.debugPrint)('inner (reformat) = ' + inner);
38
38
  return inner;
39
39
  };
40
40
  exports.default = parseStringLiteral;
@@ -6,7 +6,7 @@
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
7
  exports.stripNLAndAfter = exports.isDigit = exports.isAlpha = exports.isEnclosedInBackticks = exports.trimBackticks = void 0;
8
8
  exports.splitLines = splitLines;
9
- const system_1 = require("./system");
9
+ const print_1 = require("./print");
10
10
  /**
11
11
  * Splits a string into an array of lines, handling both LF and CRLF newlines.
12
12
  * @param content The input string.
@@ -90,8 +90,8 @@ const stripNLAndAfter = (line) => {
90
90
  // debugPrint('stripNLAndAfter(..): idx2 = ' + idx2)
91
91
  const idx = Math.min(idx1, idx2);
92
92
  const resultLine = idx === Number.MAX_SAFE_INTEGER ? line : line.substring(0, idx);
93
- (0, system_1.debugPrint)('stripNLAndAfter(..), line: >>>' + line + '<<<');
94
- (0, system_1.debugPrint)('stripNLAndAfter(..), resultLine: >>>' + resultLine + '<<<');
93
+ (0, print_1.debugPrint)('stripNLAndAfter(..), line: >>>' + line + '<<<');
94
+ (0, print_1.debugPrint)('stripNLAndAfter(..), resultLine: >>>' + resultLine + '<<<');
95
95
  return resultLine;
96
96
  };
97
97
  exports.stripNLAndAfter = stripNLAndAfter;
@@ -5,8 +5,8 @@
5
5
  */
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
7
  exports.isValidBacktickedIdent = exports.isValidSimpleIdent = exports.stripCommentsAndAfter = exports.isMarkerCharacter = void 0;
8
+ const print_1 = require("./utils/print");
8
9
  const string_1 = require("./utils/string");
9
- const system_1 = require("./utils/system");
10
10
  const SECTION_MARKER1 = '^';
11
11
  const SECTION_MARKER2 = '<';
12
12
  const SECTION_MARKER3 = '\u00A7'; // Section sign §.
@@ -64,8 +64,8 @@ const stripCommentsAndAfter = (line) => {
64
64
  // debugPrint('stripCommentsAndAfter(..): idx5 = ' + idx5)
65
65
  const idx = Math.min(idx1, idx2, idx3, idx4, idx5);
66
66
  const resultLine = idx === Number.MAX_SAFE_INTEGER ? line : line.substring(0, idx);
67
- (0, system_1.debugPrint)('stripCommentsAndAfter(..), line: >>>' + line + '<<<');
68
- (0, system_1.debugPrint)('stripCommentsAndAfter(..), resultLine: >>>' + resultLine + '<<<');
67
+ (0, print_1.debugPrint)('stripCommentsAndAfter(..), line: >>>' + line + '<<<');
68
+ (0, print_1.debugPrint)('stripCommentsAndAfter(..), resultLine: >>>' + resultLine + '<<<');
69
69
  return resultLine;
70
70
  };
71
71
  exports.stripCommentsAndAfter = stripCommentsAndAfter;
@@ -0,0 +1,15 @@
1
+ // Parsed output from examples/basic.yini using YINI.parseFile(...)
2
+
3
+ // JS object
4
+ {
5
+ App: {
6
+ title: 'My App',
7
+ items: 10,
8
+ debug: true
9
+ },
10
+ Server: {
11
+ host: 'localhost',
12
+ port: 8080,
13
+ useTLS: false
14
+ }
15
+ }
@@ -0,0 +1,18 @@
1
+ // Parsed output in config from examples/nested.yini using YINI.parseFile(...)
2
+
3
+ config = {
4
+ App: {
5
+ name: 'Nested Demo App',
6
+ version: '1.2.3',
7
+ Theme: {
8
+ primaryColor: 3368601,
9
+ darkMode: true,
10
+ Overrides: { darkMode: false, fontSize: 14 },
11
+ },
12
+ },
13
+ Database: {
14
+ host: 'db.local',
15
+ port: 5432,
16
+ Credentials: { password: 'secret' },
17
+ },
18
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "yini-parser",
3
- "version": "1.0.0-alpha.7x",
3
+ "version": "1.0.1-beta",
4
4
  "description": "Simple and flexible config parser for Node.js. YINI: an enhanced, readable alternative to JSON, INI, and YAML—built for modern JavaScript and TypeScript projects.",
5
5
  "keywords": [
6
6
  "yini",
@@ -54,9 +54,13 @@
54
54
  "test:smoke": "cross-env NODE_ENV=test APP_ENV=local jest tests/smoke --bail --verbose --runInBand",
55
55
  "test:unit": "cross-env NODE_ENV=test APP_ENV=local jest tests/unit --bail --verbose --runInBand",
56
56
  "test:integr": "cross-env NODE_ENV=test APP_ENV=local jest tests/integration --bail --verbose --runInBand",
57
+ "test:issues": "cross-env NODE_ENV=test APP_ENV=local jest tests/fixed-issues --bail --verbose --runInBand",
58
+ "test:gold": "cross-env NODE_ENV=test APP_ENV=local jest tests/golden --bail --verbose --runInBand",
57
59
  "test:smoke:debug": "cross-env npm run test:smoke -- --isDebug=1",
58
60
  "test:unit:debug": "cross-env npm run test:unit -- --isDebug=1",
59
61
  "test:integr:debug": "cross-env npm run test:integr -- --isDebug=1",
62
+ "test:issues:debug": "cross-env npm run test:issues -- --isDebug=1",
63
+ "test:gold:debug": "cross-env npm run test:gold -- --isDebug=1",
60
64
  "test:esm": "node ./tests/fixtures/test-src-files/esm-smoke.js",
61
65
  "ci:test": "cross-env NODE_ENV=test APP_ENV=ci jest --verbose --runInBand",
62
66
  "ci:test:smoke": "cross-env NODE_ENV=test APP_ENV=ci jest tests/smoke --verbose --runInBand",
File without changes
File without changes