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
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.properties = void 0;
4
+ const case_extension_1 = require("../String/case.extension");
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${(0, case_extension_1.convertCase)('camel', 'pascal')}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
+ }, {});
21
+ Object.properties = exports.properties;
@@ -1,20 +1,20 @@
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
+ const case_extension_1 = require("../String/case.extension");
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${(0, case_extension_1.convertCase)('camel', 'pascal')}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
+ }, {});
@@ -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 @@
1
+ export * from './case.extension';
@@ -1,21 +1,17 @@
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("./CopyToClipboard"), exports);
18
- __exportStar(require("./GetCSSProperty"), exports);
19
- __exportStar(require("./GetNestedProperty"), exports);
20
- __exportStar(require("./SetNavigationSelected"), exports);
21
- __exportStar(require("./HTMLEvent"), exports);
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("./case.extension"), exports);
@@ -1,17 +1,6 @@
1
- export * from './Array';
2
- export * from './Document';
3
- export * from './Map';
4
- export * from './Object';
5
- export * from './String';
6
- declare global {
7
- interface BooleanConstructor {
8
- /**
9
- * Parses string to boolean. Will only return true if value === "true" otherwise false
10
- */
11
- parseBoolean(value: string): boolean;
12
- }
13
- }
14
- declare function parseBoolean(value: string): boolean;
15
- export declare const BooleanExtensions: {
16
- parseBoolean: typeof parseBoolean;
17
- };
1
+ export * from './Array';
2
+ export * from './Function';
3
+ export * from './Map';
4
+ export * from './Number';
5
+ export * from './Object';
6
+ export * from './String';
@@ -1,30 +1,22 @@
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.BooleanExtensions = void 0;
18
- __exportStar(require("./Array"), exports);
19
- __exportStar(require("./Document"), exports);
20
- __exportStar(require("./Map"), exports);
21
- __exportStar(require("./Object"), exports);
22
- __exportStar(require("./String"), exports);
23
- function parseBoolean(value) {
24
- return value === "true";
25
- }
26
- ;
27
- Boolean.parseBoolean = parseBoolean;
28
- exports.BooleanExtensions = {
29
- parseBoolean
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 __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("./Array"), exports);
18
+ __exportStar(require("./Function"), exports);
19
+ __exportStar(require("./Map"), exports);
20
+ __exportStar(require("./Number"), exports);
21
+ __exportStar(require("./Object"), exports);
22
+ __exportStar(require("./String"), exports);
@@ -1,15 +1,15 @@
1
- import { Arrayable, IElement } from "../Types";
2
- type Events = Record<`on${Capitalize<keyof HTMLElementEventMap>}`, (event: Event) => void>;
3
- /**
4
- * Construction options when creating an HTML element using:
5
- * @see Document.createElement
6
- * @borwwos IElement
7
- * @borrows Arrayable
8
- */
9
- export type ElementOptions = Partial<Events & Record<string, any> & {
10
- id: string;
11
- className: Arrayable<string>;
12
- children: Arrayable<IElement>;
13
- dataset: Record<string, string>;
14
- }>;
15
- export default ElementOptions;
1
+ import { Arrayable, IElement } from "../Types";
2
+ type Events = Record<`on${Capitalize<keyof HTMLElementEventMap>}`, (event: Event) => void>;
3
+ /**
4
+ * Construction options when creating an HTML element using:
5
+ * @see Document.createElement
6
+ * @borwwos IElement
7
+ * @borrows Arrayable
8
+ */
9
+ export type ElementOptions = Partial<Events & Record<string, any> & {
10
+ id: string;
11
+ className: Arrayable<string>;
12
+ children: Arrayable<IElement>;
13
+ dataset: Record<string, string>;
14
+ }>;
15
+ export default ElementOptions;
@@ -1,2 +1,2 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,12 +1,12 @@
1
- import { StringRegex } from "../Types";
2
- /**
3
- * Replacement tool for
4
- * @see String.toSnakeCase
5
- * @see String.toKebabCase
6
- * @borrows StringRegex
7
- */
8
- export interface IReplacement {
9
- replacer?: StringRegex;
10
- replacement?: string;
11
- }
12
- export default IReplacement;
1
+ import { StringRegex } from "../Types";
2
+ /**
3
+ * Replacement tool for
4
+ * @see String.toSnakeCase
5
+ * @see String.toKebabCase
6
+ * @borrows StringRegex
7
+ */
8
+ export interface IReplacement {
9
+ replacer?: StringRegex;
10
+ replacement?: string;
11
+ }
12
+ export default IReplacement;
@@ -1,2 +1,2 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,2 +1,2 @@
1
- export * from './ElementOptions';
2
- export * from './IReplacement';
1
+ export * from './ElementOptions';
2
+ export * from './IReplacement';
@@ -1,18 +1,18 @@
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("./ElementOptions"), exports);
18
- __exportStar(require("./IReplacement"), exports);
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("./ElementOptions"), exports);
18
+ __exportStar(require("./IReplacement"), exports);
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Item is function or T
3
+ */
4
+ export type Functionable<T, Args extends any[] = []> = T | ((...args: Args) => T);
5
+ /**
6
+ * Item is Promise<T> or T
7
+ */
8
+ export type Promisable<T> = T | Promise<T>;
9
+ /**
10
+ * Item is T or null
11
+ */
12
+ export type Nullable<T> = T | null;
13
+ /**
14
+ * Item cannot be null or undefined
15
+ */
16
+ export type NonNullable<T> = T extends null ? never : T extends undefined ? never : T;
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Item is single or multiple
3
+ */
4
+ export type Arrayable<T> = T | Array<T>;
5
+ export type SingleArrayable<T> = T | [T];
6
+ export type TFromArray<T> = T extends Array<infer U> ? U : never;
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,9 +1,9 @@
1
- /**
2
- * Construct a type with the properties of Type except for those in type Properties.
3
- */
4
- export type BetterOmit<Type, Properties extends keyof Type> = Omit<Type, Properties>;
5
- /**
6
- * Extract from From those types that are assignable to Properties
7
- */
8
- export type BetterExtract<From, Properties extends From> = Extract<From, Properties>;
9
- export type PartialExcept<From, Properties extends keyof From> = Partial<From> & Required<Pick<From, Properties>>;
1
+ /**
2
+ * Construct a type with the properties of Type except for those in type Properties.
3
+ */
4
+ export type BetterOmit<Type, Properties extends keyof Type> = Omit<Type, Properties>;
5
+ /**
6
+ * Extract from From those types that are assignable to Properties
7
+ */
8
+ export type BetterExtract<From, Properties extends From> = Extract<From, Properties>;
9
+ export type PartialExcept<From, Properties extends keyof From> = Partial<From> & Required<Pick<From, Properties>>;
@@ -1,2 +1,2 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,8 @@
1
+ /**
2
+ * C# Guid representation
3
+ */
4
+ export type Guid = string;
5
+ /**
6
+ * C# TimeSpan representation from JSON
7
+ */
8
+ export type TimeSpanType = string;
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,6 +1,6 @@
1
- export type LongMonth = 'Janurary' | 'February' | 'March' | 'April' | 'May' | 'June' | 'July' | 'August' | 'September' | 'October' | 'November' | 'December';
2
- export type ShortMonth = 'Jan' | 'Feb' | 'Mar' | 'Apr' | 'May' | 'Jun' | 'Jul' | 'Aug' | 'Sep' | 'Oct' | 'Nov' | 'Dec';
3
- export type Month = LongMonth | ShortMonth;
4
- export type ShortDay = 'Mon' | 'Tue' | 'Wed' | 'Thu' | 'Fri' | 'Sat' | 'Sun';
5
- export type LongDay = `${'Mon' | 'Tues' | 'Wednes' | 'Thurs' | 'Fri' | 'Satur' | 'Sun'}day`;
6
- export type Day = ShortDay | LongDay;
1
+ export type LongMonth = 'January' | 'February' | 'March' | 'April' | 'May' | 'June' | 'July' | 'August' | 'September' | 'October' | 'November' | 'December';
2
+ export type ShortMonth = 'Jan' | 'Feb' | 'Mar' | 'Apr' | 'May' | 'Jun' | 'Jul' | 'Aug' | 'Sep' | 'Oct' | 'Nov' | 'Dec';
3
+ export type Month = LongMonth | ShortMonth;
4
+ export type ShortDay = 'Mon' | 'Tue' | 'Wed' | 'Thu' | 'Fri' | 'Sat' | 'Sun';
5
+ export type LongDay = `${'Mon' | 'Tues' | 'Wednes' | 'Thurs' | 'Fri' | 'Satur' | 'Sun'}day`;
6
+ export type Day = ShortDay | LongDay;
@@ -1,2 +1,2 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,10 +1,10 @@
1
- /**
2
- * Default eventhandler mapper. Object with properties that are arrays
3
- */
4
- export type BaseEvent<Keys extends string, Types extends Array<any>> = Record<Keys, Types>;
5
- /**
6
- * Eventhandler type for:
7
- * @see EventCollection
8
- * @borrows BaseEvent
9
- */
10
- export type EventHandler<Events extends BaseEvent<string, Array<any>> = BaseEvent<string, Array<any>>, Event extends keyof Events = keyof Events, ReturnType = any> = (...args: Events[Event]) => ReturnType;
1
+ /**
2
+ * Default event-handler mapper. Object with properties that are arrays
3
+ */
4
+ export type BaseEvent<Keys extends string, Types extends Array<any>> = Record<Keys, Types>;
5
+ /**
6
+ * Event-handler type for:
7
+ * @see EventCollection
8
+ * @borrows BaseEvent
9
+ */
10
+ export type EventHandler<Events extends BaseEvent<string, Array<any>> = BaseEvent<string, Array<any>>, Event extends keyof Events = keyof Events, ReturnType = any> = (...args: Events[Event]) => ReturnType;
@@ -1,2 +1,2 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,5 @@
1
+ export type NewReturnType<Function extends (...args: any[]) => any, NewReturnType extends any> = (...args: Parameters<Function>) => NewReturnType;
2
+ export type PromisedReturn<Function extends (...args: any[]) => any> = NewReturnType<Function, Promise<ReturnType<Function>>>;
3
+ export type NoFunctions<T> = {
4
+ [K in keyof T]: T[K] extends Function ? never : T[K];
5
+ };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Return types of T
3
+ */
4
+ export type ValueOf<T> = T[keyof T];
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,13 +1,34 @@
1
- /**
2
- * Filters all properties from From that has the return type of Type
3
- */
4
- export type PropertiesWith<Type, From> = {
5
- [Key in keyof From as From[Key] extends Type ? Key : never]: From[Key];
6
- };
7
- export default PropertiesWith;
8
- /**
9
- * Fitlers all properties from From that don't have the return type of Type
10
- */
11
- export type PropertiesWithout<Type, From> = {
12
- [Key in keyof From as From[Key] extends Type ? never : Key]: From[Key];
13
- };
1
+ /**
2
+ * Filters all properties from From that has the return type of Type
3
+ */
4
+ export type PropertiesWith<Type, From> = {
5
+ [Key in keyof From as From[Key] extends Type ? Key : never]: From[Key];
6
+ };
7
+ export default PropertiesWith;
8
+ /**
9
+ * Fitlers all properties from From that don't have the return type of Type
10
+ */
11
+ export type PropertiesWithout<Type, From> = {
12
+ [Key in keyof From as From[Key] extends Type ? never : Key]: From[Key];
13
+ };
14
+ /**
15
+ * GetRepeatedKeys<[
16
+ * { username: string, password: string },
17
+ * { username: number, email: string },
18
+ * ]> // { username: string | number }
19
+ */
20
+ export type GetRepeatedKeys<Types extends Array<any>> = (Types extends [infer First, infer Second, ...infer Rest] ? First extends object ? Second extends object ? {
21
+ [Key in Extract<keyof First, keyof Second>]: First[Key] | Second[Key];
22
+ } & GetRepeatedKeys<Rest> : {} : {} : {});
23
+ /**
24
+ * Situation: Model = Character | Artifact | Domain
25
+ * Type must include generic type T, which is the Model type
26
+ * Type must also include generic type TProps, which is the properties of the Model type. Selected properties of TProps must extract the types of Model whose properties has been selected.
27
+ *
28
+ * Example:
29
+ * type Model = Character | Artifact | Domain
30
+ * Properties<Model, 'name' | 'rarity'>
31
+ *
32
+ * Result: Character | Artifact, because only Character and Artifact have 'name' and 'rarity' properties
33
+ */
34
+ export type ModelWithProps<T, TProps extends (keyof T | string)> = T extends Record<TProps, any> ? T : never;
@@ -1,2 +1,2 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1 @@
1
+ export type Autocomplete<T> = T | (string & {});
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,16 +1,22 @@
1
- /**
2
- * Converts Start types to Switch types in From type
3
- */
4
- export type TransformType<From, Start, Switch> = {
5
- [Key in keyof From]: From[Key] extends Start ? Switch : From[Key];
6
- };
7
- /**
8
- * Returns object with properties matching BaseType with types of NewType
9
- */
10
- export type TransformTypes<From, BaseType, NewType> = Record<keyof {
11
- [Key in keyof From as From[Key] extends BaseType ? Key : never]: Key;
12
- }, NewType>;
13
- export type Json<T> = {
14
- [Key in keyof T]: T[Key] extends object ? Json<T[Key]> : T[Key] extends Array<infer U> ? Array<Json<U>> : T[Key] extends number | string | boolean | null ? T[Key] : string;
15
- };
16
- export default TransformTypes;
1
+ /**
2
+ * Converts Start types to Switch types in From type
3
+ */
4
+ export type TransformType<From, Start, Switch> = {
5
+ [Key in keyof From]: From[Key] extends Start ? Switch : From[Key];
6
+ };
7
+ /**
8
+ * Returns object with properties matching BaseType with types of NewType
9
+ */
10
+ export type TransformTypes<From, BaseType, NewType> = Record<keyof {
11
+ [Key in keyof From as From[Key] extends BaseType ? Key : never]: Key;
12
+ }, NewType>;
13
+ export type Json<T> = {
14
+ [Key in keyof T]: T[Key] extends object ? Json<T[Key]> : T[Key] extends Array<infer U> ? Array<Json<U>> : T[Key] extends number | string | boolean | null ? T[Key] : string;
15
+ };
16
+ /**
17
+ * Type's properties are ReturnType
18
+ */
19
+ export type AllPropsAre<ReturnType> = {
20
+ [key: string]: ReturnType;
21
+ };
22
+ export default TransformTypes;
@@ -1,2 +1,2 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });