1 | /**
|
2 | * @param {Object<string,function(*):boolean>} filterObject
|
3 | * @return {Object[]} - new array
|
4 | */
|
5 | const samplesFind = function (filterObject) {
|
6 | let samples = this;
|
7 |
|
8 | for (let field in filterObject) if (filterObject.hasOwnProperty(field)) samples = samplesFindOnce.call(samples, field, filterObject[field]);
|
9 |
|
10 | return samples;
|
11 | };
|
12 | /**
|
13 | * @param {string} field
|
14 | * @param {function(*):boolean} filter
|
15 | * @return {Object[]} - new array
|
16 | */
|
17 |
|
18 | const samplesFindOnce = function (field, filter) {
|
19 | return this.filter(sample => filter(sample[field]));
|
20 | };
|
21 |
|
22 | export { samplesFind };
|