danholibraryjs 1.11.0 → 2.0.1

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 (210) hide show
  1. package/README.md +0 -1
  2. package/_package.github-release.json +6 -0
  3. package/_package.npm-release.json +6 -0
  4. package/dist/Classes/DanhoLogger.d.ts +23 -0
  5. package/dist/Classes/DanhoLogger.js +65 -0
  6. package/dist/Classes/Events/Event.d.ts +66 -66
  7. package/dist/Classes/Events/Event.js +114 -114
  8. package/dist/Classes/Events/EventCollection.d.ts +57 -57
  9. package/dist/Classes/Events/EventCollection.js +109 -109
  10. package/dist/Classes/Events/EventEmitter.d.ts +74 -74
  11. package/dist/Classes/Events/EventEmitter.js +97 -97
  12. package/dist/Classes/Events/index.d.ts +3 -3
  13. package/dist/Classes/Events/index.js +19 -19
  14. package/dist/Classes/Time/Date.d.ts +148 -147
  15. package/dist/Classes/Time/Date.js +241 -238
  16. package/dist/Classes/Time/Time.d.ts +66 -65
  17. package/dist/Classes/Time/Time.js +120 -117
  18. package/dist/Classes/Time/TimeProperties.d.ts +3 -3
  19. package/dist/Classes/Time/TimeProperties.js +2 -2
  20. package/dist/Classes/Time/TimeSpan.d.ts +123 -123
  21. package/dist/Classes/Time/TimeSpan.js +179 -179
  22. package/dist/Classes/Time/index.d.ts +4 -4
  23. package/dist/Classes/Time/index.js +20 -20
  24. package/dist/Classes/index.d.ts +4 -3
  25. package/dist/Classes/index.js +20 -19
  26. package/dist/Classes/store.d.ts +75 -75
  27. package/dist/Classes/store.js +84 -84
  28. package/dist/Extensions/Array/array.extension.d.ts +42 -0
  29. package/dist/Extensions/Array/array.extension.js +57 -0
  30. package/dist/Extensions/Array/crud.extension.d.ts +24 -0
  31. package/dist/Extensions/Array/crud.extension.js +28 -0
  32. package/dist/Extensions/Array/index.d.ts +6 -0
  33. package/dist/Extensions/Array/index.js +22 -0
  34. package/dist/Extensions/Array/loop.extension.d.ts +18 -0
  35. package/dist/Extensions/Array/loop.extension.js +23 -0
  36. package/dist/Extensions/Array/random.extension.d.ts +23 -0
  37. package/dist/Extensions/Array/random.extension.js +35 -0
  38. package/dist/Extensions/Array/sort.extension.d.ts +27 -0
  39. package/dist/Extensions/Array/sort.extension.js +31 -0
  40. package/dist/Extensions/Array/string.extension.d.ts +13 -0
  41. package/dist/Extensions/Array/string.extension.js +14 -0
  42. package/dist/Extensions/Function.d.ts +29 -14
  43. package/dist/Extensions/Function.js +23 -10
  44. package/dist/Extensions/Map.d.ts +54 -54
  45. package/dist/Extensions/Map.js +42 -42
  46. package/dist/Extensions/Number.d.ts +13 -0
  47. package/dist/Extensions/Number.js +40 -0
  48. package/dist/Extensions/Object/arrays.extension.d.ts +17 -0
  49. package/dist/Extensions/Object/arrays.extension.js +13 -0
  50. package/dist/Extensions/Object/booleans.extension.d.ts +18 -0
  51. package/dist/Extensions/Object/booleans.extension.js +37 -0
  52. package/dist/Extensions/Object/extracts.extension.d.ts +38 -0
  53. package/dist/Extensions/Object/extracts.extension.js +72 -0
  54. package/dist/Extensions/Object/index.d.ts +4 -49
  55. package/dist/Extensions/Object/index.js +20 -38
  56. package/dist/Extensions/Object/properties.d.ts +28 -28
  57. package/dist/Extensions/Object/properties.extension.d.ts +33 -0
  58. package/dist/Extensions/Object/properties.extension.js +21 -0
  59. package/dist/Extensions/Object/properties.js +20 -20
  60. package/dist/Extensions/String/case.extension.d.ts +12 -0
  61. package/dist/Extensions/String/case.extension.js +55 -0
  62. package/dist/Extensions/String/index.d.ts +1 -0
  63. package/dist/{Functions → Extensions/String}/index.js +17 -21
  64. package/dist/Extensions/index.d.ts +6 -17
  65. package/dist/Extensions/index.js +22 -30
  66. package/dist/Interfaces/ElementOptions.d.ts +15 -15
  67. package/dist/Interfaces/ElementOptions.js +2 -2
  68. package/dist/Interfaces/IReplacement.d.ts +12 -12
  69. package/dist/Interfaces/IReplacement.js +2 -2
  70. package/dist/Interfaces/index.d.ts +2 -2
  71. package/dist/Interfaces/index.js +18 -18
  72. package/dist/Types/Able.d.ts +16 -0
  73. package/dist/Types/Able.js +2 -0
  74. package/dist/Types/Array.d.ts +6 -0
  75. package/dist/Types/Array.js +2 -0
  76. package/dist/Types/BetterTypes.d.ts +9 -9
  77. package/dist/Types/BetterTypes.js +2 -2
  78. package/dist/Types/C#.d.ts +8 -0
  79. package/dist/Types/C#.js +2 -0
  80. package/dist/Types/Date.d.ts +6 -6
  81. package/dist/Types/Date.js +2 -2
  82. package/dist/Types/Events.d.ts +10 -10
  83. package/dist/Types/Events.js +2 -2
  84. package/dist/Types/Function.d.ts +5 -0
  85. package/dist/Types/Function.js +2 -0
  86. package/dist/Types/Object.d.ts +4 -0
  87. package/dist/Types/Object.js +2 -0
  88. package/dist/Types/PropertiesWith.d.ts +34 -13
  89. package/dist/Types/PropertiesWith.js +2 -2
  90. package/dist/Types/String.d.ts +1 -0
  91. package/dist/Types/String.js +2 -0
  92. package/dist/Types/TransformTypes.d.ts +22 -16
  93. package/dist/Types/TransformTypes.js +2 -2
  94. package/dist/Types/index.d.ts +24 -65
  95. package/dist/Types/index.js +27 -21
  96. package/dist/Utils/{ApiUtil → ApiUtils}/ApiTypes.d.ts +15 -15
  97. package/dist/Utils/{ApiUtil → ApiUtils}/ApiTypes.js +15 -15
  98. package/dist/Utils/{ApiUtil → ApiUtils}/RequestUtil.d.ts +19 -19
  99. package/dist/Utils/{ApiUtil → ApiUtils}/RequestUtil.js +73 -73
  100. package/dist/Utils/{ApiUtil → ApiUtils}/index.d.ts +20 -20
  101. package/dist/Utils/{ApiUtil → ApiUtils}/index.js +33 -33
  102. package/dist/Utils/ColorUtils.d.ts +11 -0
  103. package/dist/Utils/ColorUtils.js +93 -0
  104. package/dist/Utils/{FormUtil.d.ts → FormUtils.d.ts} +6 -6
  105. package/dist/Utils/{FormUtil.js → FormUtils.js} +35 -35
  106. package/dist/Utils/NumberUtils.d.ts +1 -0
  107. package/dist/Utils/NumberUtils.js +7 -0
  108. package/dist/Utils/PatcherUtils.d.ts +6 -0
  109. package/dist/Utils/PatcherUtils.js +80 -0
  110. package/dist/Utils/StringUtils.d.ts +3 -0
  111. package/dist/Utils/StringUtils.js +47 -0
  112. package/dist/Utils/TimeUtils/debounce.util.d.ts +22 -0
  113. package/dist/Utils/TimeUtils/debounce.util.js +78 -0
  114. package/dist/Utils/TimeUtils/functions.util.d.ts +4 -0
  115. package/dist/Utils/TimeUtils/functions.util.js +21 -0
  116. package/dist/Utils/TimeUtils/index.d.ts +15 -0
  117. package/dist/Utils/TimeUtils/index.js +34 -0
  118. package/dist/Utils/TimeUtils/throttle.util.d.ts +15 -0
  119. package/dist/Utils/TimeUtils/throttle.util.js +43 -0
  120. package/dist/Utils/index.d.ts +7 -2
  121. package/dist/Utils/index.js +23 -18
  122. package/dist/index.d.ts +4 -5
  123. package/dist/index.js +20 -21
  124. package/docs/Classes.md +78 -3
  125. package/docs/Extensions.md +219 -78
  126. package/docs/Types.md +202 -58
  127. package/docs/index.md +0 -1
  128. package/package.json +4 -2
  129. package/src/Classes/DanhoLogger.ts +78 -0
  130. package/src/Classes/Events/Event.ts +96 -96
  131. package/src/Classes/Events/EventCollection.ts +90 -90
  132. package/src/Classes/Events/EventEmitter.ts +68 -68
  133. package/src/Classes/Time/Date.ts +219 -216
  134. package/src/Classes/Time/Time.ts +109 -104
  135. package/src/Classes/Time/TimeSpan.ts +171 -171
  136. package/src/Classes/index.ts +1 -0
  137. package/src/Classes/store.ts +22 -22
  138. package/src/Extensions/Array/array.extension.ts +103 -0
  139. package/src/Extensions/Array/crud.extension.ts +46 -0
  140. package/src/Extensions/Array/index.ts +6 -0
  141. package/src/Extensions/Array/loop.extension.ts +38 -0
  142. package/src/Extensions/Array/random.extension.ts +56 -0
  143. package/src/Extensions/Array/sort.extension.ts +52 -0
  144. package/src/Extensions/Array/string.extension.ts +22 -0
  145. package/src/Extensions/Function.ts +37 -10
  146. package/src/Extensions/Map.ts +56 -56
  147. package/src/Extensions/Number.ts +50 -0
  148. package/src/Extensions/Object/arrays.extension.ts +27 -0
  149. package/src/Extensions/Object/booleans.extension.ts +46 -0
  150. package/src/Extensions/Object/extracts.extension.ts +102 -0
  151. package/src/Extensions/Object/index.ts +4 -82
  152. package/src/Extensions/Object/properties.extension.ts +59 -0
  153. package/src/Extensions/Object/properties.ts +36 -36
  154. package/src/Extensions/String/case.extension.ts +95 -0
  155. package/src/Extensions/String/index.ts +1 -0
  156. package/src/Extensions/index.ts +3 -21
  157. package/src/Interfaces/ElementOptions.ts +7 -7
  158. package/src/Interfaces/IReplacement.ts +2 -2
  159. package/src/Types/Able.ts +22 -0
  160. package/src/Types/Array.ts +7 -0
  161. package/src/Types/C#.ts +9 -0
  162. package/src/Types/Date.ts +1 -1
  163. package/src/Types/Events.ts +12 -12
  164. package/src/Types/Function.ts +10 -0
  165. package/src/Types/Object.ts +4 -0
  166. package/src/Types/PropertiesWith.ts +35 -4
  167. package/src/Types/String.ts +1 -0
  168. package/src/Types/TransformTypes.ts +21 -13
  169. package/src/Types/index.ts +7 -69
  170. package/src/Utils/{ApiUtil → ApiUtils}/ApiTypes.ts +2 -1
  171. package/src/Utils/{ApiUtil → ApiUtils}/index.ts +1 -1
  172. package/src/Utils/ColorUtils.ts +102 -0
  173. package/src/Utils/{FormUtil.ts → FormUtils.ts} +2 -2
  174. package/src/Utils/NumberUtils.ts +3 -0
  175. package/src/Utils/PatcherUtils.ts +111 -0
  176. package/src/Utils/StringUtils.ts +44 -0
  177. package/src/Utils/TimeUtils/debounce.util.ts +85 -0
  178. package/src/Utils/TimeUtils/functions.util.ts +18 -0
  179. package/src/Utils/TimeUtils/index.ts +9 -0
  180. package/src/Utils/TimeUtils/throttle.util.ts +44 -0
  181. package/src/Utils/index.ts +8 -2
  182. package/src/index.ts +0 -1
  183. package/dist/Extensions/Array.d.ts +0 -52
  184. package/dist/Extensions/Array.js +0 -51
  185. package/dist/Extensions/Document.d.ts +0 -27
  186. package/dist/Extensions/Document.js +0 -32
  187. package/dist/Extensions/String.d.ts +0 -36
  188. package/dist/Extensions/String.js +0 -25
  189. package/dist/Functions/CopyToClipboard.d.ts +0 -7
  190. package/dist/Functions/CopyToClipboard.js +0 -15
  191. package/dist/Functions/GetCSSProperty.d.ts +0 -15
  192. package/dist/Functions/GetCSSProperty.js +0 -26
  193. package/dist/Functions/GetNestedProperty.d.ts +0 -9
  194. package/dist/Functions/GetNestedProperty.js +0 -23
  195. package/dist/Functions/HTMLEvent.d.ts +0 -11
  196. package/dist/Functions/HTMLEvent.js +0 -14
  197. package/dist/Functions/SetNavigationSelected.d.ts +0 -9
  198. package/dist/Functions/SetNavigationSelected.js +0 -25
  199. package/dist/Functions/index.d.ts +0 -5
  200. package/docs/Functions.md +0 -61
  201. package/src/Extensions/Array.ts +0 -95
  202. package/src/Extensions/Document.ts +0 -58
  203. package/src/Extensions/String.ts +0 -54
  204. package/src/Functions/CopyToClipboard.ts +0 -10
  205. package/src/Functions/GetCSSProperty.ts +0 -27
  206. package/src/Functions/GetNestedProperty.ts +0 -29
  207. package/src/Functions/HTMLEvent.ts +0 -13
  208. package/src/Functions/SetNavigationSelected.ts +0 -19
  209. package/src/Functions/index.ts +0 -5
  210. /package/src/Utils/{ApiUtil → ApiUtils}/RequestUtil.ts +0 -0
