asv-hlps 1.4.45 → 1.4.46
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/lib/cjs/utils.d.ts +5 -1
- package/lib/cjs/utils.js +20 -3
- package/lib/esm/utils.d.ts +5 -1
- package/lib/esm/utils.js +17 -1
- package/package.json +1 -1
package/lib/cjs/utils.d.ts
CHANGED
|
@@ -16,6 +16,10 @@ export declare const getRandomColor: (brightness: number) => string;
|
|
|
16
16
|
export declare const removeDuplicateObjects: (array: any[], property?: string) => any[];
|
|
17
17
|
export declare const removeDuplicateValues: (array: any[]) => any[];
|
|
18
18
|
export declare const duplicateObjects: (array: any[], property: string) => any[];
|
|
19
|
+
export declare const duplicateObjectsGrouped: (array: any[], keyProp?: string, prms?: {
|
|
20
|
+
arrProp?: string;
|
|
21
|
+
groupedByKeyProp?: boolean;
|
|
22
|
+
}) => any[];
|
|
19
23
|
export declare const toObjectDate: (fromDate: any, toDate: string) => {
|
|
20
24
|
fromDate: any;
|
|
21
25
|
toDate: string;
|
|
@@ -64,7 +68,7 @@ export declare const formatNgbDate: (date: any) => {
|
|
|
64
68
|
toDate: string;
|
|
65
69
|
};
|
|
66
70
|
export declare const genRandomColour: () => string;
|
|
67
|
-
export declare const getColorAccordingToDate: (inputDate: Date, period1?: number, period2?: number, period3?: number, ifClass?: boolean) => "red" | "DarkOrange" | "turquoise" | "blue" | "green" | "#f46a6a" | "#f1b44c" | "#cce5ff" | "#34c38f" | "#339900";
|
|
71
|
+
export declare const getColorAccordingToDate: (inputDate: Date, period1?: number, period2?: number, period3?: number, ifClass?: boolean, options?: {}) => "red" | "DarkOrange" | "turquoise" | "blue" | "green" | "#f46a6a" | "#f1b44c" | "#cce5ff" | "#34c38f" | "#339900";
|
|
68
72
|
export declare const getPeriodDateColor: (inputDate: string, period?: number, colors?: [string, string, string, string, ...string[]]) => string;
|
|
69
73
|
export declare const arrayMultiChecked: (objet: any[], event: boolean, item: any) => any[];
|
|
70
74
|
export declare const inputChecked: (event: any, item: any, checks: any[], isChecked?: boolean) => any[];
|
package/lib/cjs/utils.js
CHANGED
|
@@ -3,8 +3,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
7
|
-
exports.nthIndexOf = exports.pathName = exports.checkObjInArray = exports.arraySome = exports.winMaxHeight = exports.toggleProp = exports.roundLastNDigits = exports.removeParamKeyName = exports.countryIsoToFlag = exports.monthStringName = exports.returnBool = exports.formatAmountToString = exports.reduceTimes = exports.reduceSum = exports.sumAmount = exports.fillEndWithZero = exports.fillStartWithZero = exports.absFromSequence = exports.returnDates = exports.displayFrDatePeriode = exports.getArrayOfRandomColor = exports.randomHslColor = exports.randomHexColor = exports.genRandomNumberArray = exports.randomRgbColor = exports.randomInteger = exports.insertAtInArray = exports.isBirthday = exports.padEndWithZero = exports.padStartWithZero = exports.formatMonthYearToLocaleString = exports.calculPercent = exports.validEmail = exports.convertToCfa = exports.packAndUnit = exports.unCheckedAll = exports.inputChecked = exports.arrayMultiChecked = void 0;
|
|
6
|
+
exports.getColorAccordingToDate = exports.genRandomColour = exports.formatNgbDate = exports.dateNth = exports.dateNthMonth = exports.dateNthDay = exports.dateNthWeek = exports.getNbOfDaysBetweenTwoDates = exports.displayDateRangeFr = exports.reformatDates = exports.firstDayOfDate = exports.dateToString = exports.dateDiff = exports.dateFormatter = exports.replaceSpacesWith = exports.replaceAllIn = exports.toPlural = exports.sesStorageGet = exports.sesStorageSet = exports.genSequenceRef = exports.refGenerator = exports.removeBackSlashOccurences = exports.stringifyFormatter = exports.removeString = exports.diffArraysByProp = exports.diffArraysByFunc = exports.deepClone = exports.findFirstSequenceMissing = exports.fillNumWithZero = exports.findSequencesMissing = exports.sequencesToNumbers = exports.notInSequence = exports.currencyFormatterCfa = exports.currencyFormatter = exports.checkAuth = exports.wakeUp = exports.sleep = exports.limitTo = exports.titleCase = exports.toObjectDate = exports.duplicateObjectsGrouped = exports.duplicateObjects = exports.removeDuplicateValues = exports.removeDuplicateObjects = exports.getRandomColor = exports.calPercent = exports.percentOf = exports.genDateMinutesStep = exports.formatDateFirstDayFr = exports.isEmpty = void 0;
|
|
7
|
+
exports.nthIndexOf = exports.pathName = exports.checkObjInArray = exports.arraySome = exports.winMaxHeight = exports.toggleProp = exports.roundLastNDigits = exports.removeParamKeyName = exports.countryIsoToFlag = exports.monthStringName = exports.returnBool = exports.formatAmountToString = exports.reduceTimes = exports.reduceSum = exports.sumAmount = exports.fillEndWithZero = exports.fillStartWithZero = exports.absFromSequence = exports.returnDates = exports.displayFrDatePeriode = exports.getArrayOfRandomColor = exports.randomHslColor = exports.randomHexColor = exports.genRandomNumberArray = exports.randomRgbColor = exports.randomInteger = exports.insertAtInArray = exports.isBirthday = exports.padEndWithZero = exports.padStartWithZero = exports.formatMonthYearToLocaleString = exports.calculPercent = exports.validEmail = exports.convertToCfa = exports.packAndUnit = exports.unCheckedAll = exports.inputChecked = exports.arrayMultiChecked = exports.getPeriodDateColor = void 0;
|
|
8
8
|
const dayjs_1 = __importDefault(require("dayjs"));
|
|
9
9
|
const dayOfYear_1 = __importDefault(require("dayjs/plugin/dayOfYear"));
|
|
10
10
|
const isSameOrBefore_1 = __importDefault(require("dayjs/plugin/isSameOrBefore"));
|
|
@@ -146,6 +146,23 @@ const duplicateObjects = (array, property) => {
|
|
|
146
146
|
return array.filter((obj, index) => array.findIndex(item => lodash_1.default.get(item, property) === lodash_1.default.get(obj, property)) !== index);
|
|
147
147
|
};
|
|
148
148
|
exports.duplicateObjects = duplicateObjects;
|
|
149
|
+
const duplicateObjectsGrouped = (array, keyProp = "id", prms) => {
|
|
150
|
+
const objs = array.reduce((acc, obj) => {
|
|
151
|
+
const key = obj[keyProp];
|
|
152
|
+
if (!acc[key]) {
|
|
153
|
+
acc[key] = [];
|
|
154
|
+
}
|
|
155
|
+
acc[key].push(obj);
|
|
156
|
+
return acc;
|
|
157
|
+
}, {});
|
|
158
|
+
const grouped = Object.values(objs);
|
|
159
|
+
const groupedByKeyProp = grouped.map((obj) => ({
|
|
160
|
+
[keyProp]: obj[0][keyProp],
|
|
161
|
+
[(prms === null || prms === void 0 ? void 0 : prms.arrProp) || "arr"]: obj,
|
|
162
|
+
}));
|
|
163
|
+
return (prms === null || prms === void 0 ? void 0 : prms.groupedByKeyProp) || true ? groupedByKeyProp : grouped;
|
|
164
|
+
};
|
|
165
|
+
exports.duplicateObjectsGrouped = duplicateObjectsGrouped;
|
|
149
166
|
const toObjectDate = (fromDate, toDate) => {
|
|
150
167
|
toDate = toDate !== "null" ? toDate : fromDate;
|
|
151
168
|
return { fromDate: fromDate, toDate: toDate };
|
|
@@ -442,7 +459,7 @@ const genRandomColour = () => {
|
|
|
442
459
|
return "#" + Math.floor(Math.random() * 16777215).toString(16);
|
|
443
460
|
};
|
|
444
461
|
exports.genRandomColour = genRandomColour;
|
|
445
|
-
const getColorAccordingToDate = (inputDate, period1 = 3, period2 = 6, period3 = 9, ifClass) => {
|
|
462
|
+
const getColorAccordingToDate = (inputDate, period1 = 3, period2 = 6, period3 = 9, ifClass, options) => {
|
|
446
463
|
const date = new Date();
|
|
447
464
|
const date2 = new Date(inputDate);
|
|
448
465
|
const diffNumber = Math.ceil((0, exports.getNbOfDaysBetweenTwoDates)(date2, date));
|
package/lib/esm/utils.d.ts
CHANGED
|
@@ -16,6 +16,10 @@ export declare const getRandomColor: (brightness: number) => string;
|
|
|
16
16
|
export declare const removeDuplicateObjects: (array: any[], property?: string) => any[];
|
|
17
17
|
export declare const removeDuplicateValues: (array: any[]) => any[];
|
|
18
18
|
export declare const duplicateObjects: (array: any[], property: string) => any[];
|
|
19
|
+
export declare const duplicateObjectsGrouped: (array: any[], keyProp?: string, prms?: {
|
|
20
|
+
arrProp?: string;
|
|
21
|
+
groupedByKeyProp?: boolean;
|
|
22
|
+
}) => any[];
|
|
19
23
|
export declare const toObjectDate: (fromDate: any, toDate: string) => {
|
|
20
24
|
fromDate: any;
|
|
21
25
|
toDate: string;
|
|
@@ -64,7 +68,7 @@ export declare const formatNgbDate: (date: any) => {
|
|
|
64
68
|
toDate: string;
|
|
65
69
|
};
|
|
66
70
|
export declare const genRandomColour: () => string;
|
|
67
|
-
export declare const getColorAccordingToDate: (inputDate: Date, period1?: number, period2?: number, period3?: number, ifClass?: boolean) => "red" | "DarkOrange" | "turquoise" | "blue" | "green" | "#f46a6a" | "#f1b44c" | "#cce5ff" | "#34c38f" | "#339900";
|
|
71
|
+
export declare const getColorAccordingToDate: (inputDate: Date, period1?: number, period2?: number, period3?: number, ifClass?: boolean, options?: {}) => "red" | "DarkOrange" | "turquoise" | "blue" | "green" | "#f46a6a" | "#f1b44c" | "#cce5ff" | "#34c38f" | "#339900";
|
|
68
72
|
export declare const getPeriodDateColor: (inputDate: string, period?: number, colors?: [string, string, string, string, ...string[]]) => string;
|
|
69
73
|
export declare const arrayMultiChecked: (objet: any[], event: boolean, item: any) => any[];
|
|
70
74
|
export declare const inputChecked: (event: any, item: any, checks: any[], isChecked?: boolean) => any[];
|
package/lib/esm/utils.js
CHANGED
|
@@ -130,6 +130,22 @@ export const removeDuplicateValues = (array) => {
|
|
|
130
130
|
export const duplicateObjects = (array, property) => {
|
|
131
131
|
return array.filter((obj, index) => array.findIndex(item => lodash.get(item, property) === lodash.get(obj, property)) !== index);
|
|
132
132
|
};
|
|
133
|
+
export const duplicateObjectsGrouped = (array, keyProp = "id", prms) => {
|
|
134
|
+
const objs = array.reduce((acc, obj) => {
|
|
135
|
+
const key = obj[keyProp];
|
|
136
|
+
if (!acc[key]) {
|
|
137
|
+
acc[key] = [];
|
|
138
|
+
}
|
|
139
|
+
acc[key].push(obj);
|
|
140
|
+
return acc;
|
|
141
|
+
}, {});
|
|
142
|
+
const grouped = Object.values(objs);
|
|
143
|
+
const groupedByKeyProp = grouped.map((obj) => ({
|
|
144
|
+
[keyProp]: obj[0][keyProp],
|
|
145
|
+
[(prms === null || prms === void 0 ? void 0 : prms.arrProp) || "arr"]: obj,
|
|
146
|
+
}));
|
|
147
|
+
return (prms === null || prms === void 0 ? void 0 : prms.groupedByKeyProp) || true ? groupedByKeyProp : grouped;
|
|
148
|
+
};
|
|
133
149
|
export const toObjectDate = (fromDate, toDate) => {
|
|
134
150
|
toDate = toDate !== "null" ? toDate : fromDate;
|
|
135
151
|
return { fromDate: fromDate, toDate: toDate };
|
|
@@ -387,7 +403,7 @@ export const formatNgbDate = (date) => {
|
|
|
387
403
|
export const genRandomColour = () => {
|
|
388
404
|
return "#" + Math.floor(Math.random() * 16777215).toString(16);
|
|
389
405
|
};
|
|
390
|
-
export const getColorAccordingToDate = (inputDate, period1 = 3, period2 = 6, period3 = 9, ifClass) => {
|
|
406
|
+
export const getColorAccordingToDate = (inputDate, period1 = 3, period2 = 6, period3 = 9, ifClass, options) => {
|
|
391
407
|
const date = new Date();
|
|
392
408
|
const date2 = new Date(inputDate);
|
|
393
409
|
const diffNumber = Math.ceil(getNbOfDaysBetweenTwoDates(date2, date));
|