jexp 0.0.11 → 0.1.2

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
@@ -1,7 +1,583 @@
1
1
  # JEXP
2
2
 
3
- Parser and evaluator of expressions by line of commands. The expressions correspond to the package js-expressions
3
+ Command line application that allows parser and evaluator of json/yaml applying expressions.
4
+
5
+ ## Features
6
+
7
+ - Functions and arrow functions
8
+ - Constants, enums, variables, objects and arrays
9
+ - Arithmetic, assignment, comparison, Logical and bitwise operators
10
+ - Environment variables
11
+
12
+ ## Global installation
13
+
14
+ it is necessary to install the package globally to be able to access the command line applications.
15
+
16
+ ```sh
17
+ npm install jexp -g
18
+ ```
19
+
20
+ ## Usage
21
+
22
+ ```sh
23
+ jexp <expression> <source> [options]
24
+ ```
25
+
26
+ ### Expression
27
+
28
+ The expressions correspond to the package [js-expressions](https://www.npmjs.com/package/js-expressions)
29
+
30
+ expression that is applied to the data source
31
+
32
+ the root of the data is accessed from **dot**
33
+
34
+ ```sh
35
+ jexp '.' ./data/orders.json
36
+ ```
37
+
38
+ From the **dot** we write the expressions
39
+
40
+ ```sh
41
+ jexp '.details.article' ./data/orders.json
42
+ ```
43
+
44
+ ```sh
45
+ jexp '.details.first(p=> p.unitPrice * p.qty < 3 )' ./data/orders.json
46
+ ```
47
+
48
+ ### Source
49
+
50
+ Get data source from json file
51
+
52
+ ```sh
53
+ jexp '.[0].details' ./data/orders.json
54
+ ```
55
+
56
+ Get data source from yaml file
57
+
58
+ ```sh
59
+ jexp '.min(p=> p.total)' ./data/orders.yaml
60
+ ```
61
+
62
+ Get data source from json stringify
63
+
64
+ ```sh
65
+ jexp 'concatenate(capitalize(.fruit.name)," ",.fruit.color)' '{"fruit":{"name":"apple","color":"green","price":1.20}}'
66
+ ```
67
+
68
+ Get data source from pipeline command
4
69
 
5
70
  ```sh
6
71
  curl -s https://raw.githubusercontent.com/FlavioLionelRita/jexp/main/data/orders.json | jexp '.number'
7
72
  ```
73
+
74
+ ### Options
75
+
76
+ | Option | Abbreviation | Description | Options |
77
+ |-------------------|--------------|----------------|-----------|
78
+ |--output <format> |-o |Force output | json, yaml|
79
+ |--beautiful |-b |Beautiful output| |
80
+ |--decorate |-d |Decorate output | |
81
+
82
+ ## Examples
83
+
84
+ file orders.js
85
+
86
+ ```json
87
+ [
88
+ {
89
+ "number": "20001",
90
+ "customer": { "firstName": "John", "lastName": "Murphy" },
91
+ "orderTime": "2022-07-30T10:15:54",
92
+ "details": [
93
+ { "article": "Pear", "unitPrice": 1.78, "qty": 2 },
94
+ { "article": "Banana", "unitPrice": 1.99, "qty": 1 },
95
+ { "article": "White grape", "unitPrice": 2.03, "qty": 1 }
96
+ ]
97
+ },
98
+ {
99
+ "number": "20002",
100
+ "customer": { "firstName": "Paul", "lastName": "Smith" },
101
+ "orderTime": "2022-07-30T12:12:43",
102
+ "details": [
103
+ { "article": "Apple", "unitPrice": 2.15, "qty": 1 },
104
+ { "article": "Banana", "unitPrice": 1.99, "qty": 2 },
105
+ { "article": "Pear", "unitPrice": 1.78, "qty": 1 }
106
+ ]
107
+ }
108
+ ]
109
+ ```
110
+
111
+ Return the entire content of the file
112
+
113
+ ```sh
114
+ jexp '.' ./data/orders.json
115
+ ```
116
+
117
+ Result:
118
+
119
+ ```json
120
+ [{"number":"20001","customer":{"firstName":"John","lastName":"Murphy"},"orderTime":"2022-07-30T10:15:54","details":[{"article":"Pear","unitPrice":1.78,"qty":2},{"article":"Banana","unitPrice":1.99,"qty":1},{"article":"White grape","unitPrice":2.03,"qty":1}]},{"number":"20002","customer":{"firstName":"Paul","lastName":"Smith"},"orderTime":"2022-07-30T12:12:43","details":[{"article":"Apple","unitPrice":2.15,"qty":1},{"article":"Banana","unitPrice":1.99,"qty":2},{"article":"Pear","unitPrice":1.78,"qty":1}]}]
121
+ ```
122
+
123
+ Returns the number property of the list
124
+
125
+ ```sh
126
+ jexp '.number' ./data/orders.json
127
+ ```
128
+
129
+ Result:
130
+
131
+ ```json
132
+ ["20001","20002"]
133
+ ```
134
+
135
+ Concatenates two properties and capitalizes the first one
136
+
137
+ ```sh
138
+ jexp 'concatenate(capitalize(.fruit.name)," ",.fruit.color)' '{"fruit":{"name":"apple","color":"green","price":1.20}}'
139
+ ```
140
+
141
+ Result:
142
+
143
+ ```json
144
+ "Apple green"
145
+ ```
146
+
147
+ Returns the first element of an array from the index in yaml format
148
+
149
+ ```sh
150
+ jexp '.[0]' ./data/orders.json -o yaml
151
+ ```
152
+
153
+ Result:
154
+
155
+ ```json
156
+ number: '20001'
157
+ customer:
158
+ firstName: John
159
+ lastName: Murphy
160
+ orderTime: '2022-07-30T10:15:54'
161
+ details:
162
+ - article: Pear
163
+ unitPrice: 1.78
164
+ qty: 2
165
+ - article: Banana
166
+ unitPrice: 1.99
167
+ qty: 1
168
+ - article: White grape
169
+ unitPrice: 2.03
170
+ qty: 1
171
+
172
+ ```
173
+
174
+ Returns the details property of the first element in beautiful format
175
+
176
+ ```sh
177
+ jexp '.[0].details' ./data/orders.json -b
178
+ ```
179
+
180
+ Result:
181
+
182
+ ```json
183
+ [
184
+ {
185
+ "article": "Pear",
186
+ "unitPrice": 1.78,
187
+ "qty": 2
188
+ },
189
+ {
190
+ "article": "Banana",
191
+ "unitPrice": 1.99,
192
+ "qty": 1
193
+ },
194
+ {
195
+ "article": "White grape",
196
+ "unitPrice": 2.03,
197
+ "qty": 1
198
+ }
199
+ ]
200
+ ```
201
+
202
+ Returns the details property of the listing
203
+
204
+ ```sh
205
+ jexp '.details' ./data/orders.json
206
+ ```
207
+
208
+ Result:
209
+
210
+ ```json
211
+ [{"article":"Pear","unitPrice":1.78,"qty":2},{"article":"Banana","unitPrice":1.99,"qty":1},{"article":"White grape","unitPrice":2.03,"qty":1},{"article":"Apple","unitPrice":2.15,"qty":1},{"article":"Banana","unitPrice":1.99,"qty":2},{"article":"Pear","unitPrice":1.78,"qty":1}]
212
+ ```
213
+
214
+ Returns the article property of the list of details of each element of the list
215
+
216
+ ```sh
217
+ jexp '.details.article' ./data/orders.json
218
+ ```
219
+
220
+ Result:
221
+
222
+ ```json
223
+ ["Pear","Banana","White grape","Apple","Banana","Pear"]
224
+ ```
225
+
226
+ Get the minimum of the total property
227
+
228
+ ```sh
229
+ jexp '.min(p=> p.total)' ./data/orders.json
230
+ ```
231
+
232
+ Result:
233
+
234
+ ```json
235
+ null
236
+ ```
237
+
238
+ Get the minimum of the article property from all the details
239
+
240
+ ```sh
241
+ jexp '.details.min(p=> p.article )' ./data/orders.json
242
+ ```
243
+
244
+ Result:
245
+
246
+ ```json
247
+ "Apple"
248
+ ```
249
+
250
+ Get the maximum "unitPrice * p.qty" from all the details
251
+
252
+ ```sh
253
+ jexp '.details.max(p=> p.unitPrice * p.qty )' ./data/orders.json
254
+ ```
255
+
256
+ Result:
257
+
258
+ ```json
259
+ 3.98
260
+ ```
261
+
262
+ Get the middle value "unitPrice * p.qty" from all the details
263
+
264
+ ```sh
265
+ jexp '.details.avg(p=> p.unitPrice * p.qty )' ./data/orders.json
266
+ ```
267
+
268
+ Result:
269
+
270
+ ```json
271
+ 2.5816666666666666
272
+ ```
273
+
274
+ Gets the sum of the total property
275
+
276
+ ```sh
277
+ jexp '.sum(p=> p.total )' ./data/orders.json
278
+ ```
279
+
280
+ Result:
281
+
282
+ ```json
283
+ 0
284
+ ```
285
+
286
+ Get the sum "unitPrice * p.qty" of the details of item 1 of the list
287
+
288
+ ```sh
289
+ jexp '.[1].details.sum(p=> p.unitPrice * p.qty )' ./data/orders.json
290
+ ```
291
+
292
+ Result:
293
+
294
+ ```json
295
+ 7.91
296
+ ```
297
+
298
+ Get the number of details where "unitPrice * p.qty " is less than 3
299
+
300
+ ```sh
301
+ jexp '.details.count(p=> p.unitPrice * p.qty < 3 )' ./data/orders.json
302
+ ```
303
+
304
+ Result:
305
+
306
+ ```json
307
+ 4
308
+ ```
309
+
310
+ Get the first article property of all details where "unitPrice * p.qty" is less than 3
311
+
312
+ ```sh
313
+ jexp '.details.first(p=> p.unitPrice * p.qty < 3 ).article' ./data/orders.json
314
+ ```
315
+
316
+ Result:
317
+
318
+ ```json
319
+ "Banana"
320
+ ```
321
+
322
+ Get the last article property of all details where "unitPrice * p.qty" is less than 3
323
+
324
+ ```sh
325
+ jexp '.details.last(p=> p.unitPrice * p.qty < 3 ).article' ./data/orders.json
326
+ ```
327
+
328
+ Result:
329
+
330
+ ```json
331
+ "Pear"
332
+ ```
333
+
334
+ Get the first detail where "unitPrice * p.qty" is less than 3 in beautiful format
335
+
336
+ ```sh
337
+ jexp '.details.first(p=> p.unitPrice * p.qty < 3 )' ./data/orders.json -b
338
+ ```
339
+
340
+ Result:
341
+
342
+ ```json
343
+ {
344
+ "article": "Banana",
345
+ "unitPrice": 1.99,
346
+ "qty": 1
347
+ }
348
+ ```
349
+
350
+ Get the sum "unitPrice * p.qty" of the details of item 1 of the list using pipeline
351
+
352
+ ```sh
353
+ curl -s https://raw.githubusercontent.com/FlavioLionelRita/jexp/main/data/orders.json | jexp '.details.sum(p=> p.unitPrice * p.qty )'
354
+ ```
355
+
356
+ Result:
357
+
358
+ ```json
359
+ 20.1
360
+ ```
361
+
362
+ Get the smallest article
363
+
364
+ ```sh
365
+ jexp '.details.min(p=> p.article )' ./data/orders.json
366
+ ```
367
+
368
+ Result:
369
+
370
+ ```json
371
+ "Apple"
372
+ ```
373
+
374
+ Get the total of all the details
375
+
376
+ ```sh
377
+ jexp '.details.max(p=> p.unitPrice * p.qty )' ./data/orders.json
378
+ ```
379
+
380
+ Result:
381
+
382
+ ```json
383
+ 3.98
384
+ ```
385
+
386
+ Get the mean value of all details
387
+
388
+ ```sh
389
+ jexp '.details.avg(p=> p.unitPrice * p.qty )' ./data/orders.json
390
+ ```
391
+
392
+ Result:
393
+
394
+ ```json
395
+ 2.5816666666666666
396
+ ```
397
+
398
+ Get the total of the details of order 1
399
+
400
+ ```sh
401
+ jexp '[1].details.sum(p=> p.unitPrice * p.qty )' ./data/orders.json
402
+ ```
403
+
404
+ Result:
405
+
406
+ ```json
407
+ 0
408
+ ```
409
+
410
+ Gets the number of details where the subtotal is less than 3
411
+
412
+ ```sh
413
+ jexp '.details.count(p=> p.unitPrice * p.qty < 3 )' ./data/orders.json
414
+ ```
415
+
416
+ Result:
417
+
418
+ ```json
419
+ 4
420
+ ```
421
+
422
+ Get the article of the first detail where the subtotal is less than 3
423
+
424
+ ```sh
425
+ jexp '.details.first(p=> p.unitPrice * p.qty < 3 ).article' ./data/orders.json
426
+ ```
427
+
428
+ Result:
429
+
430
+ ```json
431
+ "Banana"
432
+ ```
433
+
434
+ Get the article of the last detail where the subtotal is less than 3
435
+
436
+ ```sh
437
+ jexp '.details.last(p=> p.unitPrice * p.qty < 3 ).article
438
+ ```
439
+
440
+ Result:
441
+
442
+ ```json
443
+ /bin/sh: 1: Syntax error: Unterminated quoted string
444
+ ```
445
+
446
+ Get the first detail where the subtotal is less than 3
447
+
448
+ ```sh
449
+ jexp '.details.first(p=> p.unitPrice * p.qty < 3 )' ./data/orders.json
450
+ ```
451
+
452
+ Result:
453
+
454
+ ```json
455
+ {"article":"Banana","unitPrice":1.99,"qty":1}
456
+ ```
457
+
458
+ Calculate the total for each order
459
+
460
+ ```sh
461
+ jexp '.each(p=>p.total=p.details.sum(q=>q.qty*q.unitPrice)).map(p=>{nro:p.number,total:p.total})' ./data/orders.json
462
+ ```
463
+
464
+ Result:
465
+
466
+ ```json
467
+ [{"nro":"20001","total":7.58},{"nro":"20002","total":7.91}]
468
+ ```
469
+
470
+ Calculate the subtotal for each order
471
+
472
+ ```sh
473
+ jexp '.details.foreach(p=>p.subtotal=p.qty*p.unitPrice).subtotal' ./data/orders.json
474
+ ```
475
+
476
+ Result:
477
+
478
+ ```json
479
+ [3.56,1.99,2.03,2.15,3.98,1.78]
480
+ ```
481
+
482
+ calculates the total of all the details
483
+
484
+ ```sh
485
+ jexp '.details.foreach(p=>total=nvl(total,0)+p.qty*p.unitPrice);total' ./data/orders.json
486
+ ```
487
+
488
+ Result:
489
+
490
+ ```json
491
+ 15.49
492
+ ```
493
+
494
+ Get the list of items without repeating
495
+
496
+ ```sh
497
+ jexp '.details.distinct(p=>p.article)' ./data/orders.json
498
+ ```
499
+
500
+ Result:
501
+
502
+ ```json
503
+ ["Pear","Banana","White grape","Apple"]
504
+ ```
505
+
506
+ Get the list of items and quantity without repeating
507
+
508
+ ```sh
509
+ jexp '.details.distinct(p=>{article:p.article,qty:p.qty})' ./data/orders.json
510
+ ```
511
+
512
+ Result:
513
+
514
+ ```json
515
+ [{"article":"Pear","qty":2},{"article":"Banana","qty":1},{"article":"White grape","qty":1},{"article":"Apple","qty":1},{"article":"Banana","qty":2},{"article":"Pear","qty":1}]
516
+ ```
517
+
518
+
519
+
520
+ ```sh
521
+ jexp '.details.map(p=>{article:p.article,count:count(1),total:sum(p.qty * p.unitPrice)})' ./data/orders.json
522
+ ```
523
+
524
+ Result:
525
+
526
+ ```json
527
+ [{"article":"Pear","count":2,"total":5.34},{"article":"Banana","count":2,"total":5.97},{"article":"White grape","count":1,"total":2.03},{"article":"Apple","count":1,"total":2.15}]
528
+ ```
529
+
530
+ Get the total of the first order
531
+
532
+ ```sh
533
+ jexp '{total:.[0].details.sum(p=>p.qty * p.unitPrice)}' ./data/orders.json
534
+ ```
535
+
536
+ Result:
537
+
538
+ ```json
539
+ {"total":7.58}
540
+ ```
541
+
542
+ Get the total of the last order
543
+
544
+ ```sh
545
+ jexp '{total:.[.length()-1].details.sum(p=>p.qty * p.unitPrice)}' ./data/orders.json
546
+ ```
547
+
548
+ Result:
549
+
550
+ ```json
551
+ {"total":7.91}
552
+ ```
553
+
554
+ List the orders with their totals
555
+
556
+ ```sh
557
+ jexp '.map(p=>{nro:p.number,total:p.details.sum(q=>q.qty * q.unitPrice)})' ./data/orders.json
558
+ ```
559
+
560
+ Result:
561
+
562
+ ```json
563
+ [{"nro":"20001","total":7.58},{"nro":"20002","total":7.91}]
564
+ ```
565
+
566
+ ## js-expression
567
+
568
+ [Js-expression](https://www.npmjs.com/package/js-expressions) is an extensible expression evaluator and parser. \
569
+ Besides the operators, functions, variables, objects and arrays that are supported
570
+
571
+ ### Documentation
572
+
573
+ - [Array](https://github.com/FlavioLionelRita/js-expressions/wiki/Array)
574
+ - [Assignment](https://github.com/FlavioLionelRita/js-expressions/wiki/Assignment)
575
+ - [Bitwise](https://github.com/FlavioLionelRita/js-expressions/wiki/Bitwise)
576
+ - [Comparison](https://github.com/FlavioLionelRita/js-expressions/wiki/Comparison)
577
+ - [Control flows](https://github.com/FlavioLionelRita/js-expressions/wiki/Flows)
578
+ - [Datetime](https://github.com/FlavioLionelRita/js-expressions/wiki/Datetime)
579
+ - [Extend](https://github.com/FlavioLionelRita/js-expressions/wiki/Extend)
580
+ - [Logical](https://github.com/FlavioLionelRita/js-expressions/wiki/Logical)
581
+ - [Nullable](https://github.com/FlavioLionelRita/js-expressions/wiki/Nullable)
582
+ - [Numeric](https://github.com/FlavioLionelRita/js-expressions/wiki/Numeric)
583
+ - [String](https://github.com/FlavioLionelRita/js-expressions/wiki/String)
package/index.js CHANGED
@@ -18,50 +18,45 @@ const path_1 = __importDefault(require("path"));
18
18
  const { program, Option } = require('commander');
19
19
  const colorize = require('json-colorizer');
20
20
  const yaml = require('js-yaml');
21
- const run = (query, source, options) => __awaiter(void 0, void 0, void 0, function* () {
22
- try {
23
- let data = {};
24
- let extension = '';
25
- if ((source.startsWith('[') || source.startsWith('{'))) {
26
- data = js_expressions_1.Helper.tryParse(source);
27
- }
28
- else {
29
- extension = path_1.default.extname(source);
30
- if (!['.json', '.yaml', 'yml'].includes(extension)) {
31
- throw Error(`extension ${extension} not supported `);
32
- }
33
- const content = yield js_expressions_1.Helper.readFile(source);
34
- if (!content) {
35
- throw Error(`can not read file ${source}`);
36
- }
37
- if (extension === 'json') {
38
- data = js_expressions_1.Helper.tryParse(content);
39
- }
40
- else {
41
- data = yaml.load(content);
42
- }
21
+ const run = (expression, source, options) => __awaiter(void 0, void 0, void 0, function* () {
22
+ let data = {};
23
+ let extension = '';
24
+ if ((source.startsWith('[') || source.startsWith('{'))) {
25
+ data = js_expressions_1.Helper.tryParse(source);
26
+ }
27
+ else {
28
+ extension = path_1.default.extname(source);
29
+ if (!['.json', '.yaml', 'yml'].includes(extension)) {
30
+ throw Error(`extension ${extension} not supported `);
43
31
  }
44
- if (data === null || data === undefined) {
45
- throw Error(`can not parse content of ${source}`);
32
+ const content = yield js_expressions_1.Helper.readFile(source);
33
+ if (!content) {
34
+ throw Error(`can not read file ${source}`);
46
35
  }
47
- const result = js_expressions_1.expressions.eval(query, { '.': data });
48
- const forceJson = options.output === 'json';
49
- const forceYaml = options.output === 'yaml';
50
- if (forceYaml || (!forceJson && extension && ['.yaml', 'yml'].includes(extension))) {
51
- console.log(yaml.dump(result));
36
+ if (extension === 'json') {
37
+ data = js_expressions_1.Helper.tryParse(content);
52
38
  }
53
39
  else {
54
- const formatted = options.beautiful ? JSON.stringify(result, null, 2) : JSON.stringify(result);
55
- if (options.decorate) {
56
- console.log(colorize(formatted));
57
- }
58
- else {
59
- console.log(formatted);
60
- }
40
+ data = yaml.load(content);
61
41
  }
62
42
  }
63
- catch (error) {
64
- console.error(error.stack);
43
+ if (data === null || data === undefined) {
44
+ throw Error(`can not parse content of ${source}`);
45
+ }
46
+ const result = js_expressions_1.expressions.eval(expression, { '.': data });
47
+ const forceJson = options.output === 'json';
48
+ const forceYaml = options.output === 'yaml';
49
+ if (forceYaml || (!forceJson && extension && ['.yaml', 'yml'].includes(extension))) {
50
+ console.log(yaml.dump(result));
51
+ }
52
+ else {
53
+ const formatted = options.beautiful ? JSON.stringify(result, null, 2) : JSON.stringify(result);
54
+ if (options.decorate) {
55
+ console.log(colorize(formatted));
56
+ }
57
+ else {
58
+ console.log(formatted);
59
+ }
65
60
  }
66
61
  });
67
62
  const getInput = () => __awaiter(void 0, void 0, void 0, function* () {
@@ -82,15 +77,20 @@ const getInput = () => __awaiter(void 0, void 0, void 0, function* () {
82
77
  function main() {
83
78
  return __awaiter(this, void 0, void 0, function* () {
84
79
  program
85
- .argument('<query>')
80
+ .argument('<expression>')
86
81
  .argument('[source]')
87
82
  .addOption(new Option('-o, --output <format>', 'Force output').choices(['json', 'yaml']))
88
83
  .option('-b, --beautiful', 'Beautiful output', false)
89
84
  .option('-d, --decorate', 'Decorate output', false)
90
85
  .option('-q, --query-file <path>', 'query file')
91
- .action((query, source, options) => __awaiter(this, void 0, void 0, function* () {
92
- const data = (source !== undefined) ? source : yield getInput();
93
- yield run(query, data, options);
86
+ .action((expression, source, options) => __awaiter(this, void 0, void 0, function* () {
87
+ try {
88
+ const data = (source !== undefined) ? source : yield getInput();
89
+ yield run(expression, data, options);
90
+ }
91
+ catch (error) {
92
+ console.error(error.message);
93
+ }
94
94
  }));
95
95
  yield program.parseAsync(process.argv);
96
96
  });
package/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/lib/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AACA,mDAA2D;AAC3D,gDAAuB;AACvB,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,WAAW,CAAC,CAAA;AAChD,MAAM,QAAQ,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAA;AAC1C,MAAM,IAAI,GAAG,OAAO,CAAC,SAAS,CAAC,CAAA;AAE/B,MAAM,GAAG,GAAG,CAAO,KAAY,EAAE,MAAa,EAAE,OAAW,EAAE,EAAE;IAC9D,IAAI;QACH,IAAI,IAAI,GAAO,EAAE,CAAA;QACjB,IAAI,SAAS,GAAG,EAAE,CAAA;QAClB,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,MAAM,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,EAAE;YACvD,IAAI,GAAG,uBAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAA;SAC9B;aAAM;YACN,SAAS,GAAG,cAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAA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EAAS,CAAA;gBACtE,MAAM,GAAG,CAAC,UAAU,EAAE,IAAI,EAAE,OAAO,CAAC,CAAA;aACpC;YAAC,OAAO,KAAS,EAAE;gBACnB,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,CAAA;aAC5B;QACF,CAAC,CAAA,CAAC,CAAA;QACH,MAAM,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;IACvC,CAAC;CAAA;AACD,IAAI,EAAE,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jexp",
3
- "version": "0.0.11",
3
+ "version": "0.1.2",
4
4
  "description": "Parser and evaluator of expressions by line of commands. The expressions correspond to the package js-expressions",
5
5
  "author": "Flavio Lionel Rita <flaviolrita@hotmail.com>",
6
6
  "license": "Apache-2.0 License",
@@ -18,7 +18,7 @@
18
18
  },
19
19
  "dependencies": {
20
20
  "commander": "^9.4.0",
21
- "js-expressions": "1.0.9",
21
+ "js-expressions": "1.0.11",
22
22
  "js-yaml": "^4.1.0",
23
23
  "json-colorizer": "^2.2.2"
24
24
  },