@@ -1,54 +1,54 @@
1
- declare global {
2
- interface Map<K, V> {
3
- /**
4
- * Converts into Array<[Key, Value]>
5
- */
6
- array(): Array<[K, V]>;
7
- /**
8
- * Maps values into new types of generics
9
- * @param callback Callbacking function to map values
10
- */
11
- map<EK, EV>(callback: (value: V, key: K, index: number, self: this) => [EK, EV]): Map<EK, EV>;
12
- /**
13
- * Returns array of "accepted" values. Criteria defined in callback param
14
- * @param callback Callbacking function to filter away unwanted values
15
- */
16
- filter(callback: (value: V, key: K, index: number, self: this) => boolean): Map<K, V>;
17
- /**
18
- * Returns array of keys
19
- */
20
- keyArr(): Array<K>;
21
- /**
22
- * Returns array of values
23
- */
24
- valueArr(): Array<V>;
25
- /**
26
- * Returns first [key, value] match to callback param. Returns undefined if nothing found
27
- * @param callback Callbacking function to find KeyValuePair
28
- */
29
- find(callback: (value: V, key: K, index: number, self: this) => boolean): [K, V] | undefined;
30
- /**
31
- * Whether or not map includes a value. Returns true if it does, false if not ¯\_(ツ)_/¯
32
- * @param value Value that may be includded in map
33
- * @param fromIndex Start looking for value from specific index+. Default: 0
34
- */
35
- includes(value: V, fromIndex?: number): boolean;
36
- }
37
- }
38
- declare function array<K, V>(this: Map<K, V>): Array<[K, V]>;
39
- declare function map<K, V, EK, EV>(this: Map<K, V>, callback: (value: V, key: K, index: number, map: Map<K, V>) => [EK, EV]): Map<EK, EV>;
40
- declare function filter<K, V>(this: Map<K, V>, callback: (value: V, key: K, index: number, map: Map<K, V>) => boolean): Map<K, V>;
41
- declare function keyArr<K, V>(this: Map<K, V>): Array<K>;
42
- declare function valueArr<K, V>(this: Map<K, V>): Array<V>;
43
- declare function find<K, V>(this: Map<K, V>, callback: (value: V, key: K, index: number, map: Map<K, V>) => boolean): [K, V] | undefined;
44
- declare function includes<K, V>(this: Map<K, V>, item: V, fromIndex?: number): boolean;
45
- export declare const MapExtensions: {
46
- array: typeof array;
47
- map: typeof map;
48
- filter: typeof filter;
49
- keyArr: typeof keyArr;
50
- valueArr: typeof valueArr;
51
- find: typeof find;
52
- includes: typeof includes;
53
- };
54
- export {};
1
+ declare global {
2
+ interface Map<K, V> {
3
+ /**
4
+ * Converts into Array<[Key, Value]>
5
+ */
6
+ array(): Array<[K, V]>;
7
+ /**
8
+ * Maps values into new types of generics
9
+ * @param callback Callbacking function to map values
10
+ */
11
+ map<EK, EV>(callback: (value: V, key: K, index: number, self: this) => [EK, EV]): Map<EK, EV>;
12
+ /**
13
+ * Returns array of "accepted" values. Criteria defined in callback param
14
+ * @param callback Callbacking function to filter away unwanted values
15
+ */
16
+ filter(callback: (value: V, key: K, index: number, self: this) => boolean): Map<K, V>;
17
+ /**
18
+ * Returns array of keys
19
+ */
20
+ keyArr(): Array<K>;
21
+ /**
22
+ * Returns array of values
23
+ */
24
+ valueArr(): Array<V>;
25
+ /**
26
+ * Returns first [key, value] match to callback param. Returns undefined if nothing found
27
+ * @param callback Callbacking function to find KeyValuePair
28
+ */
29
+ find(callback: (value: V, key: K, index: number, self: this) => boolean): [K, V] | undefined;
30
+ /**
31
+ * Whether or not map includes a value. Returns true if it does, false if not ¯\_(ツ)_/¯
32
+ * @param value Value that may be includded in map
33
+ * @param fromIndex Start looking for value from specific index+. Default: 0
34
+ */
35
+ includes(value: V, fromIndex?: number): boolean;
36
+ }
37
+ }
38
+ declare function array<K, V>(this: Map<K, V>): Array<[K, V]>;
39
+ declare function map<K, V, EK, EV>(this: Map<K, V>, callback: (value: V, key: K, index: number, map: Map<K, V>) => [EK, EV]): Map<EK, EV>;
40
+ declare function filter<K, V>(this: Map<K, V>, callback: (value: V, key: K, index: number, map: Map<K, V>) => boolean): Map<K, V>;
41
+ declare function keyArr<K, V>(this: Map<K, V>): Array<K>;
42
+ declare function valueArr<K, V>(this: Map<K, V>): Array<V>;
43
+ declare function find<K, V>(this: Map<K, V>, callback: (value: V, key: K, index: number, map: Map<K, V>) => boolean): [K, V] | undefined;
44
+ declare function includes<K, V>(this: Map<K, V>, item: V, fromIndex?: number): boolean;
45
+ export declare const MapExtensions: {
46
+ array: typeof array;
47
+ map: typeof map;
48
+ filter: typeof filter;
49
+ keyArr: typeof keyArr;
50
+ valueArr: typeof valueArr;
51
+ find: typeof find;
52
+ includes: typeof includes;
53
+ };
54
+ export {};
@@ -1,42 +1,42 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.MapExtensions = void 0;
4
- function array() {
5
- let result = new Array();
6
- for (const kvp of this) {
7
- result.push(kvp);
8
- }
9
- return result;
10
- }
11
- Map.prototype.array = array;
12
- function map(callback) {
13
- return this.array()
14
- .map(([k, v], i) => callback(v, k, i, this))
15
- .reduce((map, [key, value]) => map.set(key, value), new Map());
16
- }
17
- Map.prototype.map = map;
18
- function filter(callback) {
19
- return this.array()
20
- .filter(([k, v], i) => callback(v, k, i, this))
21
- .reduce((map, [key, value]) => map.set(key, value), new Map());
22
- }
23
- Map.prototype.filter = filter;
24
- function keyArr() {
25
- return this.array().map(([k]) => k);
26
- }
27
- Map.prototype.keyArr = keyArr;
28
- function valueArr() {
29
- return this.array().map(([_, v]) => v);
30
- }
31
- Map.prototype.valueArr = valueArr;
32
- function find(callback) {
33
- return this.array().find(([k, v], i) => callback(v, k, i, this));
34
- }
35
- Map.prototype.find = find;
36
- function includes(item, fromIndex) {
37
- return this.valueArr().includes(item, fromIndex);
38
- }
39
- Map.prototype.includes = includes;
40
- exports.MapExtensions = {
41
- array, map, filter, keyArr, valueArr, find, includes
42
- };
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MapExtensions = void 0;
4
+ function array() {
5
+ let result = new Array();
6
+ for (const kvp of this) {
7
+ result.push(kvp);
8
+ }
9
+ return result;
10
+ }
11
+ Map.prototype.array = array;
12
+ function map(callback) {
13
+ return this.array()
14
+ .map(([k, v], i) => callback(v, k, i, this))
15
+ .reduce((map, [key, value]) => map.set(key, value), new Map());
16
+ }
17
+ Map.prototype.map = map;
18
+ function filter(callback) {
19
+ return this.array()
20
+ .filter(([k, v], i) => callback(v, k, i, this))
21
+ .reduce((map, [key, value]) => map.set(key, value), new Map());
22
+ }
23
+ Map.prototype.filter = filter;
24
+ function keyArr() {
25
+ return this.array().map(([k]) => k);
26
+ }
27
+ Map.prototype.keyArr = keyArr;
28
+ function valueArr() {
29
+ return this.array().map(([_, v]) => v);
30
+ }
31
+ Map.prototype.valueArr = valueArr;
32
+ function find(callback) {
33
+ return this.array().find(([k, v], i) => callback(v, k, i, this));
34
+ }
35
+ Map.prototype.find = find;
36
+ function includes(item, fromIndex) {
37
+ return this.valueArr().includes(item, fromIndex);
38
+ }
39
+ Map.prototype.includes = includes;
40
+ exports.MapExtensions = {
41
+ array, map, filter, keyArr, valueArr, find, includes
42
+ };
@@ -0,0 +1,13 @@
1
+ type Separators = {
2
+ thousand: string;
3
+ decimal: string;
4
+ };
5
+ declare global {
6
+ interface Number {
7
+ toSeparationString(separators: Partial<Separators>): string;
8
+ toRomanNumeral(): string;
9
+ }
10
+ }
11
+ export declare function toSeparationString(this: number, separators: Partial<Separators>): string;
12
+ export declare function toRomanNumeral(this: number): string;
13
+ export {};
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.toRomanNumeral = exports.toSeparationString = void 0;
4
+ function toSeparationString(separators) {
5
+ const { thousand = '.', decimal = '.' } = separators;
6
+ const [integerPart, decimalPart] = this.toString().split('.');
7
+ const formattedInteger = integerPart.replace(/\B(?=(\d{3})+(?!\d))/g, thousand);
8
+ return decimalPart ? `${formattedInteger}${decimal}${decimalPart}` : formattedInteger;
9
+ }
10
+ exports.toSeparationString = toSeparationString;
11
+ Number.prototype.toSeparationString = toSeparationString;
12
+ function toRomanNumeral() {
13
+ if (this <= 0 || this >= 4000)
14
+ throw new RangeError('Number must be between 1 and 3999 to convert to Roman numeral');
15
+ const numeralMap = [
16
+ [1000, 'M'],
17
+ [900, 'CM'],
18
+ [500, 'D'],
19
+ [400, 'CD'],
20
+ [100, 'C'],
21
+ [90, 'XC'],
22
+ [50, 'L'],
23
+ [40, 'XL'],
24
+ [10, 'X'],
25
+ [9, 'IX'],
26
+ [5, 'V'],
27
+ [4, 'IV'],
28
+ [1, 'I']
29
+ ];
30
+ let value = this;
31
+ return numeralMap.reduce((acc, [numeralValue, numeral]) => {
32
+ while (value >= numeralValue) {
33
+ acc += numeral;
34
+ value -= numeralValue;
35
+ }
36
+ return acc;
37
+ }, '');
38
+ }
39
+ exports.toRomanNumeral = toRomanNumeral;
40
+ Number.prototype.toRomanNumeral = toRomanNumeral;
@@ -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,4 @@
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 * from './arrays.extension';
2
+ export * from './booleans.extension';
3
+ export * from './extracts.extension';
4
+ export * from './properties.extension';
@@ -1,38 +1,20 @@
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 __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
+ __exportStar(require("./arrays.extension"), exports);
18
+ __exportStar(require("./booleans.extension"), exports);
19
+ __exportStar(require("./extracts.extension"), exports);
20
+ __exportStar(require("./properties.extension"), exports);
@@ -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,33 @@
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
+ declare global {
28
+ interface ObjectConstructor {
29
+ properties: Properties;
30
+ }
31
+ }
32
+ export declare const properties: Properties;
33
+ export {};