starlight-cli 1.1.14 → 1.1.15

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/dist/index.js CHANGED
@@ -10433,7 +10433,24 @@ this.global.define('random', (min, max) => {
10433
10433
  if (isNaN(min) || isNaN(max)) return 0;
10434
10434
  return Math.floor(Math.random() * (max - min)) + min;
10435
10435
  });
10436
+ this.global.define('JSONParse', arg => {
10437
+ if (typeof arg !== 'string') {
10438
+ throw new RuntimeError('JSONParse expects a string', null, evaluator.source);
10439
+ }
10440
+ try {
10441
+ return JSON.parse(arg);
10442
+ } catch (e) {
10443
+ throw new RuntimeError('Invalid JSON string: ' + e.message, null, evaluator.source);
10444
+ }
10445
+ });
10436
10446
 
10447
+ this.global.define('JSONStringify', arg => {
10448
+ try {
10449
+ return JSON.stringify(arg);
10450
+ } catch (e) {
10451
+ throw new RuntimeError('Cannot stringify value: ' + e.message, null, evaluator.source);
10452
+ }
10453
+ });
10437
10454
  this.global.define('map', async (array, fn) => {
10438
10455
  if (!Array.isArray(array)) {
10439
10456
  throw new RuntimeError('map() expects an array', null, evaluator.source);
@@ -13734,7 +13751,7 @@ const Lexer = __nccwpck_require__(211);
13734
13751
  const Parser = __nccwpck_require__(222);
13735
13752
  const Evaluator = __nccwpck_require__(112);
13736
13753
 
13737
- const VERSION = '1.1.14';
13754
+ const VERSION = '1.1.15';
13738
13755
 
13739
13756
  const COLOR = {
13740
13757
  reset: '\x1b[0m',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "starlight-cli",
3
- "version": "1.1.14",
3
+ "version": "1.1.15",
4
4
  "description": "Starlight Programming Language CLI",
5
5
  "bin": {
6
6
  "starlight": "index.js"
package/src/evaluator.js CHANGED
@@ -223,7 +223,24 @@ this.global.define('random', (min, max) => {
223
223
  if (isNaN(min) || isNaN(max)) return 0;
224
224
  return Math.floor(Math.random() * (max - min)) + min;
225
225
  });
226
+ this.global.define('JSONParse', arg => {
227
+ if (typeof arg !== 'string') {
228
+ throw new RuntimeError('JSONParse expects a string', null, evaluator.source);
229
+ }
230
+ try {
231
+ return JSON.parse(arg);
232
+ } catch (e) {
233
+ throw new RuntimeError('Invalid JSON string: ' + e.message, null, evaluator.source);
234
+ }
235
+ });
226
236
 
237
+ this.global.define('JSONStringify', arg => {
238
+ try {
239
+ return JSON.stringify(arg);
240
+ } catch (e) {
241
+ throw new RuntimeError('Cannot stringify value: ' + e.message, null, evaluator.source);
242
+ }
243
+ });
227
244
  this.global.define('map', async (array, fn) => {
228
245
  if (!Array.isArray(array)) {
229
246
  throw new RuntimeError('map() expects an array', null, evaluator.source);
package/src/starlight.js CHANGED
@@ -12,7 +12,7 @@ const Lexer = require('./lexer');
12
12
  const Parser = require('./parser');
13
13
  const Evaluator = require('./evaluator');
14
14
 
15
- const VERSION = '1.1.14';
15
+ const VERSION = '1.1.15';
16
16
 
17
17
  const COLOR = {
18
18
  reset: '\x1b[0m',