yini-parser 1.0.0-alpha.3 → 1.0.0-alpha.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.
package/README.md CHANGED
@@ -13,6 +13,13 @@ YINI is a simple, human-friendly configuration format inspired by INI and JSON.
13
13
 
14
14
  ---
15
15
 
16
+ ## 💡 Why YINI?
17
+ - Easy to read and write — minimal syntax, maximum clarity.
18
+ - Supports nested sections, strict/lenient modes, and all major data types.
19
+ - A perfect alternative to messy JSON, legacy INI, or complex YAML.
20
+ - Built for both JavaScript and TypeScript.
21
+ - Human-friendly, machine-friendly, and ready for modern projects.
22
+
16
23
  ## ✨ Features
17
24
  - Simple syntax (supports both strict and lenient modes).
18
25
  - Familiar config file style (inspired by INI, YAML, TOML).
@@ -47,21 +54,35 @@ pnpm add yini-parser
47
54
 
48
55
  ## Usage
49
56
 
50
- > Only import the main class:
51
- >
52
- > ```ts
53
- > import YINI from 'yini-parser';
54
- > ```
57
+ ### Node.js (CommonJS)
58
+ **Note:** Only a default export (YINI) is provided. Named imports are not supported.
59
+ ```js
60
+ const YINI = require('yini-parser');
61
+ // If you get undefined, try:
62
+ const YINI = require('yini-parser').default;
63
+
64
+ // Parse from string.
65
+ const config = YINI.parse(`
66
+ ^ App
67
+ title = 'My App Title'
68
+ items = 25
69
+ isDarkTheme = true
70
+ `);
71
+
72
+ // Parse from file.
73
+ const configFromFile = YINI.parseFile('./config.yini');
74
+ ```
55
75
 
56
- ### Example:
76
+ ### TypeScript (with `"esModuleInterop": true`)
57
77
  ```ts
58
78
  import YINI from 'yini-parser';
59
79
 
60
80
  // Parse from string.
61
81
  const config = YINI.parse(`
62
- ^ Database
63
- host = localhost
64
- port = 5432
82
+ ^ App
83
+ title = "My App Title"
84
+ items = 25
85
+ isDarkTheme = OFF
65
86
  `);
66
87
 
67
88
  // Parse from file.
@@ -105,13 +126,87 @@ Returns a JavaScript object representing the parsed YINI configuration file.
105
126
  ## Example Output
106
127
  ```js
107
128
  {
108
- Database: {
109
- host: "localhost",
110
- port: 5432
111
- }
129
+ App:{
130
+ title: "My App Title",
131
+ items: 25,
132
+ isDarkTheme: false
133
+ }
112
134
  }
