asv-hlps 1.4.35 → 1.4.37

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.
@@ -110,4 +110,5 @@ export declare const toggleProp: (tob: any, propToToggle: string) => any;
110
110
  export declare const winMaxHeight: (step?: 0.2 | 0.3 | 0.4 | 0.5 | 0.6 | 0.7 | 0.8 | 0.9) => number;
111
111
  export declare const arraySome: (arr1: any[], arr2: any[]) => boolean;
112
112
  export declare const checkObjInArray: (objs: any[], checkProp: string | number, prop?: string) => boolean;
113
- export declare const pathUrlName: (location: any) => any;
113
+ export declare const pathName: (location: any) => any;
114
+ export declare const nthIndexOf: (str: string, charToFind: string, nthPosition?: number) => number;
package/lib/cjs/utils.js CHANGED
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.inputChecked = exports.arrayMultiChecked = exports.getPeriodDateColor = exports.getColorAccordingToDate = exports.genRandomColour = exports.formatNgbDate = exports.getNbOfDaysBetweenTwoDates = exports.displayDateRangeFr = exports.reformatDates = exports.firstDayOfDate = exports.dateToString = exports.dateDiff = exports.dateNthWeek = exports.getNthWeek = 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.duplicateObjects = exports.removeDuplicateValues = exports.removeDuplicateObjects = exports.getRandomColor = exports.calPercent = exports.percentOf = exports.genDateMinutesStep = exports.formatDateFirstDayFr = exports.isEmpty = void 0;
7
- exports.pathUrlName = 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 = 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 = void 0;
8
8
  const dayjs_1 = __importDefault(require("dayjs"));
9
9
  const isSameOrBefore_1 = __importDefault(require("dayjs/plugin/isSameOrBefore"));
10
10
  const relativeTime_1 = __importDefault(require("dayjs/plugin/relativeTime"));
@@ -118,7 +118,7 @@ exports.getRandomColor = getRandomColor;
118
118
  return [...new Map(tobs.map((item) => [item[property], item])).values()];
119
119
  }; */
