topkat-utils 1.0.60 → 1.1.2

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.
Files changed (102) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/dist/index.d.ts +34 -0
  3. package/dist/index.js +56 -0
  4. package/dist/index.js.map +1 -0
  5. package/dist/src/array-utils.d.ts +56 -0
  6. package/dist/src/array-utils.js +138 -0
  7. package/dist/src/array-utils.js.map +1 -0
  8. package/dist/src/date-utils.d.ts +100 -0
  9. package/dist/src/date-utils.js +357 -0
  10. package/dist/src/date-utils.js.map +1 -0
  11. package/dist/src/env-utils.d.ts +8 -0
  12. package/dist/src/env-utils.js +38 -0
  13. package/dist/src/env-utils.js.map +1 -0
  14. package/dist/src/error-utils.d.ts +8 -0
  15. package/dist/src/error-utils.js +99 -0
  16. package/dist/src/error-utils.js.map +1 -0
  17. package/dist/src/is-empty.d.ts +1 -0
  18. package/dist/src/is-empty.js +13 -0
  19. package/dist/src/is-empty.js.map +1 -0
  20. package/dist/src/is-object.d.ts +2 -0
  21. package/dist/src/is-object.js +7 -0
  22. package/dist/src/is-object.js.map +1 -0
  23. package/dist/src/isset.d.ts +1 -0
  24. package/dist/src/isset.js +8 -0
  25. package/dist/src/isset.js.map +1 -0
  26. package/dist/src/logger-utils.d.ts +76 -0
  27. package/dist/src/logger-utils.js +355 -0
  28. package/dist/src/logger-utils.js.map +1 -0
  29. package/dist/src/loop-utils.d.ts +37 -0
  30. package/dist/src/loop-utils.js +105 -0
  31. package/dist/src/loop-utils.js.map +1 -0
  32. package/dist/src/math-utils.d.ts +23 -0
  33. package/dist/src/math-utils.js +43 -0
  34. package/dist/src/math-utils.js.map +1 -0
  35. package/dist/src/mongo-utils.d.ts +11 -0
  36. package/dist/src/mongo-utils.js +49 -0
  37. package/dist/src/mongo-utils.js.map +1 -0
  38. package/dist/src/object-utils.d.ts +96 -0
  39. package/dist/src/object-utils.js +369 -0
  40. package/dist/src/object-utils.js.map +1 -0
  41. package/dist/src/private/config.d.ts +44 -0
  42. package/dist/src/private/config.js +55 -0
  43. package/dist/src/private/config.js.map +1 -0
  44. package/dist/src/private/error-handler.d.ts +10 -0
  45. package/dist/src/private/error-handler.js +18 -0
  46. package/dist/src/private/error-handler.js.map +1 -0
  47. package/dist/src/private/types.d.ts +4 -0
  48. package/dist/src/private/types.js +3 -0
  49. package/dist/src/private/types.js.map +1 -0
  50. package/dist/src/regexp-utils.d.ts +12 -0
  51. package/dist/src/regexp-utils.js +44 -0
  52. package/dist/src/regexp-utils.js.map +1 -0
  53. package/dist/src/remove-circular-json-stringify.d.ts +1 -0
  54. package/dist/src/remove-circular-json-stringify.js +20 -0
  55. package/dist/src/remove-circular-json-stringify.js.map +1 -0
  56. package/dist/src/string-utils.d.ts +77 -0
  57. package/dist/src/string-utils.js +209 -0
  58. package/dist/src/string-utils.js.map +1 -0
  59. package/dist/src/tests-utils.js +77 -0
  60. package/dist/src/tests-utils.js.map +1 -0
  61. package/dist/src/timer-utils.d.ts +16 -0
  62. package/dist/src/timer-utils.js +79 -0
  63. package/dist/src/timer-utils.js.map +1 -0
  64. package/dist/src/transaction-utils.d.ts +14 -0
  65. package/dist/src/transaction-utils.js +87 -0
  66. package/dist/src/transaction-utils.js.map +1 -0
  67. package/dist/src/validation-utils.d.ts +89 -0
  68. package/dist/src/validation-utils.js +192 -0
  69. package/dist/src/validation-utils.js.map +1 -0
  70. package/dist/src/wtf-utils.d.ts +7 -0
  71. package/dist/src/wtf-utils.js +83 -0
  72. package/dist/src/wtf-utils.js.map +1 -0
  73. package/index.ts +38 -0
  74. package/package.json +2 -2
  75. package/src/array-utils.ts +128 -0
  76. package/src/date-utils.ts +377 -0
  77. package/src/env-utils.ts +29 -0
  78. package/src/error-utils.ts +77 -0
  79. package/src/is-empty.ts +5 -0
  80. package/src/is-object.ts +3 -0
  81. package/src/isset.ts +3 -0
  82. package/src/logger-utils.ts +349 -0
  83. package/src/loop-utils.ts +101 -0
  84. package/src/math-utils.ts +38 -0
  85. package/src/mongo-utils.ts +38 -0
  86. package/src/object-utils.ts +356 -0
  87. package/src/private/config.ts +85 -0
  88. package/src/private/error-handler.ts +21 -0
  89. package/src/private/types.ts +6 -0
  90. package/src/regexp-utils.ts +37 -0
  91. package/src/remove-circular-json-stringify.ts +17 -0
  92. package/src/string-utils.ts +212 -0
  93. package/src/tests-utils.ts +70 -0
  94. package/src/timer-utils.ts +58 -0
  95. package/src/transaction-utils.ts +63 -0
  96. package/src/validation-utils.ts +253 -0
  97. package/src/wtf-utils.ts +88 -0
  98. package/tsconfig.json +11 -4
  99. package/utils.d.ts +0 -694
  100. package/utils.js +0 -2227
  101. package/utils.js.map +0 -1
  102. package/utils.ts +0 -2304
