jexp 0.1.8 → 0.1.9
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 +57 -15
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -325,13 +325,13 @@ jexp '.details.max(p=> p.unitPrice * p.qty )' ./data/orders.json
|
|
|
325
325
|
**Get the middle value "unitPrice * p.qty" from all the details**:
|
|
326
326
|
|
|
327
327
|
```sh
|
|
328
|
-
jexp '.details.avg(p=> p.unitPrice * p.qty
|
|
328
|
+
jexp 'round(.details.avg(p=> p.unitPrice * p.qty),2)' ./data/orders.json
|
|
329
329
|
```
|
|
330
330
|
|
|
331
331
|
*Result*:
|
|
332
332
|
|
|
333
333
|
```json
|
|
334
|
-
2.
|
|
334
|
+
2.35
|
|
335
335
|
```
|
|
336
336
|
|
|
337
337
|
**Gets the sum of the total property**:
|
|
@@ -379,13 +379,7 @@ jexp '.details.first(p=> p.unitPrice * p.qty < 3 ).article' ./data/orders.json
|
|
|
379
379
|
*Result*:
|
|
380
380
|
|
|
381
381
|
```json
|
|
382
|
-
"
|
|
383
|
-
```
|
|
384
|
-
|
|
385
|
-
**Get the last article property of all details where "unitPrice * p.qty" is less than 3**:
|
|
386
|
-
|
|
387
|
-
```sh
|
|
388
|
-
jexp '.details.last(p=> p.unitPrice * p.qty < 3 ).article' ./data/orders.json
|
|
382
|
+
"Banan…unitPrice * p.qty < 3 ).article' ./data/orders.json
|
|
389
383
|
```
|
|
390
384
|
|
|
391
385
|
*Result*:
|
|
@@ -419,7 +413,7 @@ curl -s https://raw.githubusercontent.com/FlavioLionelRita/jexp/main/data/orders
|
|
|
419
413
|
*Result*:
|
|
420
414
|
|
|
421
415
|
```json
|
|
422
|
-
|
|
416
|
+
23.44
|
|
423
417
|
```
|
|
424
418
|
|
|
425
419
|
**Get the smallest article**:
|
|
@@ -446,16 +440,16 @@ jexp '.details.max(p=> p.unitPrice * p.qty )' ./data/orders.json
|
|
|
446
440
|
3.98
|
|
447
441
|
```
|
|
448
442
|
|
|
449
|
-
**
|
|
443
|
+
**Average value of the price of the items purchased in the order 20003**:
|
|
450
444
|
|
|
451
445
|
```sh
|
|
452
|
-
jexp '.details.avg(p=> p.unitPrice
|
|
446
|
+
jexp 'round(.filter(p=> p.number == "20003").details.avg(p=> p.unitPrice),2)' ./data/orders.json
|
|
453
447
|
```
|
|
454
448
|
|
|
455
449
|
*Result*:
|
|
456
450
|
|
|
457
451
|
```json
|
|
458
|
-
2
|
|
452
|
+
2
|
|
459
453
|
```
|
|
460
454
|
|
|
461
455
|
**Get the total of the details of order 1**:
|
|
@@ -631,14 +625,14 @@ jexp '{total:.[0].details.sum(p=>p.qty * p.unitPrice)}' ./data/orders.json
|
|
|
631
625
|
**Get the total of the last order**:
|
|
632
626
|
|
|
633
627
|
```sh
|
|
634
|
-
jexp '{total
|
|
628
|
+
jexp '{total:round(.[.length()-1].details.sum(p=>p.qty * p.unitPrice),2)}' ./data/orders.json -b
|
|
635
629
|
```
|
|
636
630
|
|
|
637
631
|
*Result*:
|
|
638
632
|
|
|
639
633
|
```json
|
|
640
634
|
{
|
|
641
|
-
"total": 7.
|
|
635
|
+
"total": 7.95
|
|
642
636
|
}
|
|
643
637
|
```
|
|
644
638
|
|
|
@@ -654,6 +648,54 @@ jexp '.map(p=>{nro:p.number,total:p.details.sum(q=>q.qty * q.unitPrice)})' ./dat
|
|
|
654
648
|
[{"nro":"20001","total":7.58},{"nro":"20002","total":7.91},{"nro":"20003","total":7.949999999999999}]
|
|
655
649
|
```
|
|
656
650
|
|
|
651
|
+
**All articles that are in orders 20001 and 20003**:
|
|
652
|
+
|
|
653
|
+
```sh
|
|
654
|
+
jexp '.[0].details.article.union(.[1].details.article)' ./data/orders.json
|
|
655
|
+
```
|
|
656
|
+
|
|
657
|
+
*Result*:
|
|
658
|
+
|
|
659
|
+
```json
|
|
660
|
+
["Pear","Banana","White grape","Apple"]
|
|
661
|
+
```
|
|
662
|
+
|
|
663
|
+
**The articles in common between order 20001 and 20002**:
|
|
664
|
+
|
|
665
|
+
```sh
|
|
666
|
+
jexp '.[0].details.article.intersection(.[1].details.article)' ./data/orders.json
|
|
667
|
+
```
|
|
668
|
+
|
|
669
|
+
*Result*:
|
|
670
|
+
|
|
671
|
+
```json
|
|
672
|
+
["Banana","Pear"]
|
|
673
|
+
```
|
|
674
|
+
|
|
675
|
+
**Articles that are in order 20001 and are not in order 20002**:
|
|
676
|
+
|
|
677
|
+
```sh
|
|
678
|
+
jexp '.[0].details.article.difference(.[1].details.article)' ./data/orders.json
|
|
679
|
+
```
|
|
680
|
+
|
|
681
|
+
*Result*:
|
|
682
|
+
|
|
683
|
+
```json
|
|
684
|
+
["White grape"]
|
|
685
|
+
```
|
|
686
|
+
|
|
687
|
+
**Articles of orders 20001 and 20003 that are not shared**:
|
|
688
|
+
|
|
689
|
+
```sh
|
|
690
|
+
jexp '.[0].details.article.symmetricDifference(.[1].details.article)' ./data/orders.json
|
|
691
|
+
```
|
|
692
|
+
|
|
693
|
+
*Result*:
|
|
694
|
+
|
|
695
|
+
```json
|
|
696
|
+
["White grape","Apple"]
|
|
697
|
+
```
|
|
698
|
+
|
|
657
699
|
## js-expression
|
|
658
700
|
|
|
659
701
|
> [Js-expression](https://www.npmjs.com/package/js-expressions) is an extensible expression evaluator and parser.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "jexp",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.9",
|
|
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",
|