120
120
  const removeDuplicateObjects = (array, property = "id") => {
121
- return array.filter((obj, index) => array.findIndex((item) => lodash_1.default.get(item, property) === lodash_1.default.get(obj, property)) === index);
121
+ return array.filter((obj, index) => array.findIndex(item => lodash_1.default.get(item, property) === lodash_1.default.get(obj, property)) === index);
122
122
  /* const uniqueIds: any[] = [];
123
123
  const unique = array.filter((element) => {
124
124
  const isDuplicate = uniqueIds.includes(element[property]);
@@ -140,7 +140,7 @@ const removeDuplicateValues = (array) => {
140
140
  };
141
141
  exports.removeDuplicateValues = removeDuplicateValues;
142
142
  const duplicateObjects = (array, property) => {
143
- return array.filter((obj, index) => array.findIndex((item) => lodash_1.default.get(item, property) === lodash_1.default.get(obj, property)) !== index);
143
+ return array.filter((obj, index) => array.findIndex(item => lodash_1.default.get(item, property) === lodash_1.default.get(obj, property)) !== index);
144
144
  };
145
145
  exports.duplicateObjects = duplicateObjects;
146
146
  const toObjectDate = (fromDate, toDate) => {
@@ -167,7 +167,7 @@ const limitTo = (value, limit = 15, trail = "") => {
167
167
  };
168
168
  exports.limitTo = limitTo;
169
169
  const sleep = (ms) => {
170
- return new Promise((resolve) => setTimeout(resolve, ms));
170
+ return new Promise(resolve => setTimeout(resolve, ms));
171
171
  };
172
172
  exports.sleep = sleep;
173
173
  const wakeUp = (sleep) => {
@@ -192,7 +192,7 @@ exports.currencyFormatterCfa = currencyFormatterCfa;
192
192
  const notInSequence = (arr) => {
193
193
  const [min, max] = [Math.min(...arr), Math.max(...arr)];
194
194
  // let out = Array.from(Array(max - min), (v, i) => i + min).filter((i) => !arr.includes(i));
195
- return Array.from(Array(max - min), (v, i) => i + min).filter((i) => !arr.includes(i));
195
+ return Array.from(Array(max - min), (v, i) => i + min).filter(i => !arr.includes(i));
196
196
  };
197
197
  exports.notInSequence = notInSequence;
198
198
  const sequencesToNumbers = (arr) => {
@@ -507,7 +507,7 @@ const getPeriodDateColor = (inputDate, period = 30, colors) => {
507
507
  };
508
508
  exports.getPeriodDateColor = getPeriodDateColor;
509
509
  const arrayMultiChecked = (objet, event, item) => {
510
- const findItem = objet.find((x) => x.id === item.id);
510
+ const findItem = objet.find(x => x.id === item.id);
511
511
  event && !findItem ? objet.push(item) : objet.splice(objet.indexOf(findItem), 1);
512
512
  return objet;
513
513
  };
@@ -524,7 +524,7 @@ const inputChecked = (event, item, checks, isChecked = true) => {
524
524
  exports.inputChecked = inputChecked;
525
525
  const unCheckedAll = (checks) => {
526
526
  const checkeds = document.querySelectorAll("input");
527
- checkeds.forEach((el) => {
527
+ checkeds.forEach(el => {
528
528
  if (el.checked) {
529
529
  el.checked = false;
530
530
  }
@@ -678,7 +678,7 @@ exports.returnDates = returnDates;
678
678
  const absFromSequence = (arr) => {
679
679
  let [min, max] = [Math.min(...arr), Math.max(...arr)];
680
680
  // let out = Array.from(Array(max - min), (v, i) => i + min).filter((i) => !arr.includes(i));
681
- return Array.from(Array(max - min), (v, i) => i + min).filter((i) => !arr.includes(i));
681
+ return Array.from(Array(max - min), (v, i) => i + min).filter(i => !arr.includes(i));
682
682
  };
683
683
  exports.absFromSequence = absFromSequence;
684
684
  const fillStartWithZero = (num, targetLength) => {
@@ -748,8 +748,8 @@ exports.monthStringName = monthStringName;
748
748
  const countryIsoToFlag = (code) => {
749
749
  return code
750
750
  .split("")
751
- .map((letter) => (letter.charCodeAt(0) % 32) + 0x1f1e5)
752
- .map((n) => String.fromCodePoint(n))
751
+ .map(letter => (letter.charCodeAt(0) % 32) + 0x1f1e5)
752
+ .map(n => String.fromCodePoint(n))
753
753
  .join("");
754
754
  };
755
755
  exports.countryIsoToFlag = countryIsoToFlag;
@@ -787,17 +787,21 @@ const winMaxHeight = (step) => {
787
787
  };
788
788
  exports.winMaxHeight = winMaxHeight;
789
789
  const arraySome = (arr1, arr2) => {
790
- return arr1.some((x) => arr2.includes(x));
790
+ return arr1.some(x => arr2.includes(x));
791
791
  };
792
792
  exports.arraySome = arraySome;
793
793
  const checkObjInArray = (objs, checkProp, prop = "id") => {
794
- return objs.some((x) => {
794
+ return objs.some(x => {
795
795
  return x[prop] === checkProp;
796
796
  });
797
797
  };
798
798
  exports.checkObjInArray = checkObjInArray;
799
799
  // export const pathUrlName = (location: Location) => {
800
- const pathUrlName = (location) => {
800
+ const pathName = (location) => {
801
801
  return location.pathname.substring(location.pathname.lastIndexOf("/") + 1);
802
802
  };
803
- exports.pathUrlName = pathUrlName;
803
+ exports.pathName = pathName;
804
+ const nthIndexOf = (str, charToFind, nthPosition = 1) => {
805
+ return str.split(charToFind, nthPosition).join(charToFind).length;
806
+ };
807
+ exports.nthIndexOf = nthIndexOf;
@@ -110,4 +110,5 @@ export declare const toggleProp: (tob: any, propToToggle: string) => any;
110
110
  export declare const winMaxHeight: (step?: 0.2 | 0.3 | 0.4 | 0.5 | 0.6 | 0.7 | 0.8 | 0.9) => number;
111
111
  export declare const arraySome: (arr1: any[], arr2: any[]) => boolean;
112
112
  export declare const checkObjInArray: (objs: any[], checkProp: string | number, prop?: string) => boolean;
113
- export declare const pathUrlName: (location: any) => any;
113
+ export declare const pathName: (location: any) => any;
114
+ export declare const nthIndexOf: (str: string, charToFind: string, nthPosition?: number) => number;
package/lib/esm/utils.js CHANGED
@@ -105,7 +105,7 @@ export const getRandomColor = (brightness) => {
105
105
  return [...new Map(tobs.map((item) => [item[property], item])).values()];
106
106
  }; */
107
107
  export const removeDuplicateObjects = (array, property = "id") => {
108
- return array.filter((obj, index) => array.findIndex((item) => lodash.get(item, property) === lodash.get(obj, property)) === index);
108
+ return array.filter((obj, index) => array.findIndex(item => lodash.get(item, property) === lodash.get(obj, property)) === index);
109
109
  /* const uniqueIds: any[] = [];
110
110
  const unique = array.filter((element) => {
111
111
  const isDuplicate = uniqueIds.includes(element[property]);
@@ -125,7 +125,7 @@ export const removeDuplicateValues = (array) => {
125
125
  return [...new Set(array)];
126
126
  };
127
127
  export const duplicateObjects = (array, property) => {
128
- return array.filter((obj, index) => array.findIndex((item) => lodash.get(item, property) === lodash.get(obj, property)) !== index);
128
+ return array.filter((obj, index) => array.findIndex(item => lodash.get(item, property) === lodash.get(obj, property)) !== index);
129
129
  };
130
130
  export const toObjectDate = (fromDate, toDate) => {
131
131
  toDate = toDate !== "null" ? toDate : fromDate;
@@ -148,7 +148,7 @@ export const limitTo = (value, limit = 15, trail = "") => {
148
148
  return value.length > limit ? value.substring(0, limit) + trail : value;
149
149
  };
150
150
  export const sleep = (ms) => {
151
- return new Promise((resolve) => setTimeout(resolve, ms));
151
+ return new Promise(resolve => setTimeout(resolve, ms));
152
152
  };
153
153
  export const wakeUp = (sleep) => {
154
154
  clearInterval(sleep);
@@ -168,7 +168,7 @@ export const currencyFormatterCfa = (val) => {
168
168
  export const notInSequence = (arr) => {
169
169
  const [min, max] = [Math.min(...arr), Math.max(...arr)];
170
170
  // let out = Array.from(Array(max - min), (v, i) => i + min).filter((i) => !arr.includes(i));
171
- return Array.from(Array(max - min), (v, i) => i + min).filter((i) => !arr.includes(i));
171
+ return Array.from(Array(max - min), (v, i) => i + min).filter(i => !arr.includes(i));
172
172
  };
173
173
  export const sequencesToNumbers = (arr) => {
174
174
  const seqs = [];
@@ -452,7 +452,7 @@ export const getPeriodDateColor = (inputDate, period = 30, colors) => {
452
452
  }
453
453
  };
454
454
  export const arrayMultiChecked = (objet, event, item) => {
455
- const findItem = objet.find((x) => x.id === item.id);
455
+ const findItem = objet.find(x => x.id === item.id);
456
456
  event && !findItem ? objet.push(item) : objet.splice(objet.indexOf(findItem), 1);
457
457
  return objet;
458
458
  };
@@ -467,7 +467,7 @@ export const inputChecked = (event, item, checks, isChecked = true) => {
467
467
  };
468
468
  export const unCheckedAll = (checks) => {
469
469
  const checkeds = document.querySelectorAll("input");
470
- checkeds.forEach((el) => {
470
+ checkeds.forEach(el => {
471
471
  if (el.checked) {
472
472
  el.checked = false;
473
473
  }
@@ -603,7 +603,7 @@ export const returnDates = (fromDate, toDate) => {
603
603
  export const absFromSequence = (arr) => {
604
604
  let [min, max] = [Math.min(...arr), Math.max(...arr)];
605
605
  // let out = Array.from(Array(max - min), (v, i) => i + min).filter((i) => !arr.includes(i));
606
- return Array.from(Array(max - min), (v, i) => i + min).filter((i) => !arr.includes(i));
606
+ return Array.from(Array(max - min), (v, i) => i + min).filter(i => !arr.includes(i));
607
607
  };
608
608
  export const fillStartWithZero = (num, targetLength) => {
609
609
  return num.toString().padStart(targetLength, "0");
@@ -664,8 +664,8 @@ export const monthStringName = (date, format = "MMM", options) => {
664
664
  export const countryIsoToFlag = (code) => {
665
665
  return code
666
666
  .split("")
667
- .map((letter) => (letter.charCodeAt(0) % 32) + 0x1f1e5)
668
- .map((n) => String.fromCodePoint(n))
667
+ .map(letter => (letter.charCodeAt(0) % 32) + 0x1f1e5)
668
+ .map(n => String.fromCodePoint(n))
669
669
  .join("");
670
670
  };
671
671
  export const removeParamKeyName = (params, name = "name") => {
@@ -698,14 +698,17 @@ export const winMaxHeight = (step) => {
698
698
  return step ? window.innerHeight * step : window.innerHeight * 0.5;
699
699
  };
700
700
  export const arraySome = (arr1, arr2) => {
701
- return arr1.some((x) => arr2.includes(x));
701
+ return arr1.some(x => arr2.includes(x));
702
702
  };
703
703
  export const checkObjInArray = (objs, checkProp, prop = "id") => {
704
- return objs.some((x) => {
704
+ return objs.some(x => {
705
705
  return x[prop] === checkProp;
706
706
  });
707
707
  };
708
708
  // export const pathUrlName = (location: Location) => {
709
- export const pathUrlName = (location) => {
709
+ export const pathName = (location) => {
710
710
  return location.pathname.substring(location.pathname.lastIndexOf("/") + 1);
711
711
  };
712
+ export const nthIndexOf = (str, charToFind, nthPosition = 1) => {
713
+ return str.split(charToFind, nthPosition).join(charToFind).length;
714
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "asv-hlps",
3
- "version": "1.4.35",
3
+ "version": "1.4.37",
4
4
  "description": "helpers",
5
5
  "main": "./lib/cjs/index.js",
6
6
  "module": "./lib/esm/index.js",