package/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ### v1.1.1
2
+ * test OK
3
+ * NEW WTF utils removed circular dependencies
4
+
1
5
  ### v1.0.58
2
6
  * BREAKING remove export default
3
7
 
@@ -0,0 +1,34 @@
1
+ export * from './src/array-utils';
2
+ export * from './src/date-utils';
3
+ export * from './src/env-utils';
4
+ export * from './src/error-utils';
5
+ export * from './src/isset';
6
+ export * from './src/logger-utils';
7
+ export * from './src/loop-utils';
8
+ export * from './src/math-utils';
9
+ export * from './src/mongo-utils';
10
+ export * from './src/object-utils';
11
+ export * from './src/string-utils';
12
+ export * from './src/wtf-utils';
13
+ export * from './src/validation-utils';
14
+ export * from './src/transaction-utils';
15
+ export * from './src/timer-utils';
16
+ export * from './src/is-empty';
17
+ export * from './src/remove-circular-json-stringify';
18
+ export * from './src/is-object';
19
+ export { registerConfig } from 'src/private/config';
20
+ import { moyenne } from 'src/math-utils';
21
+ import { kebabCase, snakeCase } from 'src/string-utils';
22
+ import { shuffleArray, noDuplicateFilter } from 'src/array-utils';
23
+ import { issetOr, validator } from 'src/validation-utils';
24
+ import { objFilterUndefinedRecursive } from 'src/object-utils';
25
+ export declare const int: typeof parseInt;
26
+ export declare const average: typeof moyenne;
27
+ export declare const arrayUniqueValue: typeof noDuplicateFilter;
28
+ export declare const JSONstringyParse: (o: any) => any;
29
+ export declare const removeUndefinedKeys: typeof objFilterUndefinedRecursive;
30
+ export declare const randomizeArray: typeof shuffleArray;
31
+ export declare const dashCase: typeof kebabCase;
32
+ export declare const underscoreCase: typeof snakeCase;
33
+ export declare const required: typeof validator;
34
+ export declare const orIsset: typeof issetOr;
package/dist/index.js ADDED
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.orIsset = exports.required = exports.underscoreCase = exports.dashCase = exports.randomizeArray = exports.removeUndefinedKeys = exports.JSONstringyParse = exports.arrayUniqueValue = exports.average = exports.int = exports.registerConfig = void 0;
18
+ __exportStar(require("./src/array-utils"), exports);
19
+ __exportStar(require("./src/date-utils"), exports);
20
+ __exportStar(require("./src/env-utils"), exports);
21
+ __exportStar(require("./src/error-utils"), exports);
22
+ __exportStar(require("./src/isset"), exports);
23
+ __exportStar(require("./src/logger-utils"), exports);
24
+ __exportStar(require("./src/loop-utils"), exports);
25
+ __exportStar(require("./src/math-utils"), exports);
26
+ __exportStar(require("./src/mongo-utils"), exports);
27
+ __exportStar(require("./src/object-utils"), exports);
28
+ __exportStar(require("./src/string-utils"), exports);
29
+ __exportStar(require("./src/wtf-utils"), exports);
30
+ __exportStar(require("./src/validation-utils"), exports);
31
+ __exportStar(require("./src/transaction-utils"), exports);
32
+ __exportStar(require("./src/timer-utils"), exports);
33
+ __exportStar(require("./src/is-empty"), exports);
34
+ __exportStar(require("./src/remove-circular-json-stringify"), exports);
35
+ __exportStar(require("./src/is-object"), exports);
36
+ var config_1 = require("./src/private/config");
37
+ Object.defineProperty(exports, "registerConfig", { enumerable: true, get: function () { return config_1.registerConfig; } });
38
+ const math_utils_1 = require("./src/math-utils");
39
+ const string_utils_1 = require("./src/string-utils");
40
+ const array_utils_1 = require("./src/array-utils");
41
+ const validation_utils_1 = require("./src/validation-utils");
42
+ const object_utils_1 = require("./src/object-utils");
43
+ const remove_circular_json_stringify_1 = require("./src/remove-circular-json-stringify");
44
+ // ALIASES
45
+ exports.int = parseInt;
46
+ exports.average = math_utils_1.moyenne;
47
+ exports.arrayUniqueValue = array_utils_1.noDuplicateFilter;
48
+ const JSONstringyParse = o => JSON.parse((0, remove_circular_json_stringify_1.removeCircularJSONstringify)(o));
49
+ exports.JSONstringyParse = JSONstringyParse;
50
+ exports.removeUndefinedKeys = object_utils_1.objFilterUndefinedRecursive;
51
+ exports.randomizeArray = array_utils_1.shuffleArray;
52
+ exports.dashCase = string_utils_1.kebabCase;
53
+ exports.underscoreCase = string_utils_1.snakeCase;
54
+ exports.required = validation_utils_1.validator; // alias for readability
55
+ exports.orIsset = validation_utils_1.issetOr;
56
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,oDAAiC;AACjC,mDAAgC;AAChC,kDAA+B;AAC/B,oDAAiC;AACjC,8CAA2B;AAC3B,qDAAkC;AAClC,mDAAgC;AAChC,mDAAgC;AAChC,oDAAiC;AACjC,qDAAkC;AAClC,qDAAkC;AAClC,kDAA+B;AAC/B,yDAAsC;AACtC,0DAAuC;AACvC,oDAAiC;AACjC,iDAA8B;AAC9B,uEAAoD;AACpD,kDAA+B;AAC/B,+CAAqD;AAA5C,wGAAA,cAAc,OAAA;AAEvB,iDAA0C;AAC1C,qDAAyD;AACzD,mDAAmE;AACnE,6DAA2D;AAC3D,qDAAgE;AAChE,yFAAkF;AAElF,UAAU;AACG,QAAA,GAAG,GAAG,QAAQ,CAAA;AACd,QAAA,OAAO,GAAG,oBAAO,CAAA;AACjB,QAAA,gBAAgB,GAAG,+BAAiB,CAAA;AAC1C,MAAM,gBAAgB,GAAG,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,IAAA,4DAA2B,EAAC,CAAC,CAAC,CAAC,CAAA;AAAlE,QAAA,gBAAgB,oBAAkD;AAClE,QAAA,mBAAmB,GAAG,0CAA2B,CAAA;AACjD,QAAA,cAAc,GAAG,0BAAY,CAAA;AAC7B,QAAA,QAAQ,GAAG,wBAAS,CAAA;AACpB,QAAA,cAAc,GAAG,wBAAS,CAAA;AAC1B,QAAA,QAAQ,GAAG,4BAAS,CAAA,CAAC,wBAAwB;AAC7C,QAAA,OAAO,GAAG,0BAAO,CAAA"}
@@ -0,0 +1,56 @@
1
+ export declare function shuffleArray(array: any): any;
2
+ /**
3
+ * Maye sure obj[addr] is an array and push a value to it
4
+ * @param {Object} obj parent object
5
+ * @param {String} addr field name in parent
6
+ * @param {Any} valToPush
7
+ * @param {Boolean} onlyUniqueValues default:false; may be true or a comparision function; (a,b) => return true if they are the same like (a, b) => a.name === b.name
8
+ * @return obj[addr] eventually processed by the callback
9
+ */
10
+ export declare function ensureIsArrayAndPush(obj: object, addr: string, valToPush: any, onlyUniqueValues: Function): any;
11
+ /** If a string is provided, return it as array else return the value */
12
+ export declare function strAsArray(arrOrStr: any): any;
13
+ /** If not an array provided, return the array with the value
14
+ * /!\ NOTE /!\ In case the value is null or undefined, it will return that value
15
+ */
16
+ export declare function asArray<T extends any[] | any>(item: T): T extends undefined ? undefined : T extends any[] ? T : T[];
17
+ /** Array comparison
18
+ * @return {object} { inCommon, notInB, notInA }
19
+ */
20
+ export declare function compareArrays(arrayA: any[], arrayB: any[], compare?: (a: any, b: any) => boolean): {
21
+ inCommon: any[];
22
+ notInB: any[];
23
+ notInA: any[];
24
+ };
25
+ /**
26
+ * @return [] only elements that are both in arrayA and arrayB
27
+ */
28
+ export declare function getArrayInCommon(arrayA?: any[], arrayB?: any[], compare?: (a: any, b: any) => boolean): any[];
29
+ /**
30
+ * @return [] only elements that are in arrayB and not in arrayA
31
+ */
32
+ export declare function getNotInArrayA(arrayA?: any[], arrayB?: any[], compare?: (a: any, b: any) => boolean): any[];
33
+ /**
34
+ * @return [] only elements that are in neither arrayA and arrayB
35
+ */
36
+ export declare function getArrayDiff(arrayA?: any[], arrayB?: any[], compare?: (a: any, b: any) => boolean): any[];
37
+ /** filter duplicate values in an array
38
+ * @param {function} comparisonFn default:(a, b) => a === b. A function that shall return true if two values are considered equal
39
+ * @return {array|function}
40
+ */
41
+ export declare function noDuplicateFilter(arr: any, comparisonFn?: (a: any, b: any) => boolean): any[];
42
+ /** Count number of occurence of item in array */
43
+ export declare function arrayCount(item: any, arr: any[]): number;
44
+ /**
45
+ * Sort an array in an object of subArrays, no duplicate.
46
+ * @param {Array} array
47
+ * @param {function} getFieldFromItem (itemOfArray) => field[String|Number]
48
+ * tell me how you want to sort your Array
49
+ */
50
+ export declare function arrayToObjectSorted(array: any, getFieldFromItem: any): {};
51
+ /**
52
+ * @param {Function} comparisonFunction default: (itemToPush, itemAlreadyInArray) => itemToPush === itemAlreadyInArray; comparison function to consider the added item duplicate
53
+ */
54
+ export declare function pushIfNotExist(arrayToPushInto: any, valueOrArrayOfValuesToBePushed: any, comparisonFunction?: (a: any, b: any) => boolean): any[];
55
+ export declare function isNotEmptyArray(arr: any): boolean;
56
+ export declare function randomItemInArray<T>(array: T[]): T;
@@ -0,0 +1,138 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.randomItemInArray = exports.isNotEmptyArray = exports.pushIfNotExist = exports.arrayToObjectSorted = exports.arrayCount = exports.noDuplicateFilter = exports.getArrayDiff = exports.getNotInArrayA = exports.getArrayInCommon = exports.compareArrays = exports.asArray = exports.strAsArray = exports.ensureIsArrayAndPush = exports.shuffleArray = void 0;
4
+ //----------------------------------------
5
+ // ARRAY UTILS
6
+ //----------------------------------------
7
+ const object_utils_1 = require("./object-utils");
8
+ const isset_1 = require("./isset");
9
+ function shuffleArray(array) {
10
+ for (let i = array.length - 1; i > 0; i--) {
11
+ const j = Math.floor(Math.random() * (i + 1));
12
+ [array[i], array[j]] = [array[j], array[i]];
13
+ }
14
+ return array;
15
+ }
16
+ exports.shuffleArray = shuffleArray;
17
+ /**
18
+ * Maye sure obj[addr] is an array and push a value to it
19
+ * @param {Object} obj parent object
20
+ * @param {String} addr field name in parent
21
+ * @param {Any} valToPush
22
+ * @param {Boolean} onlyUniqueValues default:false; may be true or a comparision function; (a,b) => return true if they are the same like (a, b) => a.name === b.name
23
+ * @return obj[addr] eventually processed by the callback
24
+ */
25
+ function ensureIsArrayAndPush(obj, addr, valToPush, onlyUniqueValues) {
26
+ return (0, object_utils_1.ensureObjectProp)(obj, addr, [], objValue => {
27
+ if ((0, isset_1.isset)(onlyUniqueValues)) {
28
+ let duplicateFound = false;
29
+ if (typeof onlyUniqueValues === 'function')
30
+ duplicateFound = objValue.some(a => onlyUniqueValues(a, valToPush));
31
+ else
32
+ duplicateFound = objValue.includes(valToPush);
33
+ if (!duplicateFound)
34
+ objValue.push(valToPush);
35
+ }
36
+ else
37
+ objValue.push(valToPush);
38
+ });
39
+ }
40
+ exports.ensureIsArrayAndPush = ensureIsArrayAndPush;
41
+ /** If a string is provided, return it as array else return the value */
42
+ function strAsArray(arrOrStr) {
43
+ return typeof arrOrStr === 'string' ? [arrOrStr] : arrOrStr;
44
+ }
45
+ exports.strAsArray = strAsArray;
46
+ /** If not an array provided, return the array with the value
47
+ * /!\ NOTE /!\ In case the value is null or undefined, it will return that value
48
+ */
49
+ function asArray(item) {
50
+ return (typeof item === 'undefined' ? item : Array.isArray(item) ? item : [item]);
51
+ }
52
+ exports.asArray = asArray;
53
+ /** Array comparison
54
+ * @return {object} { inCommon, notInB, notInA }
55
+ */
56
+ function compareArrays(arrayA, arrayB, compare = (a, b) => a === b) {
57
+ return {
58
+ inCommon: getArrayInCommon(arrayA, arrayB, compare),
59
+ notInB: getNotInArrayA(arrayB, arrayA, compare),
60
+ notInA: getNotInArrayA(arrayA, arrayB, compare),
61
+ };
62
+ }
63
+ exports.compareArrays = compareArrays;
64
+ /**
65
+ * @return [] only elements that are both in arrayA and arrayB
66
+ */
67
+ function getArrayInCommon(arrayA = [], arrayB = [], compare = (a, b) => a === b) {
68
+ if (!Array.isArray(arrayA) || !Array.isArray(arrayB))
69
+ return [];
70
+ else
71
+ return arrayA.filter(a => arrayB.some(b => compare(a, b)));
72
+ }
73
+ exports.getArrayInCommon = getArrayInCommon;
74
+ /**
75
+ * @return [] only elements that are in arrayB and not in arrayA
76
+ */
77
+ function getNotInArrayA(arrayA = [], arrayB = [], compare = (a, b) => a === b) {
78
+ if (!Array.isArray(arrayA) && Array.isArray(arrayB))
79
+ return arrayB;
80
+ else if (!Array.isArray(arrayB))
81
+ return [];
82
+ else
83
+ return arrayB.filter(b => !arrayA.some(a => compare(a, b)));
84
+ }
85
+ exports.getNotInArrayA = getNotInArrayA;
86
+ /**
87
+ * @return [] only elements that are in neither arrayA and arrayB
88
+ */
89
+ function getArrayDiff(arrayA = [], arrayB = [], compare = (a, b) => a === b) {
90
+ return [...getNotInArrayA(arrayA, arrayB, compare), ...getNotInArrayA(arrayB, arrayA, compare)];
91
+ }
92
+ exports.getArrayDiff = getArrayDiff;
93
+ /** filter duplicate values in an array
94
+ * @param {function} comparisonFn default:(a, b) => a === b. A function that shall return true if two values are considered equal
95
+ * @return {array|function}
96
+ */
97
+ function noDuplicateFilter(arr, comparisonFn = (a, b) => a === b) {
98
+ return arr.filter((a, i, arr) => arr.findIndex(b => comparisonFn(a, b)) === i);
99
+ }
100
+ exports.noDuplicateFilter = noDuplicateFilter;
101
+ /** Count number of occurence of item in array */
102
+ function arrayCount(item, arr) {
103
+ return arr.reduce((total, item2) => item === item2 ? total + 1 : total, 0);
104
+ }
105
+ exports.arrayCount = arrayCount;
106
+ /**
107
+ * Sort an array in an object of subArrays, no duplicate.
108
+ * @param {Array} array
109
+ * @param {function} getFieldFromItem (itemOfArray) => field[String|Number]
110
+ * tell me how you want to sort your Array
111
+ */
112
+ function arrayToObjectSorted(array, getFieldFromItem) {
113
+ const res = {};
114
+ array.forEach(item => {
115
+ (0, object_utils_1.objForceWriteIfNotSet)(res, getFieldFromItem(item), []);
116
+ res[getFieldFromItem(item)].push(item);
117
+ });
118
+ return res;
119
+ }
120
+ exports.arrayToObjectSorted = arrayToObjectSorted;
121
+ /**
122
+ * @param {Function} comparisonFunction default: (itemToPush, itemAlreadyInArray) => itemToPush === itemAlreadyInArray; comparison function to consider the added item duplicate
123
+ */
124
+ function pushIfNotExist(arrayToPushInto, valueOrArrayOfValuesToBePushed, comparisonFunction = (a, b) => a === b) {
125
+ const valuesToPush = asArray(valueOrArrayOfValuesToBePushed).filter(a => !arrayToPushInto.some(b => comparisonFunction(a, b)));
126
+ arrayToPushInto.push(...valuesToPush);
127
+ return arrayToPushInto;
128
+ }
129
+ exports.pushIfNotExist = pushIfNotExist;
130
+ function isNotEmptyArray(arr) {
131
+ return Array.isArray(arr) && !!arr.length;
132
+ }
133
+ exports.isNotEmptyArray = isNotEmptyArray;
134
+ function randomItemInArray(array) {
135
+ return array[Math.floor(Math.random() * array.length)];
136
+ }
137
+ exports.randomItemInArray = randomItemInArray;
138
+ //# sourceMappingURL=array-utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"array-utils.js","sourceRoot":"","sources":["../../src/array-utils.ts"],"names":[],"mappings":";;;AAAA,0CAA0C;AAC1C,cAAc;AACd,0CAA0C;AAC1C,iDAAwE;AACxE,mCAA+B;AAE/B,S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BAAiB,CAAI,KAAU;IAC3C,OAAO,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,CAAA;AAC1D,CAAC;AAFD,8CAEC"}
@@ -0,0 +1,100 @@
1
+ export declare function getDateAsInt12(dateAllFormat?: Date | string | number, errIfNotValid?: any): string;
2
+ export declare function humanReadableTimestamp(dateAllFormat: any): number;
3
+ /** format for 6/8/2018 => 20180806
4
+ * @param dateAllFormat multiple format allowed 2012, 20120101, 201201011200, new Date(), "2019-12-08T16:19:10.341Z" and all string that new Date() can parse
5
+ */
6
+ export declare function getDateAsInt(dateAllFormat?: Date | string | number, errIfNotValid$?: boolean, withHoursAndMinutes$?: boolean): string;
7
+ export declare function getMonthAsInt(dateAllFormat?: Date | string | number): number;
8
+ /**
9
+ * @param dateAllFormat multiple format allowed 2012, 20120101, 201201011200, new Date(), "2019-12-08T16:19:10.341Z" and all string that new Date() can parse
10
+ */
11
+ export declare function getDateAsObject(dateAllFormat?: any, errIfNotValid$?: boolean): Date;
12
+ /** [2018,01,06] */
13
+ export declare function dateStringToArray(strOrInt: any): any[];
14
+ /**
15
+ * @param dateAllFormat default: actualDate
16
+ * @returns ['01', '01', '2019'] OR **string** if separator is provided */
17
+ export declare function dateArray(dateAllFormat?: Date | string | number): [string, string, string];
18
+ /**
19
+ * @param dateAllFormat default: actualDate
20
+ * @returns ['01', '01', '2019'] OR **string** if separator is provided */
21
+ export declare function dateArrayInt(dateAllFormat?: Date | string | number): [number, number, number];
22
+ /**
23
+ * @return 01/01/2012 (alias of dateArrayFormatted(date, '/'))
24
+ */
25
+ export declare function dateFormatted(dateAllFormat: Date | string | number, separator?: string): string;
26
+ /** Date with custom offset (Ex: +2 for France) */
27
+ export declare function dateOffset(offsetHours: any, dateObj?: Date): Date;
28
+ /** */
29
+ export declare function getTimeAsInt(timeOrDateInt?: any): number | "dateInvalid";
30
+ /**
31
+ * @param {timeInt|dateInt12} Eg: 2222 OR 201201012222. Default, actual dateInt12
32
+ * @param {String} separator default: ":"
33
+ */
34
+ export declare function getIntAsTime(intOrDateTimeInt?: string, separator?: string): string;
35
+ export declare function isTimeStringValid(timeStr: any, outputAnError$?: boolean): boolean;
36
+ export declare function getDuration(startDate: any, endDate: any, inMinutes?: boolean): number | number[];
37
+ /** compare two object with DATE INT, if they overlap return true
38
+ * @param {Object} event1 {startDate, endDate}
39
+ * @param {Object} event2 {startDate, endDate}
40
+ * @param {String} fieldNameForStartDate$ replace startDate with this string
41
+ * @param {String} fieldNameForEndDate$ replace endDate with this string
42
+ * @param {Boolean} allowNull$ if false, retrun false if any of the startdates or enddates are not set
43
+ * @param {Boolean} strict$ if true,
44
+ */
45
+ export declare function doDateOverlap(event1: any, event2: any, fieldNameForStartDate$?: string, fieldNameForEndDate$?: string, allowNull$?: boolean, strict$?: boolean): boolean;
46
+ declare type DateAllFormat = DateObjectFormat | DateStringFormats;
47
+ declare type DateStringFormats = 'dateInt8' | 'dateInt12' | 'humanReadableTimestamp';
48
+ declare type DateObjectFormat = 'date';
49
+ export declare function nextWeekDay(fromDate: any, weekDayInt?: 0 | 1 | 2 | 3 | 4 | 5 | 6, outputFormat?: DateStringFormats, sameDayAllowed?: boolean): number;
50
+ export declare function nextWeekDay(fromDate: any, weekDayInt?: 0 | 1 | 2 | 3 | 4 | 5 | 6, outputFormat?: DateObjectFormat, sameDayAllowed?: boolean): Date;
51
+ /**
52
+ * @param {String} outputFormat dateInt, dateInt8, dateInt12, date, humanReadableTimestamp, int (dateInt8)
53
+ */
54
+ export declare function addDays(dateAllFormat?: Date | string | number, numberOfDays?: number, outputFormat?: 'dateInt8' | 'dateInt12' | 'humanReadableTimestamp'): string;
55
+ export declare function addDays(dateAllFormat?: Date | string | number, numberOfDays?: number, outputFormat?: 'date'): Date;
56
+ /**
57
+ * @param {String} outputFormat dateInt, dateInt8, dateInt12, date, humanReadableTimestamp, int (dateInt8)
58
+ */
59
+ export declare function addMinutes(dateAllFormat?: Date | string | number, numberOfMinutes?: number, outputFormat?: DateStringFormats): string;
60
+ export declare function addMinutes(dateAllFormat?: Date | string | number, numberOfMinutes?: number, outputFormat?: DateObjectFormat): Date;
61
+ /**
62
+ * @param {String} outputFormat dateInt, dateInt8, dateInt12, date, humanReadableTimestamp, int (dateInt8)
63
+ */
64
+ export declare function addHours(dateAllFormat?: Date | string | number, numberOfHours?: number, outputFormat?: 'dateInt8' | 'dateInt12' | 'humanReadableTimestamp'): string;
65
+ export declare function addHours(dateAllFormat?: Date | string | number, numberOfHours?: number, outputFormat?: 'date'): Date;
66
+ /**
67
+ * @param {String} outputFormat dateInt, dateInt8, dateInt12, date, humanReadableTimestamp, int (dateInt8)
68
+ */
69
+ export declare function addMonths(dateAllFormat?: Date | string | number, numberOfMonths?: number, outputFormat?: 'dateInt8' | 'dateInt12' | 'humanReadableTimestamp'): string;
70
+ export declare function addMonths(dateAllFormat?: Date | string | number, numberOfMonths?: number, outputFormat?: 'date'): Date;
71
+ /**
72
+ * @param {String} outputFormat dateInt, dateInt8, dateInt12, date, humanReadableTimestamp, int (dateInt8)
73
+ */
74
+ export declare function addYears(dateAllFormat?: Date | string | number, numberOfYears?: number, outputFormat?: DateAllFormat): Date;
75
+ export declare function getDayOfMonth(dateAllFormat?: Date | string | number): any;
76
+ export declare function getYear(dateAllFormat?: Date | string | number): any;
77
+ export declare function getHours(dateAllFormat?: Date | string | number): any;
78
+ export declare function getMinutes(dateAllFormat?: Date | string | number): any;
79
+ /**
80
+ * @param {String} outputFormat dateInt, dateInt8, dateInt12, date, humanReadableTimestamp, int (dateInt8)
81
+ */
82
+ export declare function lastDayOfMonth(dateAllFormat?: Date | string | number, outputFormat?: DateAllFormat): Date;
83
+ /**
84
+ * @param {String} outputFormat dateInt, dateInt8, dateInt12, date, humanReadableTimestamp, int (dateInt8)
85
+ */
86
+ export declare function firstDayOfMonth(dateAllFormat?: Date | string | number, outputFormat?: DateAllFormat): Date;
87
+ export declare function differenceInMilliseconds(startDateAllFormat: any, endDateAllFormat: any): number;
88
+ export declare function differenceInSeconds(startDateAllFormat: any, endDateAllFormat: any): number;
89
+ export declare function differenceInMinutes(startDateAllFormat: any, endDateAllFormat: any): number;
90
+ export declare function differenceInHours(startDateAllFormat: any, endDateAllFormat: any): number;
91
+ export declare function differenceInDays(startDateAllFormat: any, endDateAllFormat: any): number;
92
+ export declare function differenceInWeeks(startDateAllFormat: any, endDateAllFormat: any): number;
93
+ /**
94
+ * @param {String} outputDateFormat dateInt, dateInt8, dateInt12, date, humanReadableTimestamp, int (dateInt8)
95
+ */
96
+ export declare function getDateAs(dateAllFormat?: Date | string | number, outputFormat?: 'dateInt8' | 'dateInt12' | 'humanReadableTimestamp'): string;
97
+ export declare function getDateAs(dateAllFormat?: Date | string | number, outputFormat?: 'date'): Date;
98
+ export declare function isDateIntOrStringValid(dateStringOrInt: any, outputAnError?: boolean, length?: any): boolean;
99
+ export declare function isDateIsoOrObjectValid(dateIsoOrObj: any, outputAnError?: boolean): boolean;
100
+ export {};