-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathmin.js
More file actions
22 lines (18 loc) · 661 Bytes
/
min.js
File metadata and controls
22 lines (18 loc) · 661 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
/*
Example of min() API
---------------------
You need to pass a property name in min()
API to get the minimum of the values of that property.
*/
const jsonQ = require('../index.js');
let Q = new jsonQ(__dirname + '/data.json');
const minPrice = Q.from('products').min('price');
console.log('-------- Printing minPrice ---------');
console.log(minPrice);
// Resetting the instance to initial state
// because the previous query changed it internal state
Q = Q.reset();
// If the data is plain array, you don't need to pass the 'property' parameter
const arrayMin = Q.from('arr').min();
console.log('-------- Printing Min ---------');
console.log(arrayMin);