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

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,11 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const system_1 = require("../utils/system");
3
+ const print_1 = require("../utils/print");
4
4
  const parseNumberLiteral = (txt) => {
5
- (0, system_1.debugPrint)('-> Entered parseNumberLiteral(..), txt: ' + txt);
5
+ (0, print_1.debugPrint)('-> Entered parseNumberLiteral(..), txt: ' + txt);
6
6
  if (/^0[xX]|#/.test(txt)) {
7
7
  // Prefix: 0x, 0X, #
8
- (0, system_1.debugPrint)('* Identified as a hex number');
8
+ (0, print_1.debugPrint)('* Identified as a hex number');
9
9
  return {
10
10
  type: 'Number-Integer',
11
11
  // value: parseInt(txt.replace('#', '0x'), 16),
@@ -14,7 +14,7 @@ const parseNumberLiteral = (txt) => {
14
14
  }
15
15
  if (/^0[bB]|%/.test(txt)) {
16
16
  // Prefix: 0b, 0B, %
17
- (0, system_1.debugPrint)('* Identified as a bin number');
17
+ (0, print_1.debugPrint)('* Identified as a bin number');
18
18
  return {
19
19
  type: 'Number-Integer',
20
20
  value: parseInt(txt.replace(/^0[bB]|%/, ''), 2),
@@ -22,7 +22,7 @@ const parseNumberLiteral = (txt) => {
22
22
  }
23
23
  if (/^0[oO]/.test(txt)) {
24
24
  // Prefix: 0o, 0O
25
- (0, system_1.debugPrint)('* Identified as a ord number');
25
+ (0, print_1.debugPrint)('* Identified as a ord number');
26
26
  return {
27
27
  type: 'Number-Integer',
28
28
  value: parseInt(txt.replace(/^0[oO]/, ''), 8),
@@ -30,7 +30,7 @@ const parseNumberLiteral = (txt) => {
30
30
  }
31
31
  if (/^0[zZ]/.test(txt)) {
32
32
  // Prefix: 0z, 0Z
33
- (0, system_1.debugPrint)('* Identified as a duodecimal number');
33
+ (0, print_1.debugPrint)('* Identified as a duodecimal number');
34
34
  return {
35
35
  type: 'Number-Integer',
36
36
  value: parseInt(txt.replace(/^0[zZ]/, ''), 12),
@@ -38,12 +38,12 @@ const parseNumberLiteral = (txt) => {
38
38
  }
39
39
  // In a regex literal the dot must be escaped (\.) to match a literal '.'
40
40
  if (/\./.test(txt)) {
41
- (0, system_1.debugPrint)('* Identified as a float number');
41
+ (0, print_1.debugPrint)('* Identified as a float number');
42
42
  return { type: 'Number-Float', value: parseFloat(txt) };
43
43
  }
44
44
  // TODO: Depending, on mode, below continue or break on error
45
45
  //console.error('Error: Failed to parse number value: ' + txt)
46
- (0, system_1.debugPrint)('* Identified as a int number');
46
+ (0, print_1.debugPrint)('* Identified as a int number');
47
47
  return { type: 'Number-Integer', value: parseInt(txt) };
48
48
  };
49
49
  exports.default = parseNumberLiteral;
@@ -5,25 +5,25 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const extractHeaderParts_1 = __importDefault(require("../parsers/extractHeaderParts"));
7
7
  const extractSignificantYiniLine_1 = require("../parsers/extractSignificantYiniLine");
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 yiniHelpers_1 = require("../yiniHelpers");
11
11
  /**
12
12
  * Extract ...
13
13
  * @param rawLine Raw line with the section header.
14
14
  */
15
15
  const parseSectionHeader = (rawLine, errorHandler, ctx) => {
16
- (0, system_1.debugPrint)('-> Entered parseSectionHeader(..)');
16
+ (0, print_1.debugPrint)('-> Entered parseSectionHeader(..)');
17
17
  rawLine = rawLine.trim();
18
18
  const line = (0, extractSignificantYiniLine_1.extractYiniLine)(rawLine);
19
- (0, system_1.debugPrint)(' rawLine: >>>' + rawLine + '<<<');
20
- (0, system_1.debugPrint)('extractYiniLine(..), line: >>>' + line + '<<<');
19
+ (0, print_1.debugPrint)(' rawLine: >>>' + rawLine + '<<<');
20
+ (0, print_1.debugPrint)('extractYiniLine(..), line: >>>' + line + '<<<');
21
21
  let { strMarkerChars, strSectionName, strNumberPart, isBacktickedName } = (0, extractHeaderParts_1.default)(rawLine, errorHandler, ctx);
22
- (0, system_1.debugPrint)('In parseSectionHeader(..), after extractHeaderParts(..):');
23
- (0, system_1.debugPrint)(' strMarkerChars: ' + strMarkerChars);
24
- (0, system_1.debugPrint)(' strSectionName: ' + strSectionName);
25
- (0, system_1.debugPrint)(' strNumberPart: ' + strNumberPart);
26
- (0, system_1.debugPrint)('isBacktickedName: ' + isBacktickedName);
22
+ (0, print_1.debugPrint)('In parseSectionHeader(..), after extractHeaderParts(..):');
23
+ (0, print_1.debugPrint)(' strMarkerChars: ' + strMarkerChars);
24
+ (0, print_1.debugPrint)(' strSectionName: ' + strSectionName);
25
+ (0, print_1.debugPrint)(' strNumberPart: ' + strNumberPart);
26
+ (0, print_1.debugPrint)('isBacktickedName: ' + isBacktickedName);
27
27
  let headerMarkerType;
28
28
  let level = 0;
29
29
  if (strMarkerChars === '') {
@@ -76,7 +76,7 @@ const parseSectionHeader = (rawLine, errorHandler, ctx) => {
76
76
  }
77
77
  }
78
78
  else {
79
- (0, system_1.debugPrint)('Naming contraints: Is not a BacktickedName');
79
+ (0, print_1.debugPrint)('Naming contraints: Is not a BacktickedName');
80
80
  if (lenOfName <= 0) {
81
81
  errorHandler.pushOrBail(ctx, 'Syntax-Error', 'Invalid section name in repeating marker characters header, section name: "' +
82
82
  strSectionName +
@@ -93,15 +93,15 @@ const parseSectionHeader = (rawLine, errorHandler, ctx) => {
93
93
  }
94
94
  // ---------------------------------------------------------------
95
95
  // strSectionName = trimBackticks(strSectionName)
96
- (0, system_1.debugPrint)(' --------------');
97
- (0, system_1.debugPrint)('<- About to leave parseSectionHeader(..)');
98
- (0, system_1.debugPrint)(` rawLine = >>>${rawLine}<<<`);
99
- (0, system_1.debugPrint)(` line = >>>${line}<<<`);
100
- (0, system_1.debugPrint)();
101
- (0, system_1.debugPrint)('identified level: ' + level);
102
- (0, system_1.debugPrint)(' SectionName: ' + strSectionName);
103
- (0, system_1.debugPrint)('headerMarkerType: ' + headerMarkerType);
104
- (0, system_1.debugPrint)(' --------------');
96
+ (0, print_1.debugPrint)(' --------------');
97
+ (0, print_1.debugPrint)('<- About to leave parseSectionHeader(..)');
98
+ (0, print_1.debugPrint)(` rawLine = >>>${rawLine}<<<`);
99
+ (0, print_1.debugPrint)(` line = >>>${line}<<<`);
100
+ (0, print_1.debugPrint)();
101
+ (0, print_1.debugPrint)('identified level: ' + level);
102
+ (0, print_1.debugPrint)(' SectionName: ' + strSectionName);
103
+ (0, print_1.debugPrint)('headerMarkerType: ' + headerMarkerType);
104
+ (0, print_1.debugPrint)(' --------------');
105
105
  return {
106
106
  markerType: headerMarkerType,
107
107
  sectionName: strSectionName,
@@ -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.0-beta.1",
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",
File without changes
File without changes