danholibraryjs 1.11.0 → 2.0.0

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 (204) hide show
  1. package/dist/Classes/DanhoLogger.d.ts +23 -0
  2. package/dist/Classes/DanhoLogger.js +65 -0
  3. package/dist/Classes/Events/Event.d.ts +66 -66
  4. package/dist/Classes/Events/Event.js +114 -114
  5. package/dist/Classes/Events/EventCollection.d.ts +57 -57
  6. package/dist/Classes/Events/EventCollection.js +109 -109
  7. package/dist/Classes/Events/EventEmitter.d.ts +74 -74
  8. package/dist/Classes/Events/EventEmitter.js +97 -97
  9. package/dist/Classes/Events/index.d.ts +3 -3
  10. package/dist/Classes/Events/index.js +19 -19
  11. package/dist/Classes/Time/Date.d.ts +148 -147
  12. package/dist/Classes/Time/Date.js +241 -238
  13. package/dist/Classes/Time/Time.d.ts +66 -65
  14. package/dist/Classes/Time/Time.js +120 -117
  15. package/dist/Classes/Time/TimeProperties.d.ts +3 -3
  16. package/dist/Classes/Time/TimeProperties.js +2 -2
  17. package/dist/Classes/Time/TimeSpan.d.ts +123 -123
  18. package/dist/Classes/Time/TimeSpan.js +179 -179
  19. package/dist/Classes/Time/index.d.ts +4 -4
  20. package/dist/Classes/Time/index.js +20 -20
  21. package/dist/Classes/index.d.ts +4 -3
  22. package/dist/Classes/index.js +20 -19
  23. package/dist/Classes/store.d.ts +75 -75
  24. package/dist/Classes/store.js +84 -84
  25. package/dist/Extensions/Array/array.extension.d.ts +42 -0
  26. package/dist/Extensions/Array/array.extension.js +57 -0
  27. package/dist/Extensions/Array/crud.extension.d.ts +24 -0
  28. package/dist/Extensions/Array/crud.extension.js +28 -0
  29. package/dist/Extensions/Array/index.d.ts +20 -0
  30. package/dist/Extensions/Array/index.js +40 -0
  31. package/dist/Extensions/Array/loop.extension.d.ts +18 -0
  32. package/dist/Extensions/Array/loop.extension.js +23 -0
  33. package/dist/Extensions/Array/random.extension.d.ts +23 -0
  34. package/dist/Extensions/Array/random.extension.js +35 -0
  35. package/dist/Extensions/Array/sort.extension.d.ts +27 -0
  36. package/dist/Extensions/Array/sort.extension.js +31 -0
  37. package/dist/Extensions/Array/string.extension.d.ts +13 -0
  38. package/dist/Extensions/Array/string.extension.js +14 -0
  39. package/dist/Extensions/Array.d.ts +52 -52
  40. package/dist/Extensions/Array.js +51 -51
  41. package/dist/Extensions/Document.d.ts +27 -27
  42. package/dist/Extensions/Document.js +32 -32
  43. package/dist/Extensions/Function.d.ts +29 -14
  44. package/dist/Extensions/Function.js +23 -10
  45. package/dist/Extensions/Map.d.ts +54 -54
  46. package/dist/Extensions/Map.js +42 -42
  47. package/dist/Extensions/Number.d.ts +13 -0
  48. package/dist/Extensions/Number.js +40 -0
  49. package/dist/Extensions/Object/arrays.extension.d.ts +17 -0
  50. package/dist/Extensions/Object/arrays.extension.js +13 -0
  51. package/dist/Extensions/Object/booleans.extension.d.ts +18 -0
  52. package/dist/Extensions/Object/booleans.extension.js +37 -0
  53. package/dist/Extensions/Object/extracts.extension.d.ts +38 -0
  54. package/dist/Extensions/Object/extracts.extension.js +72 -0
  55. package/dist/Extensions/Object/index.d.ts +10 -49
  56. package/dist/Extensions/Object/index.js +36 -38
  57. package/dist/Extensions/Object/properties.d.ts +28 -28
  58. package/dist/Extensions/Object/properties.extension.d.ts +6 -0
  59. package/dist/Extensions/Object/properties.extension.js +4 -0
  60. package/dist/Extensions/Object/properties.js +19 -20
  61. package/dist/Extensions/String/case.extension.d.ts +12 -0
  62. package/dist/Extensions/String/case.extension.js +55 -0
  63. package/dist/Extensions/String/index.d.ts +4 -0
  64. package/dist/Extensions/String/index.js +30 -0
  65. package/dist/Extensions/String.d.ts +36 -36
  66. package/dist/Extensions/String.js +25 -25
  67. package/dist/Extensions/index.d.ts +6 -17
  68. package/dist/Extensions/index.js +22 -30
  69. package/dist/Functions/CopyToClipboard.d.ts +7 -7
  70. package/dist/Functions/CopyToClipboard.js +15 -15
  71. package/dist/Functions/GetCSSProperty.d.ts +15 -15
  72. package/dist/Functions/GetCSSProperty.js +26 -26
  73. package/dist/Functions/GetNestedProperty.d.ts +9 -9
  74. package/dist/Functions/GetNestedProperty.js +23 -23
  75. package/dist/Functions/HTMLEvent.d.ts +11 -11
  76. package/dist/Functions/HTMLEvent.js +14 -14
  77. package/dist/Functions/SetNavigationSelected.d.ts +9 -9
  78. package/dist/Functions/SetNavigationSelected.js +25 -25
  79. package/dist/Functions/index.d.ts +5 -5
  80. package/dist/Functions/index.js +21 -21
  81. package/dist/Interfaces/ElementOptions.d.ts +15 -15
  82. package/dist/Interfaces/ElementOptions.js +2 -2
  83. package/dist/Interfaces/IReplacement.d.ts +12 -12
  84. package/dist/Interfaces/IReplacement.js +2 -2
  85. package/dist/Interfaces/index.d.ts +2 -2
  86. package/dist/Interfaces/index.js +18 -18
  87. package/dist/Types/Able.d.ts +16 -0
  88. package/dist/Types/Able.js +2 -0
  89. package/dist/Types/Array.d.ts +6 -0
  90. package/dist/Types/Array.js +2 -0
  91. package/dist/Types/BetterTypes.d.ts +9 -9
  92. package/dist/Types/BetterTypes.js +2 -2
  93. package/dist/Types/C#.d.ts +8 -0
  94. package/dist/Types/C#.js +2 -0
  95. package/dist/Types/Date.d.ts +6 -6
  96. package/dist/Types/Date.js +2 -2
  97. package/dist/Types/Events.d.ts +10 -10
  98. package/dist/Types/Events.js +2 -2
  99. package/dist/Types/Function.d.ts +5 -0
  100. package/dist/Types/Function.js +2 -0
  101. package/dist/Types/Object.d.ts +4 -0
  102. package/dist/Types/Object.js +2 -0
  103. package/dist/Types/PropertiesWith.d.ts +34 -13
  104. package/dist/Types/PropertiesWith.js +2 -2
  105. package/dist/Types/String.d.ts +1 -0
  106. package/dist/Types/String.js +2 -0
  107. package/dist/Types/TransformTypes.d.ts +22 -16
  108. package/dist/Types/TransformTypes.js +2 -2
  109. package/dist/Types/index.d.ts +24 -65
  110. package/dist/Types/index.js +27 -21
  111. package/dist/Utils/ApiUtil/ApiTypes.d.ts +15 -15
  112. package/dist/Utils/ApiUtil/ApiTypes.js +15 -15
  113. package/dist/Utils/ApiUtil/RequestUtil.d.ts +19 -19
  114. package/dist/Utils/ApiUtil/RequestUtil.js +73 -73
  115. package/dist/Utils/ApiUtil/index.d.ts +20 -20
  116. package/dist/Utils/ApiUtil/index.js +33 -33
  117. package/dist/Utils/ApiUtils/ApiTypes.d.ts +15 -0
  118. package/dist/Utils/ApiUtils/ApiTypes.js +15 -0
  119. package/dist/Utils/ApiUtils/RequestUtil.d.ts +19 -0
  120. package/dist/Utils/ApiUtils/RequestUtil.js +73 -0
  121. package/dist/Utils/ApiUtils/index.d.ts +20 -0
  122. package/dist/Utils/ApiUtils/index.js +33 -0
  123. package/dist/Utils/ColorUtils.d.ts +11 -0
  124. package/dist/Utils/ColorUtils.js +93 -0
  125. package/dist/Utils/FormUtil.d.ts +6 -6
  126. package/dist/Utils/FormUtil.js +35 -35
  127. package/dist/Utils/FormUtils.d.ts +6 -0
  128. package/dist/Utils/FormUtils.js +35 -0
  129. package/dist/Utils/NumberUtils.d.ts +1 -0
  130. package/dist/Utils/NumberUtils.js +7 -0
  131. package/dist/Utils/PatcherUtils.d.ts +6 -0
  132. package/dist/Utils/PatcherUtils.js +80 -0
  133. package/dist/Utils/StringUtils.d.ts +3 -0
  134. package/dist/Utils/StringUtils.js +47 -0
  135. package/dist/Utils/TimeUtils/debounce.util.d.ts +22 -0
  136. package/dist/Utils/TimeUtils/debounce.util.js +78 -0
  137. package/dist/Utils/TimeUtils/functions.util.d.ts +4 -0
  138. package/dist/Utils/TimeUtils/functions.util.js +21 -0
  139. package/dist/Utils/TimeUtils/index.d.ts +15 -0
  140. package/dist/Utils/TimeUtils/index.js +34 -0
  141. package/dist/Utils/TimeUtils/throttle.util.d.ts +15 -0
  142. package/dist/Utils/TimeUtils/throttle.util.js +43 -0
  143. package/dist/Utils/index.d.ts +7 -2
  144. package/dist/Utils/index.js +23 -18
  145. package/dist/index.d.ts +5 -5
  146. package/dist/index.js +21 -21
  147. package/package.json +4 -2
  148. package/src/Classes/DanhoLogger.ts +78 -0
  149. package/src/Classes/Events/Event.ts +96 -96
  150. package/src/Classes/Events/EventCollection.ts +90 -90
  151. package/src/Classes/Events/EventEmitter.ts +68 -68
  152. package/src/Classes/Time/Date.ts +219 -216
  153. package/src/Classes/Time/Time.ts +109 -104
  154. package/src/Classes/Time/TimeSpan.ts +171 -171
  155. package/src/Classes/index.ts +1 -0
  156. package/src/Classes/store.ts +22 -22
  157. package/src/Extensions/Array/array.extension.ts +103 -0
  158. package/src/Extensions/Array/crud.extension.ts +46 -0
  159. package/src/Extensions/Array/index.ts +15 -0
  160. package/src/Extensions/Array/loop.extension.ts +38 -0
  161. package/src/Extensions/Array/random.extension.ts +56 -0
  162. package/src/Extensions/Array/sort.extension.ts +52 -0
  163. package/src/Extensions/Array/string.extension.ts +22 -0
  164. package/src/Extensions/Document.ts +39 -39
  165. package/src/Extensions/Function.ts +37 -10
  166. package/src/Extensions/Map.ts +56 -56
  167. package/src/Extensions/Number.ts +50 -0
  168. package/src/Extensions/Object/arrays.extension.ts +27 -0
  169. package/src/Extensions/Object/booleans.extension.ts +46 -0
  170. package/src/Extensions/Object/extracts.extension.ts +102 -0
  171. package/src/Extensions/Object/index.ts +9 -80
  172. package/src/Extensions/Object/properties.extension.ts +11 -0
  173. package/src/Extensions/Object/properties.ts +35 -36
  174. package/src/Extensions/String/case.extension.ts +95 -0
  175. package/src/Extensions/String/index.ts +5 -0
  176. package/src/Extensions/index.ts +2 -20
  177. package/src/Interfaces/ElementOptions.ts +7 -7
  178. package/src/Interfaces/IReplacement.ts +2 -2
  179. package/src/Types/Able.ts +22 -0
  180. package/src/Types/Array.ts +7 -0
  181. package/src/Types/C#.ts +9 -0
  182. package/src/Types/Date.ts +1 -1
  183. package/src/Types/Events.ts +12 -12
  184. package/src/Types/Function.ts +10 -0
  185. package/src/Types/Object.ts +4 -0
  186. package/src/Types/PropertiesWith.ts +35 -4
  187. package/src/Types/String.ts +1 -0
  188. package/src/Types/TransformTypes.ts +21 -13
  189. package/src/Types/index.ts +7 -69
  190. package/src/Utils/{ApiUtil → ApiUtils}/ApiTypes.ts +2 -1
  191. package/src/Utils/{ApiUtil → ApiUtils}/index.ts +1 -1
  192. package/src/Utils/ColorUtils.ts +102 -0
  193. package/src/Utils/{FormUtil.ts → FormUtils.ts} +2 -2
  194. package/src/Utils/NumberUtils.ts +3 -0
  195. package/src/Utils/PatcherUtils.ts +111 -0
  196. package/src/Utils/StringUtils.ts +44 -0
  197. package/src/Utils/TimeUtils/debounce.util.ts +85 -0
  198. package/src/Utils/TimeUtils/functions.util.ts +18 -0
  199. package/src/Utils/TimeUtils/index.ts +9 -0
  200. package/src/Utils/TimeUtils/throttle.util.ts +44 -0
  201. package/src/Utils/index.ts +8 -2
  202. package/src/Extensions/Array.ts +0 -95
  203. package/src/Extensions/String.ts +0 -54
  204. /package/src/Utils/{ApiUtil → ApiUtils}/RequestUtil.ts +0 -0