113
135
  ```
114
136
 
137
+ ---
138
+ ---
139
+
140
+ ### Bigger Example
141
+
142
+ ```js
143
+ const YINI = require('yini-parser'); // Or: import YINI from 'yini-parser';
144
+
145
+ const config = YINI.parse(`
146
+ /*
147
+ This is a multi-line block comment.
148
+ */
149
+
150
+ @yini
151
+
152
+ ^ App
153
+ name = "Nested Example"
154
+ version = "1.0.0"
155
+ debug = OFF // This is a comment.
156
+
157
+ # Database settings.
158
+ ^^ Database
159
+ host = "db.example.com"
160
+ port = 3306
161
+ user = "appuser"
162
+ --password = "dbpassword" # Disabled line due to --.
163
+ //password = "dbpassword" # Not sure yet about this pw.
164
+ password = "dbpassword" # Keep this secret.
165
+
166
+ // Commenting with slashes works too.
167
+ ^^^ Pool
168
+ min = 2
169
+ max = 10
170
+ idleTimeout = 300
171
+
172
+ /* Block comment on a single line. */
173
+ ^^ Logging
174
+ level = "info"
175
+ logToFile = ON # This is a comment.
176
+ filePath = "./logs/app.log"
177
+
178
+ /END
179
+ `);
180
+
181
+ console.log(config);
182
+ ```
183
+
184
+ #### Output:
185
+ ```js
186
+ {
187
+ "App": {
188
+ "name": "Nested Example",
189
+ "version": "1.0.0",
190
+ "debug": false,
191
+ "Database": {
192
+ "host": "db.example.com",
193
+ "port": 3306,
194
+ "user": "appuser",
195
+ "password": "dbpassword",
196
+ "Pool": {
197
+ "min": 2,
198
+ "max": 10,
199
+ "idleTimeout": 300
200
+ }
201
+ },
202
+ "Logging": {
203
+ "level": "info",
204
+ "logToFile": true,
205
+ "filePath": "./logs/app.log"
206
+ }
207
+ }
208
+ }
209
+ ```
115
210
  ---
116
211
 
117
212
  ## 📚 Documentation
@@ -127,5 +222,4 @@ In this project on GitHub, the `libs` directory contains third party software an
127
222
 
128
223
  ---
129
224
 
130
- > ~ **YINI ≡**
131
- > [https://yini-lang.org](https://yini-lang.org)
225
+ ~ **YINI ≡** • [https://yini-lang.org](https://yini-lang.org)
@@ -4,4 +4,5 @@
4
4
  */
5
5
  export declare const debugPrint: (str?: any) => void;
6
6
  export declare const devPrint: (str?: any) => void;
7
+ export declare const toPrettyJSON: (obj: any) => string;
7
8
  export declare const printObject: (obj: any) => void;
@@ -4,7 +4,7 @@
4
4
  * @note More specific YINI helper functions should go into yiniHelpers.ts-file.
5
5
  */
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.printObject = exports.devPrint = exports.debugPrint = void 0;
7
+ exports.printObject = exports.toPrettyJSON = exports.devPrint = exports.debugPrint = void 0;
8
8
  const env_1 = require("../config/env");
9
9
  const debugPrint = (str = '') => {
10
10
  (0, env_1.isDebug)() && console.debug('DEBUG: ' + str);
@@ -14,10 +14,15 @@ const devPrint = (str = '') => {
14
14
  (0, env_1.isDev)() && !(0, env_1.isTestEnv)() && console.log('DEV: ' + str);
15
15
  };
16
16
  exports.devPrint = devPrint;
17
+ const toPrettyJSON = (obj) => {
18
+ const str = JSON.stringify(obj, null, 4);
19
+ return str;
20
+ };
21
+ exports.toPrettyJSON = toPrettyJSON;
17
22
  const printObject = (obj) => {
18
23
  if ((0, env_1.isProdEnv)() || ((0, env_1.isTestEnv)() && !(0, env_1.isDebug)()))
19
24
  return;
20
- const str = JSON.stringify(obj, null, 4);
25
+ const str = (0, exports.toPrettyJSON)(obj);
21
26
  console.log(str);
22
27
  };
23
28
  exports.printObject = printObject;
package/package.json CHANGED
@@ -1,16 +1,23 @@
1
1
  {
2
2
  "name": "yini-parser",
3
- "version": "1.0.0-alpha.3",
4
- "description": "YINI parser for JavaScript/TypeScript, an INI-inspired configuration format, meant to be readable, and easy to use.",
3
+ "version": "1.0.0-alpha.5",
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
- "read",
7
6
  "yini",
7
+ "yini-parser",
8
8
  "config",
9
+ "config-file",
10
+ "configuration",
11
+ "settings",
9
12
  "ini",
13
+ "ini-parser",
14
+ "json-alternative",
15
+ "yaml-alternative",
10
16
  "parser",
11
- "file",
12
17
  "parse",
13
- "configuration"
18
+ "read",
19
+ "nodejs",
20
+ "javascript"
14
21
  ],
15
22
  "homepage": "https://m4se.com/yini-lang.org/",
16
23
  "license": "Apache-2.0",
@@ -49,6 +56,7 @@
49
56
  "test:smoke:debug": "cross-env npm run test:smoke -- --isDebug=1",
50
57
  "test:unit:debug": "cross-env npm run test:unit -- --isDebug=1",
51
58
  "test:integr:debug": "cross-env npm run test:integr -- --isDebug=1",
59
+ "test:esm": "node ./tests/fixtures/test-src-files/esm-smoke.js",
52
60
  "ci:test": "cross-env NODE_ENV=test APP_ENV=ci jest --verbose --runInBand",
53
61
  "ci:test:smoke": "cross-env NODE_ENV=test APP_ENV=ci jest tests/smoke --verbose --runInBand",
54
62
  "tsc": "npx tsc -p ./tsconfig.json",