asv-hlps 1.2.24 → 1.2.25

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.
@@ -1,7 +1,7 @@
1
1
  export interface SteGrp {
2
- id: number;
3
- name: string;
2
+ id?: number;
3
+ name?: string;
4
4
  code?: string;
5
- shortname: string;
6
- coef: number;
5
+ shortname?: string;
6
+ coef?: number;
7
7
  }
@@ -64,6 +64,10 @@ export declare const packAndUnit: (qtity: number, qtityPerPackaging?: number) =>
64
64
  export declare const convertToCfa: (price: number, currency?: string, dollarRate?: number) => number;
65
65
  export declare const validEmail: (email: string) => boolean;
66
66
  export declare const calculPercent: (nbr: number, percentage: number) => number;
67
+ export declare const formatMonthYearToLocaleString: (date: Date, prms?: {
68
+ localLanguage?: string;
69
+ minusOne?: boolean;
70
+ }) => string;
67
71
  export declare const padStartWithZero: (num: any, targetLength: number) => any;
68
72
  export declare const padEndWithZero: (num: any, targetLength: number) => any;
69
73
  export declare const isBirthday: (birthDayDate: any) => boolean;
@@ -73,3 +77,11 @@ export declare const randomRgbColor: () => number[];
73
77
  export declare const randomHexColor: () => string;
74
78
  export declare const randomHslColor: () => number[];
75
79
  export declare const getArrayOfRandomColor: (length: number, type?: "hex" | "rgb" | "hsl") => string[];
80
+ export declare const displayFrDatePeriode: (getFromDate?: any, getToDate?: any) => string;
81
+ export declare const returnDates: (fromDate: any, toDate: any) => {
82
+ fromDate: any;
83
+ toDate: any;
84
+ };
85
+ export declare const absFromSequence: (arr: number[]) => number[];
86
+ export declare const fillStartWithZero: (num: string | number, targetLength: number) => string;
87
+ export declare const fillEndWithZero: (num: string | number, targetLength: number) => string;
package/lib/cjs/utils.js CHANGED
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.validEmail = exports.convertToCfa = exports.packAndUnit = exports.unCheckedAll = exports.inputChecked = exports.arrayMultiChecked = exports.getColorAccordingToDate = exports.genRandomColour = exports.formatNgbDate = exports.dateToString = exports.replaceSpacesWith = exports.replaceAllIn = exports.sesStorageGet = exports.sesStorageSet = exports.genSequenceRef = exports.removeBackSlashOccurences = exports.removeString = exports.deepClone = exports.findFirstSequenceMissing = exports.fillNumWithZero = exports.findSequencesMissing = exports.sequencesToNumbers = exports.notInSequence = exports.reformatDates = exports.formatToStringCfa = exports.formatToString = exports.wakeUp = exports.sleep = exports.limitTo = exports.titleCase = exports.toObjectDate = exports.removeDuplicatesByKey = exports.removeDuplicates = exports.getRandomColor = exports.getNbOfDaysBetweenTwoDates = exports.displayDateRangeFr = exports.calPercent = exports.percentOf = exports.genDateMinutesStep = exports.convertFrDateToEnDate = exports.convertEnDateToFr = exports.formatDateMd = exports.formatDateYm = exports.formatDateYmFirstDay = exports.formatDateYmd = exports.formatFromAndToDate = exports.formatDateYmHypen = exports.formatDateFirstDayFr = exports.formatDateYmdHypenFr = exports.formatDateYmdHypen = void 0;
4
- exports.getArrayOfRandomColor = exports.randomHslColor = exports.randomHexColor = exports.randomRgbColor = exports.randomInteger = exports.insertAtInArray = exports.isBirthday = exports.padEndWithZero = exports.padStartWithZero = exports.calculPercent = void 0;
4
+ exports.fillEndWithZero = exports.fillStartWithZero = exports.absFromSequence = exports.returnDates = exports.displayFrDatePeriode = exports.getArrayOfRandomColor = exports.randomHslColor = exports.randomHexColor = exports.randomRgbColor = exports.randomInteger = exports.insertAtInArray = exports.isBirthday = exports.padEndWithZero = exports.padStartWithZero = exports.formatMonthYearToLocaleString = exports.calculPercent = void 0;
5
5
  const formatDateYmdHypen = (date) => {
6
6
  return (0, exports.formatDateYmd)(date, "-");
7
7
  };