@@ -0,0 +1,17 @@
1
+ import { ValueOf } from "../../Types";
2
+ declare global {
3
+ interface ObjectConstructor {
4
+ /**
5
+ * Destructures object into array of [property, value]
6
+ * @param from Object to destruct
7
+ */
8
+ array<From extends {} = {}>(from: From): Array<[keyof From, ValueOf<From>]>;
9
+ /**
10
+ * Destructures object into array of property keys
11
+ * @param from Object to destruct
12
+ */
13
+ keysOf<From extends {} = {}>(from: From): Array<keyof From>;
14
+ }
15
+ }
16
+ export declare function array<From extends {} = {}>(this: object, from: From): Array<[keyof From, ValueOf<From>]>;
17
+ export declare function keysOf<From extends {} = {}>(this: object, from: From): Array<keyof From>;
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.keysOf = exports.array = void 0;
4
+ function array(from) {
5
+ return Object.entries(from);
6
+ }
7
+ exports.array = array;
8
+ Object.array = array;
9
+ function keysOf(from) {
10
+ return Object.keys(from);
11
+ }
12
+ exports.keysOf = keysOf;
13
+ Object.keysOf = keysOf;
@@ -0,0 +1,18 @@
1
+ declare global {
2
+ interface ObjectConstructor {
3
+ /**
4
+ * Returns true if objects are equal by comparing their properties and values recursively. Does not compare functions.
5
+ * @param a First object
6
+ * @param b Second object
7
+ * @returns true if objects are equal, false otherwise
8
+ */
9
+ areEqual<T extends object | null>(a?: T, b?: T): boolean;
10
+ /**
11
+ * Returns true if object is empty
12
+ * @param obj Object to check
13
+ */
14
+ isNullOrUndefined(obj: any): obj is null | undefined;
15
+ }
16
+ }
17
+ export declare function areEqual<T extends object | null>(a?: T, b?: T): boolean;
18
+ export declare function isNullOrUndefined(obj: any): obj is null | undefined;
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isNullOrUndefined = exports.areEqual = void 0;
4
+ function areEqual(a, b) {
5
+ if (a === b)
6
+ return true;
7
+ if (typeof a !== typeof b)
8
+ return false;
9
+ if (isNullOrUndefined(a) && isNullOrUndefined(b))
10
+ return true;
11
+ const keysA = Object.keys(a ?? {});
12
+ const keysB = Object.keys(b ?? {});
13
+ if (keysA.length !== keysB.length)
14
+ return false;
15
+ try {
16
+ const jsonA = JSON.stringify(a);
17
+ const jsonB = JSON.stringify(b);
18
+ if (jsonA === jsonB)
19
+ return true;
20
+ }
21
+ catch {
22
+ for (const key of keysA) {
23
+ if (!keysB.includes(key))
24
+ return false;
25
+ if (!areEqual(a[key], b[key]))
26
+ return false;
27
+ }
28
+ }
29
+ return true;
30
+ }
31
+ exports.areEqual = areEqual;
32
+ Object.areEqual = areEqual;
33
+ function isNullOrUndefined(obj) {
34
+ return obj === null || obj === undefined;
35
+ }
36
+ exports.isNullOrUndefined = isNullOrUndefined;
37
+ Object.isNullOrUndefined = isNullOrUndefined;
@@ -0,0 +1,38 @@
1
+ declare global {
2
+ interface ObjectConstructor {
3
+ /**
4
+ * Get a copy of object without specified properties or partial versions.
5
+ * @param from Object to extract properties from
6
+ * @param props Properties to extract/Omit
7
+ */
8
+ omit<From extends {}, Props extends keyof From>(from: From, ...props: Array<Props | Partial<From>>): Omit<From, Props>;
9
+ /**
10
+ * Get a copy of object with only specified properties or partial versions.
11
+ * @param from Object to extract properties from
12
+ * @param props Properties to extract/Pick
13
+ */
14
+ pick<From extends {}, Props extends keyof From>(from: From, ...props: Array<Props | Partial<From>>): Pick<From, Props>;
15
+ /**
16
+ * Receive an object with properties that are not in union of source and target objects
17
+ * @param source Source object
18
+ * @param target Target object
19
+ * @param exclude Properties to exclude from difference
20
+ * @returns Object with properties that are not in union of source and target objects, excluding specified properties
21
+ */
22
+ difference<T extends object>(source: T, target: T, ...exclude: Array<keyof T>): Omit<T, keyof T>;
23
+ /**
24
+ * Deeply combines objects, with later objects in parameters taking precedence over earlier ones. Does not combine arrays.
25
+ * @param objects Objects to combine
26
+ * @returns Combined object
27
+ */
28
+ combine<T extends Record<string, any | undefined>>(...objects: Array<Partial<T> | undefined>): T;
29
+ }
30
+ }
31
+ export declare function omit<From extends {}, Props extends keyof From>(from: From, ...props: Array<Props | Partial<From>>): Omit<From, Props>;
32
+ export declare function pick<From extends {}, Props extends keyof From>(from: From, ...props: Array<Props | Partial<From>>): Pick<From, Props>;
33
+ export declare function difference<T extends object>(source: T, target: T, ...exclude: Array<keyof T>): Omit<T, keyof T>;
34
+ type Combinable<T extends Record<string, any>> = {
35
+ [key in keyof T]?: T[key] extends Record<string, any> ? Combinable<T[key]> : T[key];
36
+ };
37
+ export declare function combine<T extends Record<string, any | undefined>>(...objects: Array<Combinable<T> | undefined>): T;
38
+ export {};
@@ -0,0 +1,72 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.combine = exports.difference = exports.pick = exports.omit = void 0;
4
+ function omit(from, ...props) {
5
+ return props.reduce((result, prop) => {
6
+ if (typeof prop === "object") {
7
+ const keys = Object.keysOf(prop);
8
+ keys.forEach(key => delete result[key]);
9
+ }
10
+ else {
11
+ delete result[prop];
12
+ }
13
+ return result;
14
+ }, { ...from });
15
+ }
16
+ exports.omit = omit;
17
+ Object.omit = omit;
18
+ function pick(from, ...props) {
19
+ return props.reduce((result, prop) => {
20
+ if (typeof prop === "object") {
21
+ const keys = Object.keysOf(prop);
22
+ keys.forEach(key => result[key] = from[key]);
23
+ }
24
+ else {
25
+ result[prop] = from[prop];
26
+ }
27
+ return result;
28
+ }, {});
29
+ }
30
+ exports.pick = pick;
31
+ Object.pick = pick;
32
+ function difference(source, target, ...exclude) {
33
+ const diffKeys = new Set([...Object.keysOf(source), ...Object.keysOf(target)]);
34
+ exclude?.forEach(key => diffKeys.delete(key));
35
+ return [...diffKeys.values()].reduce((acc, key, i, arr) => {
36
+ const sourceValue = JSON.stringify(source[key]);
37
+ const targetValue = JSON.stringify(target[key]);
38
+ if (sourceValue !== targetValue)
39
+ acc[key] = target[key];
40
+ return acc;
41
+ }, {});
42
+ }
43
+ exports.difference = difference;
44
+ Object.difference = difference;
45
+ function combine(...objects) {
46
+ return objects.reduce((acc, obj) => {
47
+ if (!obj)
48
+ return acc;
49
+ for (const key in obj) {
50
+ if (typeof obj[key] === 'object' && !Array.isArray(obj[key])) {
51
+ try {
52
+ acc[key] = combine(acc[key], obj[key]);
53
+ }
54
+ catch (err) {
55
+ const error = err;
56
+ if (error.message.includes('Maximum call stack size exceeded')) {
57
+ acc[key] = obj[key];
58
+ }
59
+ else
60
+ throw err;
61
+ }
62
+ }
63
+ else if (obj[key] !== undefined && obj[key] !== null && obj[key] !== '') {
64
+ // @ts-ignore
65
+ acc[key] = obj[key];
66
+ }
67
+ }
68
+ return acc;
69
+ }, {});
70
+ }
71
+ exports.combine = combine;
72
+ Object.combine = combine;
@@ -1,49 +1,10 @@
1
- import { ValueOf } from "../../Types";
2
- import { Properties } from "./properties";
3
- declare global {
4
- interface ObjectConstructor {
5
- /**
6
- * Destructures object into array of [property, value]
7
- * @param from Object to destruct
8
- */
9
- array<From extends {} = {}>(from: From): Array<[keyof From, ValueOf<From>]>;
10
- /**
11
- * Omits properties from object, but for some reason the correct term is "extract"
12
- * @param from Object to extract properties from
13
- * @param props Properties to extract/Omit
14
- */
15
- extract<From extends {}, Props extends keyof From>(from: From, ...props: Array<Props | Partial<From>>): Omit<From, Props>;
16
- /**
17
- * Pick properties from object, but for some reason the correct term is "exclude"
18
- * @param from Object to exclude properties from
19
- * @param props Properties to exclude/pick
20
- */
21
- exclude<From extends {}, Props extends keyof From>(from: From, ...props: Array<Props | Partial<From>>): Pick<From, Props>;
22
- /**
23
- * Returns true if object is empty
24
- * @param obj Object to check
25
- */
26
- isNullOrUndefined(obj: any): obj is null | undefined;
27
- /**
28
- * Destructures object into array of property keys
29
- * @param from Object to destruct
30
- */
31
- keysOf<From extends {} = {}>(from: From): Array<keyof From>;
32
- omit<From extends {}, Exclude extends keyof From>(from: From, ...exclude: Exclude[]): Omit<From, Exclude>;
33
- properties: Properties;
34
- }
35
- }
36
- declare function array<From extends {} = {}>(this: object, from: From): Array<[keyof From, ValueOf<From>]>;
37
- declare function extract<From extends {}, Props extends keyof From>(from: From, ...props: Array<Props | Partial<From>>): Omit<From, Props>;
38
- declare function exclude<From extends {}, Props extends keyof From>(from: From, ...props: Array<Props | Partial<From>>): Pick<From, Props>;
39
- declare function isNullOrUndefined(obj: any): obj is null | undefined;
40
- declare function keysOf<From extends {} = {}>(this: object, from: From): Array<keyof From>;
41
- export declare const ObjectExtensions: {
42
- properties: Properties;
43
- array: typeof array;
44
- extract: typeof extract;
45
- exclude: typeof exclude;
46
- isNullOrUndefined: typeof isNullOrUndefined;
47
- keysOf: typeof keysOf;
48
- };
49
- export {};
1
+ export declare const ObjectExtensions: {
2
+ omit<From extends {}, Props extends keyof From>(from: From, ...props: (Props | Partial<From>)[]): Omit<From, Props>;
3
+ pick<From_1 extends {}, Props_1 extends keyof From_1>(from: From_1, ...props: (Props_1 | Partial<From_1>)[]): Pick<From_1, Props_1>;
4
+ difference<T extends object>(source: T, target: T, ...exclude: (keyof T)[]): Omit<T, keyof T>;
5
+ combine<T_1 extends Record<string, any>>(...objects: ({ [key in keyof T_1]?: (T_1[key] extends Record<string, any> ? T_1[key] extends infer T_2 extends Record<string, any> ? { [key_1 in keyof T_2]?: (T_1[key][key_1] extends Record<string, any> ? T_1[key][key_1] extends infer T_3 extends Record<string, any> ? { [key_2 in keyof T_3]?: (T_1[key][key_1][key_2] extends Record<string, any> ? T_1[key][key_1][key_2] extends infer T_4 extends Record<string, any> ? { [key_3 in keyof T_4]?: (T_1[key][key_1][key_2][key_3] extends Record<string, any> ? T_1[key][key_1][key_2][key_3] extends infer T_5 extends Record<string, any> ? { [key_4 in keyof T_5]?: (T_1[key][key_1][key_2][key_3][key_4] extends Record<string, any> ? T_1[key][key_1][key_2][key_3][key_4] extends infer T_6 extends Record<string, any> ? { [key_5 in keyof T_6]?: (T_1[key][key_1][key_2][key_3][key_4][key_5] extends Record<string, any> ? T_1[key][key_1][key_2][key_3][key_4][key_5] extends infer T_7 extends Record<string, any> ? { [key_6 in keyof T_7]?: (T_1[key][key_1][key_2][key_3][key_4][key_5][key_6] extends Record<string, any> ? T_1[key][key_1][key_2][key_3][key_4][key_5][key_6] extends infer T_8 extends Record<string, any> ? { [key_7 in keyof T_8]?: (T_1[key][key_1][key_2][key_3][key_4][key_5][key_6][key_7] extends Record<string, any> ? T_1[key][key_1][key_2][key_3][key_4][key_5][key_6][key_7] extends infer T_9 extends Record<string, any> ? { [key_8 in keyof T_9]?: (T_1[key][key_1][key_2][key_3][key_4][key_5][key_6][key_7][key_8] extends Record<string, any> ? T_1[key][key_1][key_2][key_3][key_4][key_5][key_6][key_7][key_8] extends infer T_10 extends Record<string, any> ? { [key_9 in keyof T_10]?: (T_1[key][key_1][key_2][key_3][key_4][key_5][key_6][key_7][key_8][key_9] extends Record<string, any> ? T_1[key][key_1][key_2][key_3][key_4][key_5][key_6][key_7][key_8][key_9] extends infer T_11 extends Record<string, any> ? { [key_10 in keyof T_11]?: (T_1[key][key_1][key_2][key_3][key_4][key_5][key_6][key_7][key_8][key_9][key_10] extends Record<string, any> ? any : T_1[key][key_1][key_2][key_3][key_4][key_5][key_6][key_7][key_8][key_9][key_10]) | undefined; } : never : T_1[key][key_1][key_2][key_3][key_4][key_5][key_6][key_7][key_8][key_9]) | undefined; } : never : T_1[key][key_1][key_2][key_3][key_4][key_5][key_6][key_7][key_8]) | undefined; } : never : T_1[key][key_1][key_2][key_3][key_4][key_5][key_6][key_7]) | undefined; } : never : T_1[key][key_1][key_2][key_3][key_4][key_5][key_6]) | undefined; } : never : T_1[key][key_1][key_2][key_3][key_4][key_5]) | undefined; } : never : T_1[key][key_1][key_2][key_3][key_4]) | undefined; } : never : T_1[key][key_1][key_2][key_3]) | undefined; } : never : T_1[key][key_1][key_2]) | undefined; } : never : T_1[key][key_1]) | undefined; } : never : T_1[key]) | undefined; } | undefined)[]): T_1;
6
+ areEqual<T_12 extends object | null>(a?: T_12 | undefined, b?: T_12 | undefined): boolean;
7
+ isNullOrUndefined(obj: any): obj is null | undefined;
8
+ array<From_2 extends {} = {}>(this: object, from: From_2): [keyof From_2, import("../..").ValueOf<From_2>][];
9
+ keysOf<From_3 extends {} = {}>(this: object, from: From_3): (keyof From_3)[];
10
+ };
@@ -1,38 +1,36 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ObjectExtensions = void 0;
4
- const properties_1 = require("./properties");
5
- function array(from) {
6
- return Object.keysOf(from).map(prop => [prop, from[prop]]);
7
- }
8
- Object.array = array;
9
- function extract(from, ...props) {
10
- // If props are Array<keyof From>, Array<Partial<From>>, or Array<keyof From | Partial<From>>, ensure _props as Array<keyof From>
11
- const _props = props.map(prop => typeof prop === "object" ? Object.keysOf(prop) : prop).flat();
12
- _props.forEach(prop => delete from[prop]);
13
- return from;
14
- }
15
- Object.extract = extract;
16
- function exclude(from, ...props) {
17
- // If props are Array<keyof From>, Array<Partial<From>>, or Array<keyof From | Partial<From>>, ensure _props as Array<keyof From>
18
- const _props = props.map(prop => typeof prop === "object" ? Object.keysOf(prop) : prop).flat();
19
- return Object.keysOf(from).reduce((result, prop) => {
20
- if (_props.includes(prop))
21
- delete result[prop];
22
- return result;
23
- }, from);
24
- }
25
- Object.exclude = exclude;
26
- function isNullOrUndefined(obj) {
27
- return obj === null || obj === undefined;
28
- }
29
- Object.isNullOrUndefined = isNullOrUndefined;
30
- function keysOf(from) {
31
- return Object.keys(from);
32
- }
33
- Object.keysOf = keysOf;
34
- Object.properties = properties_1.properties;
35
- exports.ObjectExtensions = {
36
- properties: properties_1.properties,
37
- array, extract, exclude, isNullOrUndefined, keysOf,
38
- };
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.ObjectExtensions = void 0;
27
+ const Array = __importStar(require("./arrays.extension"));
28
+ const Booleans = __importStar(require("./booleans.extension"));
29
+ const Extracts = __importStar(require("./extracts.extension"));
30
+ const Properties = __importStar(require("./properties.extension"));
31
+ exports.ObjectExtensions = {
32
+ ...Array,
33
+ ...Booleans,
34
+ ...Extracts,
35
+ ...Properties
36
+ };
@@ -1,28 +1,28 @@
1
- import { PropertiesWith, If } from '../../Types';
2
- type PrimitiveMap = {
3
- string: string;
4
- number: number;
5
- boolean: boolean;
6
- undefined: undefined;
7
- null: null;
8
- object: object;
9
- function: Function;
10
- any: any;
11
- Date: Date;
12
- RegExp: RegExp;
13
- Promise: Promise<any>;
14
- Array: Array<any>;
15
- Map: Map<any, any>;
16
- Set: Set<any>;
17
- };
18
- /**
19
- * Object with getPrimitiveTypes<Source, AllowFunctions extends boolean>(
20
- * source: Source,
21
- * allowFunctions: AllowFunctions = false
22
- * ): Object with properties from source that matches primitive type
23
- */
24
- export type Properties = {
25
- [Key in keyof PrimitiveMap as `get${Capitalize<Key>}s`]: <Source extends {}, AllowFunctions extends boolean = false>(source: Source, withFunctions?: AllowFunctions) => If<AllowFunctions, PropertiesWith<PrimitiveMap[Key] | ((...args: any[]) => PrimitiveMap[Key]), Source>, PropertiesWith<PrimitiveMap[Key], Source>>;
26
- };
27
- export declare const properties: Properties;
28
- export {};
1
+ import { PropertiesWith, If } from '../../Types';
2
+ type PrimitiveMap = {
3
+ string: string;
4
+ number: number;
5
+ boolean: boolean;
6
+ undefined: undefined;
7
+ null: null;
8
+ object: object;
9
+ function: Function;
10
+ any: any;
11
+ Date: Date;
12
+ RegExp: RegExp;
13
+ Promise: Promise<any>;
14
+ Array: Array<any>;
15
+ Map: Map<any, any>;
16
+ Set: Set<any>;
17
+ };
18
+ /**
19
+ * Object with getPrimitiveTypes<Source, AllowFunctions extends boolean>(
20
+ * source: Source,
21
+ * allowFunctions: AllowFunctions = false
22
+ * ): Object with properties from source that matches primitive type
23
+ */
24
+ export type Properties = {
25
+ [Key in keyof PrimitiveMap as `get${Capitalize<Key>}s`]: <Source extends {}, AllowFunctions extends boolean = false>(source: Source, withFunctions?: AllowFunctions) => If<AllowFunctions, PropertiesWith<PrimitiveMap[Key] | ((...args: any[]) => PrimitiveMap[Key]), Source>, PropertiesWith<PrimitiveMap[Key], Source>>;
26
+ };
27
+ export declare const properties: Properties;
28
+ export {};
@@ -0,0 +1,6 @@
1
+ import { Properties } from "./properties";
2
+ declare global {
3
+ interface ObjectConstructor {
4
+ properties: Properties;
5
+ }
6
+ }
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const properties_1 = require("./properties");
4
+ Object.properties = properties_1.properties;
@@ -1,20 +1,19 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.properties = void 0;
4
- const String_1 = require("../String");
5
- exports.properties = [
6
- 'string', 'number', 'boolean', 'undefined', 'null',
7
- 'object', 'function', 'any',
8
- 'Date', 'RegExp', 'Promise', 'Array', 'Map', 'Set'
9
- ].reduce((result, primitive) => {
10
- result[`get${String_1.StringExtensions.toPascalCase.bind(primitive)()}s`] = function (source, withFunctions = false) {
11
- return Object.keysOf(source).reduce((result, key) => {
12
- if (source[key].constructor.name === primitive ||
13
- (withFunctions && typeof source[key] === 'function' && source[key]).constructor.name === primitive) {
14
- result[key] = source[key];
15
- }
16
- return result;
17
- }, {});
18
- };
19
- return result;
20
- }, {});
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.properties = void 0;
4
+ exports.properties = [
5
+ 'string', 'number', 'boolean', 'undefined', 'null',
6
+ 'object', 'function', 'any',
7
+ 'Date', 'RegExp', 'Promise', 'Array', 'Map', 'Set'
8
+ ].reduce((result, primitive) => {
9
+ result[`get${primitive.convertCase('camel', 'pascal')}s`] = function (source, withFunctions = false) {
10
+ return Object.keysOf(source).reduce((result, key) => {
11
+ if (source[key].constructor.name === primitive ||
12
+ (withFunctions && typeof source[key] === 'function' && source[key]).constructor.name === primitive) {
13
+ result[key] = source[key];
14
+ }
15
+ return result;
16
+ }, {});
17
+ };
18
+ return result;
19
+ }, {});
@@ -0,0 +1,12 @@
1
+ export type Case = 'camel' | 'pascal' | 'snake' | 'kebab' | 'lower' | 'upper';
2
+ declare global {
3
+ interface String {
4
+ /**
5
+ * Converts string from one case to another.
6
+ * @param from Case to convert from
7
+ * @param to Cases to convert to, in order. If multiple cases are provided, they will be applied in order
8
+ */
9
+ convertCase<To extends Array<Case>, Return extends To extends [...Array<Case>, infer To] ? To : Case>(from: Case, ...to: To): (Return extends 'upper' ? Uppercase<string> : Return extends 'lower' ? Lowercase<string> : Return extends 'pascal' ? Capitalize<string> : Return extends 'camel' ? Uncapitalize<string> : string);
10
+ }
11
+ }
12
+ export declare const convertCase: <TValue extends string, To extends Case[], Return extends To extends [...Case[], infer To_1] ? To_1 : Case>(value: TValue, from: Case, ...to: To) => Return extends "upper" ? Uppercase<TValue> : Return extends "lower" ? Lowercase<TValue> : Return extends "pascal" ? Capitalize<TValue> : Return extends "camel" ? Uncapitalize<TValue> : string;
@@ -0,0 +1,55 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.convertCase = void 0;
4
+ const caseMap = {
5
+ camel: {
6
+ camel: (str) => str,
7
+ lower: (str) => str.toLowerCase(),
8
+ upper: (str) => str.toUpperCase(),
9
+ pascal: (str) => str[0].toUpperCase() + str.replace(/([A-Z])/g, (match) => ` ${match}`).slice(1),
10
+ snake: (str) => str.replace(/([A-Z])/g, (match) => `_${match.toLowerCase()}`),
11
+ kebab: (str) => str.replace(/([A-Z])/g, (match) => `-${match.toLowerCase()}`),
12
+ },
13
+ pascal: {
14
+ pascal: (str) => str,
15
+ lower: (str) => str.toLowerCase(),
16
+ upper: (str) => str.toUpperCase(),
17
+ camel: (str) => str[0].toLowerCase() + str.slice(1),
18
+ snake: (str) => str.replace(/([A-Z])/g, (match) => `_${match.toLowerCase()}`),
19
+ kebab: (str) => str.replace(/([A-Z])/g, (match) => `-${match.toLowerCase()}`),
20
+ },
21
+ snake: {
22
+ snake: (str) => str,
23
+ lower: (str) => str.toLowerCase(),
24
+ upper: (str) => str.toUpperCase(),
25
+ camel: (str) => str.replace(/(_\w)/g, (match) => match[1].toUpperCase()),
26
+ pascal: (str) => str[0].toUpperCase() + str.substring(1, str.length).replace(/(_\w)/g, (match) => match[1].toUpperCase()),
27
+ kebab: (str) => str.replace(/_/g, '-'),
28
+ },
29
+ kebab: {
30
+ kebab: (str) => str,
31
+ lower: (str) => str.toLowerCase(),
32
+ upper: (str) => str.toUpperCase(),
33
+ camel: (str) => str.replace(/(-\w)/g, (match) => match[1].toUpperCase()),
34
+ pascal: (str) => str[0].toUpperCase() + str.substring(1, str.length).replace(/(-\w)/g, (match) => match[1].toUpperCase()),
35
+ snake: (str) => str.replace(/-/g, '_'),
36
+ },
37
+ lower: {
38
+ lower: (str) => str.toLowerCase(),
39
+ upper: (str) => str.toUpperCase(),
40
+ camel: (str) => str,
41
+ pascal: (str) => str[0].toUpperCase() + str.slice(1),
42
+ snake: (str) => str,
43
+ kebab: (str) => str,
44
+ },
45
+ upper: {
46
+ upper: (str) => str.toUpperCase(),
47
+ camel: (str) => str[0].toLowerCase() + str.slice(1),
48
+ pascal: (str) => str[0].toUpperCase() + str.toLowerCase().slice(1),
49
+ snake: (str) => str.replace(/ /g, '_'),
50
+ kebab: (str) => str.replace(/ /g, '-'),
51
+ lower: (str) => str.toLowerCase(),
52
+ }
53
+ };
54
+ const convertCase = (value, from, ...to) => to.reduce((str, toCase) => caseMap[from][toCase](str), value);
55
+ exports.convertCase = convertCase;
@@ -0,0 +1,4 @@
1
+ import * as Case from './case.extension';
2
+ export declare const StringUtils: {
3
+ convertCase: <TValue extends string, To extends Case.Case[], Return extends To extends [...Case.Case[], infer To_1] ? To_1 : Case.Case>(value: TValue, from: Case.Case, ...to: To) => Return extends "upper" ? Uppercase<TValue> : Return extends "lower" ? Lowercase<TValue> : Return extends "pascal" ? Capitalize<TValue> : Return extends "camel" ? Uncapitalize<TValue> : string;
4
+ };
@@ -0,0 +1,30 @@
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.StringUtils = void 0;
27
+ const Case = __importStar(require("./case.extension"));
28
+ exports.StringUtils = {
29
+ ...Case,
30
+ };
@@ -1,36 +1,36 @@
1
- import IReplacement from "../Interfaces/IReplacement";
2
- declare global {
3
- interface String {
4
- /**
5
- * Uppercases first letter of string
6
- */
7
- toPascalCase(): string;
8
- /**
9
- * Replaces "replacer" (default: ' ') with "replacement" (default: '_')
10
- * @param replaceOptions This is practically your stereotypical String.replace, if you really want it to be
11
- */
12
- toSnakeCase(replaceOptions?: IReplacement): string;
13
- /**
14
- * Replaces "replacer" (default: ' ') with "replacement" (default: '-')
15
- * @param replaceOptions This is practically your stereotypical String.replace, if you really want it to be
16
- */
17
- toKebabCase(replaceOptions?: IReplacement): string;
18
- /**
19
- * String.substring but accepting negative numbers to cut from length
20
- * @param start Start of string. 0 indexed, if negative number, subtracts number from length
21
- * @param end End of string. 0 indexed, if negative number, substracts number from length
22
- */
23
- clip(start: number, end?: number): string;
24
- }
25
- }
26
- declare function toPascalCase(this: string): string;
27
- declare function toSnakeCase(this: string, replaceOptions: IReplacement): string;
28
- declare function toKebabCase(this: string, replaceOptions: IReplacement): string;
29
- declare function clip(this: string, start: number, end?: number): string;
30
- export declare const StringExtensions: {
31
- toPascalCase: typeof toPascalCase;
32
- toSnakeCase: typeof toSnakeCase;
33
- toKebabCase: typeof toKebabCase;
34
- clip: typeof clip;
35
- };
36
- export {};
1
+ import IReplacement from "../Interfaces/IReplacement";
2
+ declare global {
3
+ interface String {
4
+ /**
5
+ * Uppercases first letter of string
6
+ */
7
+ toPascalCase(): string;
8
+ /**
9
+ * Replaces "replacer" (default: ' ') with "replacement" (default: '_')
10
+ * @param replaceOptions This is practically your stereotypical String.replace, if you really want it to be
11
+ */
12
+ toSnakeCase(replaceOptions?: IReplacement): string;
13
+ /**
14
+ * Replaces "replacer" (default: ' ') with "replacement" (default: '-')
15
+ * @param replaceOptions This is practically your stereotypical String.replace, if you really want it to be
16
+ */
17
+ toKebabCase(replaceOptions?: IReplacement): string;
18
+ /**
19
+ * String.substring but accepting negative numbers to cut from length
20
+ * @param start Start of string. 0 indexed, if negative number, subtracts number from length
21
+ * @param end End of string. 0 indexed, if negative number, substracts number from length
22
+ */
23
+ clip(start: number, end?: number): string;
24
+ }
25
+ }
26
+ declare function toPascalCase(this: string): string;
27
+ declare function toSnakeCase(this: string, replaceOptions: IReplacement): string;
28
+ declare function toKebabCase(this: string, replaceOptions: IReplacement): string;
29
+ declare function clip(this: string, start: number, end?: number): string;
30
+ export declare const StringExtensions: {
31
+ toPascalCase: typeof toPascalCase;
32
+ toSnakeCase: typeof toSnakeCase;
33
+ toKebabCase: typeof toKebabCase;
34
+ clip: typeof clip;
35
+ };
36
+ export {};