jexp 0.1.2 → 0.1.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.
Files changed (2) hide show
  1. package/README.md +44 -14
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -4,10 +4,12 @@ Command line application that allows parser and evaluator of json/yaml applying
4
4
 
5
5
  ## Features
6
6
 
7
- - Functions and arrow functions
8
7
  - Constants, enums, variables, objects and arrays
9
8
  - Arithmetic, assignment, comparison, Logical and bitwise operators
9
+ - Functions and arrow functions
10
+ - distinct and group by
10
11
  - Environment variables
12
+ - json and yaml
11
13
 
12
14
  ## Global installation
13
15
 
@@ -152,7 +154,7 @@ jexp '.[0]' ./data/orders.json -o yaml
152
154
 
153
155
  Result:
154
156
 
155
- ```json
157
+ ```yaml
156
158
  number: '20001'
157
159
  customer:
158
160
  firstName: John
@@ -356,7 +358,7 @@ curl -s https://raw.githubusercontent.com/FlavioLionelRita/jexp/main/data/orders
356
358
  Result:
357
359
 
358
360
  ```json
359
- 20.1
361
+ 15.49
360
362
  ```
361
363
 
362
364
  Get the smallest article
@@ -398,13 +400,13 @@ Result:
398
400
  Get the total of the details of order 1
399
401
 
400
402
  ```sh
401
- jexp '[1].details.sum(p=> p.unitPrice * p.qty )' ./data/orders.json
403
+ jexp '.[1].details.sum(p=> p.unitPrice * p.qty )' ./data/orders.json
402
404
  ```
403
405
 
404
406
  Result:
405
407
 
406
408
  ```json
407
- 0
409
+ 7.91
408
410
  ```
409
411
 
410
412
  Gets the number of details where the subtotal is less than 3
@@ -434,13 +436,13 @@ Result:
434
436
  Get the article of the last detail where the subtotal is less than 3
435
437
 
436
438
  ```sh
437
- jexp '.details.last(p=> p.unitPrice * p.qty < 3 ).article
439
+ jexp '.details.last(p=> p.unitPrice * p.qty < 3 ).article' ./data/orders.json
438
440
  ```
439
441
 
440
442
  Result:
441
443
 
442
444
  ```json
443
- /bin/sh: 1: Syntax error: Unterminated quoted string
445
+ "Pear"
444
446
  ```
445
447
 
446
448
  Get the first detail where the subtotal is less than 3
@@ -494,13 +496,18 @@ Result:
494
496
  Get the list of items without repeating
495
497
 
496
498
  ```sh
497
- jexp '.details.distinct(p=>p.article)' ./data/orders.json
499
+ jexp '.details.distinct(p=>p.article)' ./data/orders.json -b
498
500
  ```
499
501
 
500
502
  Result:
501
503
 
502
504
  ```json
503
- ["Pear","Banana","White grape","Apple"]
505
+ [
506
+ "Pear",
507
+ "Banana",
508
+ "White grape",
509
+ "Apple"
510
+ ]
504
511
  ```
505
512
 
506
513
  Get the list of items and quantity without repeating
@@ -515,16 +522,37 @@ Result:
515
522
  [{"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
523
  ```
517
524
 
518
-
525
+ Get the total and amount of each item
519
526
 
520
527
  ```sh
521
- jexp '.details.map(p=>{article:p.article,count:count(1),total:sum(p.qty * p.unitPrice)})' ./data/orders.json
528
+ jexp '.details.map(p=>{article:p.article,count:count(1),total:sum(p.qty * p.unitPrice)})' ./data/orders.json -b
522
529
  ```
523
530
 
524
531
  Result:
525
532
 
526
533
  ```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}]
534
+ [
535
+ {
536
+ "article": "Pear",
537
+ "count": 2,
538
+ "total": 5.34
539
+ },
540
+ {
541
+ "article": "Banana",
542
+ "count": 2,
543
+ "total": 5.97
544
+ },
545
+ {
546
+ "article": "White grape",
547
+ "count": 1,
548
+ "total": 2.03
549
+ },
550
+ {
551
+ "article": "Apple",
552
+ "count": 1,
553
+ "total": 2.15
554
+ }
555
+ ]
528
556
  ```
529
557
 
530
558
  Get the total of the first order
@@ -542,13 +570,15 @@ Result:
542
570
  Get the total of the last order
543
571
 
544
572
  ```sh
545
- jexp '{total:.[.length()-1].details.sum(p=>p.qty * p.unitPrice)}' ./data/orders.json
573
+ jexp '{total:.[.length()-1].details.sum(p=>p.qty * p.unitPrice)}' ./data/orders.json -b
546
574
  ```
547
575
 
548
576
  Result:
549
577
 
550
578
  ```json
551
- {"total":7.91}
579
+ {
580
+ "total": 7.91
581
+ }
552
582
  ```
553
583
 
554
584
  List the orders with their totals
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jexp",
3
- "version": "0.1.2",
3
+ "version": "0.1.5",
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",