jexp 0.1.9 → 0.1.10
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 +37 -30
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -286,16 +286,16 @@ jexp '.details.article' ./data/orders.json
|
|
|
286
286
|
["Pear","Banana","White grape","Apple","Banana","Pear","Apple","Banana","Pear","White grape"]
|
|
287
287
|
```
|
|
288
288
|
|
|
289
|
-
**
|
|
289
|
+
**The order with the smallest total**:
|
|
290
290
|
|
|
291
291
|
```sh
|
|
292
|
-
jexp '.min(p=> p.total)' ./data/orders.json
|
|
292
|
+
jexp '.map(p=>{nro:p.number,total:p.details.sum(q=> q.unitPrice * q.qty)}).min(p=> p.total)' ./data/orders.json
|
|
293
293
|
```
|
|
294
294
|
|
|
295
295
|
*Result*:
|
|
296
296
|
|
|
297
297
|
```json
|
|
298
|
-
|
|
298
|
+
7.58
|
|
299
299
|
```
|
|
300
300
|
|
|
301
301
|
**Get the minimum of the article property from all the details**:
|
|
@@ -379,7 +379,13 @@ jexp '.details.first(p=> p.unitPrice * p.qty < 3 ).article' ./data/orders.json
|
|
|
379
379
|
*Result*:
|
|
380
380
|
|
|
381
381
|
```json
|
|
382
|
-
"
|
|
382
|
+
"Banana"
|
|
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
|
|
383
389
|
```
|
|
384
390
|
|
|
385
391
|
*Result*:
|
|
@@ -404,18 +410,6 @@ jexp '.details.first(p=> p.unitPrice * p.qty < 3 )' ./data/orders.json -b
|
|
|
404
410
|
}
|
|
405
411
|
```
|
|
406
412
|
|
|
407
|
-
**Get the sum "unitPrice * p.qty" of the details of item 1 of the list using pipeline**:
|
|
408
|
-
|
|
409
|
-
```sh
|
|
410
|
-
curl -s https://raw.githubusercontent.com/FlavioLionelRita/jexp/main/data/orders.json | jexp '.details.sum(p=> p.unitPrice * p.qty )'
|
|
411
|
-
```
|
|
412
|
-
|
|
413
|
-
*Result*:
|
|
414
|
-
|
|
415
|
-
```json
|
|
416
|
-
23.44
|
|
417
|
-
```
|
|
418
|
-
|
|
419
413
|
**Get the smallest article**:
|
|
420
414
|
|
|
421
415
|
```sh
|
|
@@ -565,18 +559,6 @@ jexp '.details.distinct(p=>p.article)' ./data/orders.json -b
|
|
|
565
559
|
]
|
|
566
560
|
```
|
|
567
561
|
|
|
568
|
-
**Get the list of items and quantity without repeating**:
|
|
569
|
-
|
|
570
|
-
```sh
|
|
571
|
-
jexp '.details.distinct(p=>{article:p.article,qty:p.qty}) -b' ./data/orders.json
|
|
572
|
-
```
|
|
573
|
-
|
|
574
|
-
*Result*:
|
|
575
|
-
|
|
576
|
-
```json
|
|
577
|
-
null
|
|
578
|
-
```
|
|
579
|
-
|
|
580
562
|
**Get the total and amount of each item**:
|
|
581
563
|
|
|
582
564
|
```sh
|
|
@@ -639,13 +621,26 @@ jexp '{total:round(.[.length()-1].details.sum(p=>p.qty * p.unitPrice),2)}' ./dat
|
|
|
639
621
|
**List the orders with their totals**:
|
|
640
622
|
|
|
641
623
|
```sh
|
|
642
|
-
jexp '.map(p=>{nro:p.number,total:p.details.sum(q=>q.qty * q.unitPrice)})' ./data/orders.json
|
|
624
|
+
jexp '.map(p=>{nro:p.number,total:round(p.details.sum(q=>q.qty * q.unitPrice),2)})' ./data/orders.json -b
|
|
643
625
|
```
|
|
644
626
|
|
|
645
627
|
*Result*:
|
|
646
628
|
|
|
647
629
|
```json
|
|
648
|
-
[
|
|
630
|
+
[
|
|
631
|
+
{
|
|
632
|
+
"nro": "20001",
|
|
633
|
+
"total": 7.6
|
|
634
|
+
},
|
|
635
|
+
{
|
|
636
|
+
"nro": "20002",
|
|
637
|
+
"total": 7.9
|
|
638
|
+
},
|
|
639
|
+
{
|
|
640
|
+
"nro": "20003",
|
|
641
|
+
"total": 7.95
|
|
642
|
+
}
|
|
643
|
+
]
|
|
649
644
|
```
|
|
650
645
|
|
|
651
646
|
**All articles that are in orders 20001 and 20003**:
|
|
@@ -696,6 +691,18 @@ jexp '.[0].details.article.symmetricDifference(.[1].details.article)' ./data/ord
|
|
|
696
691
|
["White grape","Apple"]
|
|
697
692
|
```
|
|
698
693
|
|
|
694
|
+
**Get the sum "unitPrice * p.qty" of the details of item 1 of the list using pipeline**:
|
|
695
|
+
|
|
696
|
+
```sh
|
|
697
|
+
curl -s https://raw.githubusercontent.com/FlavioLionelRita/jexp/main/data/orders.json | jexp '.details.sum(p=> p.unitPrice * p.qty )'
|
|
698
|
+
```
|
|
699
|
+
|
|
700
|
+
*Result*:
|
|
701
|
+
|
|
702
|
+
```json
|
|
703
|
+
23.44
|
|
704
|
+
```
|
|
705
|
+
|
|
699
706
|
## js-expression
|
|
700
707
|
|
|
701
708
|
> [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.10",
|
|
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",
|