@@ -379,6 +379,17 @@ const calculPercent = (nbr, percentage) => {
379
379
  return (nbr * percentage) / 100;
380
380
  };
381
381
  exports.calculPercent = calculPercent;
382
+ const formatMonthYearToLocaleString = (date, prms) => {
383
+ if (prms === null || prms === void 0 ? void 0 : prms.minusOne) {
384
+ date.setMonth(date.getMonth() - 1);
385
+ }
386
+ const month = !(prms === null || prms === void 0 ? void 0 : prms.localLanguage)
387
+ ? date.toLocaleDateString("FR-fr", { month: "long" })
388
+ : date.toLocaleDateString(prms === null || prms === void 0 ? void 0 : prms.localLanguage, { month: "long" }); // get month in french
389
+ const year = date.getFullYear();
390
+ return month.toUpperCase() + " " + year;
391
+ };
392
+ exports.formatMonthYearToLocaleString = formatMonthYearToLocaleString;
382
393
  const padStartWithZero = (num, targetLength) => {
383
394
  return num.toString().padStart(targetLength, 0);
384
395
  };
@@ -450,3 +461,32 @@ const getArrayOfRandomColor = (length, type = "hex") => {
450
461
  return colors;
451
462
  };
452
463
  exports.getArrayOfRandomColor = getArrayOfRandomColor;
464
+ const displayFrDatePeriode = (getFromDate, getToDate) => {
465
+ const fromDate = !getFromDate ? new Date() : getFromDate;
466
+ const toDate = !getToDate ? fromDate : getToDate;
467
+ return (0, exports.formatDateYmdHypenFr)(new Date(fromDate)) + " au " + (0, exports.formatDateYmdHypenFr)(new Date(toDate));
468
+ };
469
+ exports.displayFrDatePeriode = displayFrDatePeriode;
470
+ const returnDates = (fromDate, toDate) => {
471
+ if (fromDate === undefined || fromDate === null) {
472
+ return;
473
+ }
474
+ // toDate = toDate !== 'null' ? toDate : fromDate;
475
+ toDate = !toDate ? fromDate : toDate;
476
+ return { fromDate, toDate };
477
+ };
478
+ exports.returnDates = returnDates;
479
+ const absFromSequence = (arr) => {
480
+ let [min, max] = [Math.min(...arr), Math.max(...arr)];
481
+ // let out = Array.from(Array(max - min), (v, i) => i + min).filter((i) => !arr.includes(i));
482
+ return Array.from(Array(max - min), (v, i) => i + min).filter((i) => !arr.includes(i));
483
+ };
484
+ exports.absFromSequence = absFromSequence;
485
+ const fillStartWithZero = (num, targetLength) => {
486
+ return num.toString().padStart(targetLength, "0");
487
+ };
488
+ exports.fillStartWithZero = fillStartWithZero;
489
+ const fillEndWithZero = (num, targetLength) => {
490
+ return num.toString().padEnd(targetLength, "0");
491
+ };
492
+ exports.fillEndWithZero = fillEndWithZero;
@@ -1,7 +1,7 @@
1
1
  export interface SteGrp {
2
- id: number;
3
- name: string;
2
+ id?: number;
3
+ name?: string;
4
4
  code?: string;
5
- shortname: string;
6
- coef: number;
5
+ shortname?: string;
6
+ coef?: number;
7
7
  }
@@ -64,6 +64,10 @@ export declare const packAndUnit: (qtity: number, qtityPerPackaging?: number) =>
64
64
  export declare const convertToCfa: (price: number, currency?: string, dollarRate?: number) => number;
65
65
  export declare const validEmail: (email: string) => boolean;
66
66
  export declare const calculPercent: (nbr: number, percentage: number) => number;
