jexp 0.1.4 → 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.
- package/README.md +41 -11
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -358,7 +358,7 @@ curl -s https://raw.githubusercontent.com/FlavioLionelRita/jexp/main/data/orders
|
|
|
358
358
|
Result:
|
|
359
359
|
|
|
360
360
|
```json
|
|
361
|
-
|
|
361
|
+
15.49
|
|
362
362
|
```
|
|
363
363
|
|
|
364
364
|
Get the smallest article
|
|
@@ -400,13 +400,13 @@ Result:
|
|
|
400
400
|
Get the total of the details of order 1
|
|
401
401
|
|
|
402
402
|
```sh
|
|
403
|
-
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
|
|
404
404
|
```
|
|
405
405
|
|
|
406
406
|
Result:
|
|
407
407
|
|
|
408
408
|
```json
|
|
409
|
-
|
|
409
|
+
7.91
|
|
410
410
|
```
|
|
411
411
|
|
|
412
412
|
Gets the number of details where the subtotal is less than 3
|
|
@@ -436,13 +436,13 @@ Result:
|
|
|
436
436
|
Get the article of the last detail where the subtotal is less than 3
|
|
437
437
|
|
|
438
438
|
```sh
|
|
439
|
-
jexp '.details.last(p=> p.unitPrice * p.qty < 3 ).article
|
|
439
|
+
jexp '.details.last(p=> p.unitPrice * p.qty < 3 ).article' ./data/orders.json
|
|
440
440
|
```
|
|
441
441
|
|
|
442
442
|
Result:
|
|
443
443
|
|
|
444
444
|
```json
|
|
445
|
-
|
|
445
|
+
"Pear"
|
|
446
446
|
```
|
|
447
447
|
|
|
448
448
|
Get the first detail where the subtotal is less than 3
|
|
@@ -496,13 +496,18 @@ Result:
|
|
|
496
496
|
Get the list of items without repeating
|
|
497
497
|
|
|
498
498
|
```sh
|
|
499
|
-
jexp '.details.distinct(p=>p.article)' ./data/orders.json
|
|
499
|
+
jexp '.details.distinct(p=>p.article)' ./data/orders.json -b
|
|
500
500
|
```
|
|
501
501
|
|
|
502
502
|
Result:
|
|
503
503
|
|
|
504
504
|
```json
|
|
505
|
-
[
|
|
505
|
+
[
|
|
506
|
+
"Pear",
|
|
507
|
+
"Banana",
|
|
508
|
+
"White grape",
|
|
509
|
+
"Apple"
|
|
510
|
+
]
|
|
506
511
|
```
|
|
507
512
|
|
|
508
513
|
Get the list of items and quantity without repeating
|
|
@@ -517,14 +522,37 @@ Result:
|
|
|
517
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}]
|
|
518
523
|
```
|
|
519
524
|
|
|
525
|
+
Get the total and amount of each item
|
|
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
|
-
[
|
|
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
|
-
{
|
|
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.
|
|
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",
|