@qrvey/utils 1.15.0-7 → 1.15.0-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/dist/cjs/filters/helpers/settings/getFilterSettings.js +1 -1
- package/dist/cjs/general/array/howManyByParam.d.ts +8 -0
- package/dist/cjs/general/array/howManyByParam.js +21 -0
- package/dist/cjs/general/array/index.d.ts +2 -0
- package/dist/cjs/general/array/index.js +2 -0
- package/dist/filters/helpers/settings/getFilterSettings.js +1 -1
- package/dist/general/array/howManyByParam.d.ts +8 -0
- package/dist/general/array/howManyByParam.js +17 -0
- package/dist/general/array/index.d.ts +2 -0
- package/dist/general/array/index.js +2 -0
- package/package.json +1 -1
|
@@ -19,7 +19,6 @@ const getScopesToDisplay_1 = require("./getScopesToDisplay");
|
|
|
19
19
|
*/
|
|
20
20
|
function getFilterSettings(filterSettings, allowedScopes = [], otherSettings) {
|
|
21
21
|
let settings = (0, mergeDeep_1.mergeDeep)(FILTER_SETTINGS_DEFAULT_1.FILTER_SETTINGS_DEFAULT, (0, objectCopy_1.objectCopy)(filterSettings));
|
|
22
|
-
settings = (0, mergeDeep_1.mergeDeep)(settings, otherSettings);
|
|
23
22
|
const scopesSettings = (0, getScopesToDisplay_1.getScopesToDisplay)(settings).filter((scope) => allowedScopes.includes(scope.id));
|
|
24
23
|
if (scopesSettings.length > 1) {
|
|
25
24
|
settings = getFilterSettingsByMultipleScopes(settings, allowedScopes);
|
|
@@ -30,6 +29,7 @@ function getFilterSettings(filterSettings, allowedScopes = [], otherSettings) {
|
|
|
30
29
|
else {
|
|
31
30
|
settings = getFilterSettingsByNoScopes(settings);
|
|
32
31
|
}
|
|
32
|
+
settings = (0, mergeDeep_1.mergeDeep)(settings, otherSettings);
|
|
33
33
|
return settings;
|
|
34
34
|
}
|
|
35
35
|
exports.getFilterSettings = getFilterSettings;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Gets the number of times that the param value exists into the object array
|
|
3
|
+
* @param array the given array
|
|
4
|
+
* @param param the param of the array object to compare
|
|
5
|
+
* @param value the value of the array object to compare
|
|
6
|
+
* @returns the number of times the parameter value exists
|
|
7
|
+
*/
|
|
8
|
+
export declare function howManyByParam<T = Record<string, unknown>>(array: T[], param: keyof T, value: unknown): number;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.howManyByParam = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Gets the number of times that the param value exists into the object array
|
|
6
|
+
* @param array the given array
|
|
7
|
+
* @param param the param of the array object to compare
|
|
8
|
+
* @param value the value of the array object to compare
|
|
9
|
+
* @returns the number of times the parameter value exists
|
|
10
|
+
*/
|
|
11
|
+
function howManyByParam(array, param, value) {
|
|
12
|
+
let count = 0;
|
|
13
|
+
if (!Array.isArray(array))
|
|
14
|
+
return count;
|
|
15
|
+
for (const i of array) {
|
|
16
|
+
if (i[param] === value)
|
|
17
|
+
count = count + 1;
|
|
18
|
+
}
|
|
19
|
+
return count;
|
|
20
|
+
}
|
|
21
|
+
exports.howManyByParam = howManyByParam;
|
|
@@ -4,5 +4,7 @@ export * from "./flattenDeep";
|
|
|
4
4
|
export * from "./getArrayByProperty";
|
|
5
5
|
export * from "./filterNestedTree";
|
|
6
6
|
export * from "./getFirstIndexFromArray";
|
|
7
|
+
export * from "./getUniqueArray";
|
|
8
|
+
export * from "./howManyByParam";
|
|
7
9
|
export * from "./getLastIndexFromArray";
|
|
8
10
|
export * from "./intersectObjectArrays";
|
|
@@ -20,5 +20,7 @@ __exportStar(require("./flattenDeep"), exports);
|
|
|
20
20
|
__exportStar(require("./getArrayByProperty"), exports);
|
|
21
21
|
__exportStar(require("./filterNestedTree"), exports);
|
|
22
22
|
__exportStar(require("./getFirstIndexFromArray"), exports);
|
|
23
|
+
__exportStar(require("./getUniqueArray"), exports);
|
|
24
|
+
__exportStar(require("./howManyByParam"), exports);
|
|
23
25
|
__exportStar(require("./getLastIndexFromArray"), exports);
|
|
24
26
|
__exportStar(require("./intersectObjectArrays"), exports);
|
|
@@ -16,7 +16,6 @@ import { getScopesToDisplay } from "./getScopesToDisplay";
|
|
|
16
16
|
*/
|
|
17
17
|
export function getFilterSettings(filterSettings, allowedScopes = [], otherSettings) {
|
|
18
18
|
let settings = mergeDeep(FILTER_SETTINGS_DEFAULT, objectCopy(filterSettings));
|
|
19
|
-
settings = mergeDeep(settings, otherSettings);
|
|
20
19
|
const scopesSettings = getScopesToDisplay(settings).filter((scope) => allowedScopes.includes(scope.id));
|
|
21
20
|
if (scopesSettings.length > 1) {
|
|
22
21
|
settings = getFilterSettingsByMultipleScopes(settings, allowedScopes);
|
|
@@ -27,6 +26,7 @@ export function getFilterSettings(filterSettings, allowedScopes = [], otherSetti
|
|
|
27
26
|
else {
|
|
28
27
|
settings = getFilterSettingsByNoScopes(settings);
|
|
29
28
|
}
|
|
29
|
+
settings = mergeDeep(settings, otherSettings);
|
|
30
30
|
return settings;
|
|
31
31
|
}
|
|
32
32
|
/**
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Gets the number of times that the param value exists into the object array
|
|
3
|
+
* @param array the given array
|
|
4
|
+
* @param param the param of the array object to compare
|
|
5
|
+
* @param value the value of the array object to compare
|
|
6
|
+
* @returns the number of times the parameter value exists
|
|
7
|
+
*/
|
|
8
|
+
export declare function howManyByParam<T = Record<string, unknown>>(array: T[], param: keyof T, value: unknown): number;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Gets the number of times that the param value exists into the object array
|
|
3
|
+
* @param array the given array
|
|
4
|
+
* @param param the param of the array object to compare
|
|
5
|
+
* @param value the value of the array object to compare
|
|
6
|
+
* @returns the number of times the parameter value exists
|
|
7
|
+
*/
|
|
8
|
+
export function howManyByParam(array, param, value) {
|
|
9
|
+
let count = 0;
|
|
10
|
+
if (!Array.isArray(array))
|
|
11
|
+
return count;
|
|
12
|
+
for (const i of array) {
|
|
13
|
+
if (i[param] === value)
|
|
14
|
+
count = count + 1;
|
|
15
|
+
}
|
|
16
|
+
return count;
|
|
17
|
+
}
|
|
@@ -4,5 +4,7 @@ export * from "./flattenDeep";
|
|
|
4
4
|
export * from "./getArrayByProperty";
|
|
5
5
|
export * from "./filterNestedTree";
|
|
6
6
|
export * from "./getFirstIndexFromArray";
|
|
7
|
+
export * from "./getUniqueArray";
|
|
8
|
+
export * from "./howManyByParam";
|
|
7
9
|
export * from "./getLastIndexFromArray";
|
|
8
10
|
export * from "./intersectObjectArrays";
|
|
@@ -4,5 +4,7 @@ export * from "./flattenDeep";
|
|
|
4
4
|
export * from "./getArrayByProperty";
|
|
5
5
|
export * from "./filterNestedTree";
|
|
6
6
|
export * from "./getFirstIndexFromArray";
|
|
7
|
+
export * from "./getUniqueArray";
|
|
8
|
+
export * from "./howManyByParam";
|
|
7
9
|
export * from "./getLastIndexFromArray";
|
|
8
10
|
export * from "./intersectObjectArrays";
|