67
+ export declare const formatMonthYearToLocaleString: (date: Date, prms?: {
68
+ localLanguage?: string;
69
+ minusOne?: boolean;
70
+ }) => string;
67
71
  export declare const padStartWithZero: (num: any, targetLength: number) => any;
68
72
  export declare const padEndWithZero: (num: any, targetLength: number) => any;
69
73
  export declare const isBirthday: (birthDayDate: any) => boolean;
@@ -73,3 +77,11 @@ export declare const randomRgbColor: () => number[];
73
77
  export declare const randomHexColor: () => string;
74
78
  export declare const randomHslColor: () => number[];
75
79
  export declare const getArrayOfRandomColor: (length: number, type?: "hex" | "rgb" | "hsl") => string[];
80
+ export declare const displayFrDatePeriode: (getFromDate?: any, getToDate?: any) => string;
81
+ export declare const returnDates: (fromDate: any, toDate: any) => {
82
+ fromDate: any;
83
+ toDate: any;
84
+ };
85
+ export declare const absFromSequence: (arr: number[]) => number[];
86
+ export declare const fillStartWithZero: (num: string | number, targetLength: number) => string;
87
+ export declare const fillEndWithZero: (num: string | number, targetLength: number) => string;
package/lib/esm/utils.js CHANGED
@@ -324,6 +324,16 @@ export const validEmail = (email) => {
324
324
  export const calculPercent = (nbr, percentage) => {
325
325
  return (nbr * percentage) / 100;
326
326
  };
327
+ export const formatMonthYearToLocaleString = (date, prms) => {
328
+ if (prms === null || prms === void 0 ? void 0 : prms.minusOne) {
329
+ date.setMonth(date.getMonth() - 1);
330
+ }
331
+ const month = !(prms === null || prms === void 0 ? void 0 : prms.localLanguage)
332
+ ? date.toLocaleDateString("FR-fr", { month: "long" })
333
+ : date.toLocaleDateString(prms === null || prms === void 0 ? void 0 : prms.localLanguage, { month: "long" }); // get month in french
334
+ const year = date.getFullYear();
335
+ return month.toUpperCase() + " " + year;
336
+ };
327
337
  export const padStartWithZero = (num, targetLength) => {
328
338
  return num.toString().padStart(targetLength, 0);
329
339
  };
@@ -386,3 +396,27 @@ export const getArrayOfRandomColor = (length, type = "hex") => {
386
396
  }
387
397
  return colors;
388
398
  };
399
+ export const displayFrDatePeriode = (getFromDate, getToDate) => {
400
+ const fromDate = !getFromDate ? new Date() : getFromDate;
401
+ const toDate = !getToDate ? fromDate : getToDate;
402
+ return formatDateYmdHypenFr(new Date(fromDate)) + " au " + formatDateYmdHypenFr(new Date(toDate));
403
+ };
404
+ export const returnDates = (fromDate, toDate) => {
405
+ if (fromDate === undefined || fromDate === null) {
406
+ return;
407
+ }
408
+ // toDate = toDate !== 'null' ? toDate : fromDate;
409
+ toDate = !toDate ? fromDate : toDate;
410
+ return { fromDate, toDate };
411
+ };
412
+ export const absFromSequence = (arr) => {
413
+ let [min, max] = [Math.min(...arr), Math.max(...arr)];
414
+ // let out = Array.from(Array(max - min), (v, i) => i + min).filter((i) => !arr.includes(i));
415
+ return Array.from(Array(max - min), (v, i) => i + min).filter((i) => !arr.includes(i));
416
+ };
417
+ export const fillStartWithZero = (num, targetLength) => {
418
+ return num.toString().padStart(targetLength, "0");
419
+ };
420
+ export const fillEndWithZero = (num, targetLength) => {
421
+ return num.toString().padEnd(targetLength, "0");
422
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "asv-hlps",
3
- "version": "1.2.24",
3
+ "version": "1.2.25",
4
4
  "description": "helpers",
5
5
  "main": "./lib/cjs/index.js",
6
6
  "module": "./lib/esm/index.js",