@rootreeweb/js-lib 4.0.10

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 (218) hide show
  1. package/README.md +49 -0
  2. package/dist/cjs/browser/dom.cjs +95 -0
  3. package/dist/cjs/browser/dom.d.ts +44 -0
  4. package/dist/cjs/browser/dom.d.ts.map +1 -0
  5. package/dist/cjs/browser/dom.js.map +1 -0
  6. package/dist/cjs/browser/download.cjs +40 -0
  7. package/dist/cjs/browser/download.d.ts +16 -0
  8. package/dist/cjs/browser/download.d.ts.map +1 -0
  9. package/dist/cjs/browser/download.js.map +1 -0
  10. package/dist/cjs/browser/index.cjs +20 -0
  11. package/dist/cjs/browser/index.d.ts +4 -0
  12. package/dist/cjs/browser/index.d.ts.map +1 -0
  13. package/dist/cjs/browser/index.js.map +1 -0
  14. package/dist/cjs/browser/queryOrThrow.cjs +42 -0
  15. package/dist/cjs/browser/queryOrThrow.d.ts +44 -0
  16. package/dist/cjs/browser/queryOrThrow.d.ts.map +1 -0
  17. package/dist/cjs/browser/queryOrThrow.js.map +1 -0
  18. package/dist/cjs/general/arrays.cjs +151 -0
  19. package/dist/cjs/general/arrays.d.ts +70 -0
  20. package/dist/cjs/general/arrays.d.ts.map +1 -0
  21. package/dist/cjs/general/arrays.js.map +1 -0
  22. package/dist/cjs/general/boolean.cjs +19 -0
  23. package/dist/cjs/general/boolean.d.ts +10 -0
  24. package/dist/cjs/general/boolean.d.ts.map +1 -0
  25. package/dist/cjs/general/boolean.js.map +1 -0
  26. package/dist/cjs/general/clock.cjs +22 -0
  27. package/dist/cjs/general/clock.d.ts +12 -0
  28. package/dist/cjs/general/clock.d.ts.map +1 -0
  29. package/dist/cjs/general/clock.js.map +1 -0
  30. package/dist/cjs/general/dates/create.cjs +81 -0
  31. package/dist/cjs/general/dates/create.d.ts +54 -0
  32. package/dist/cjs/general/dates/create.d.ts.map +1 -0
  33. package/dist/cjs/general/dates/create.js.map +1 -0
  34. package/dist/cjs/general/dates/dates.cjs +88 -0
  35. package/dist/cjs/general/dates/dates.d.ts +56 -0
  36. package/dist/cjs/general/dates/dates.d.ts.map +1 -0
  37. package/dist/cjs/general/dates/dates.js.map +1 -0
  38. package/dist/cjs/general/dates/get.cjs +77 -0
  39. package/dist/cjs/general/dates/get.d.ts +41 -0
  40. package/dist/cjs/general/dates/get.d.ts.map +1 -0
  41. package/dist/cjs/general/dates/get.js.map +1 -0
  42. package/dist/cjs/general/dates/index.cjs +20 -0
  43. package/dist/cjs/general/dates/index.d.ts +4 -0
  44. package/dist/cjs/general/dates/index.d.ts.map +1 -0
  45. package/dist/cjs/general/dates/index.js.map +1 -0
  46. package/dist/cjs/general/forms.cjs +31 -0
  47. package/dist/cjs/general/forms.d.ts +17 -0
  48. package/dist/cjs/general/forms.d.ts.map +1 -0
  49. package/dist/cjs/general/forms.js.map +1 -0
  50. package/dist/cjs/general/images.cjs +23 -0
  51. package/dist/cjs/general/images.d.ts +17 -0
  52. package/dist/cjs/general/images.d.ts.map +1 -0
  53. package/dist/cjs/general/images.js.map +1 -0
  54. package/dist/cjs/general/index.cjs +31 -0
  55. package/dist/cjs/general/index.d.ts +15 -0
  56. package/dist/cjs/general/index.d.ts.map +1 -0
  57. package/dist/cjs/general/index.js.map +1 -0
  58. package/dist/cjs/general/localization.cjs +199 -0
  59. package/dist/cjs/general/localization.d.ts +83 -0
  60. package/dist/cjs/general/localization.d.ts.map +1 -0
  61. package/dist/cjs/general/localization.js.map +1 -0
  62. package/dist/cjs/general/maps.cjs +63 -0
  63. package/dist/cjs/general/maps.d.ts +35 -0
  64. package/dist/cjs/general/maps.d.ts.map +1 -0
  65. package/dist/cjs/general/maps.js.map +1 -0
  66. package/dist/cjs/general/messenger/createMessenger.cjs +68 -0
  67. package/dist/cjs/general/messenger/createMessenger.d.ts +10 -0
  68. package/dist/cjs/general/messenger/createMessenger.d.ts.map +1 -0
  69. package/dist/cjs/general/messenger/createMessenger.js.map +1 -0
  70. package/dist/cjs/general/messenger/index.cjs +19 -0
  71. package/dist/cjs/general/messenger/index.d.ts +3 -0
  72. package/dist/cjs/general/messenger/index.d.ts.map +1 -0
  73. package/dist/cjs/general/messenger/index.js.map +1 -0
  74. package/dist/cjs/general/messenger/types.cjs +3 -0
  75. package/dist/cjs/general/messenger/types.d.ts +26 -0
  76. package/dist/cjs/general/messenger/types.d.ts.map +1 -0
  77. package/dist/cjs/general/messenger/types.js.map +1 -0
  78. package/dist/cjs/general/namedEntities.cjs +260 -0
  79. package/dist/cjs/general/namedEntities.d.ts +256 -0
  80. package/dist/cjs/general/namedEntities.d.ts.map +1 -0
  81. package/dist/cjs/general/namedEntities.js.map +1 -0
  82. package/dist/cjs/general/numbers.cjs +94 -0
  83. package/dist/cjs/general/numbers.d.ts +43 -0
  84. package/dist/cjs/general/numbers.d.ts.map +1 -0
  85. package/dist/cjs/general/numbers.js.map +1 -0
  86. package/dist/cjs/general/objects.cjs +98 -0
  87. package/dist/cjs/general/objects.d.ts +45 -0
  88. package/dist/cjs/general/objects.d.ts.map +1 -0
  89. package/dist/cjs/general/objects.js.map +1 -0
  90. package/dist/cjs/general/sorting.cjs +72 -0
  91. package/dist/cjs/general/sorting.d.ts +32 -0
  92. package/dist/cjs/general/sorting.d.ts.map +1 -0
  93. package/dist/cjs/general/sorting.js.map +1 -0
  94. package/dist/cjs/general/string.cjs +73 -0
  95. package/dist/cjs/general/string.d.ts +31 -0
  96. package/dist/cjs/general/string.d.ts.map +1 -0
  97. package/dist/cjs/general/string.js.map +1 -0
  98. package/dist/cjs/general/timeout.cjs +17 -0
  99. package/dist/cjs/general/timeout.d.ts +8 -0
  100. package/dist/cjs/general/timeout.d.ts.map +1 -0
  101. package/dist/cjs/general/timeout.js.map +1 -0
  102. package/dist/cjs/index.cjs +20 -0
  103. package/dist/cjs/index.d.ts +4 -0
  104. package/dist/cjs/index.d.ts.map +1 -0
  105. package/dist/cjs/index.js.map +1 -0
  106. package/dist/cjs/node/index.cjs +30 -0
  107. package/dist/cjs/node/index.d.ts +25 -0
  108. package/dist/cjs/node/index.d.ts.map +1 -0
  109. package/dist/cjs/node/index.js.map +1 -0
  110. package/dist/esm/browser/dom.d.ts +44 -0
  111. package/dist/esm/browser/dom.d.ts.map +1 -0
  112. package/dist/esm/browser/dom.js +88 -0
  113. package/dist/esm/browser/dom.js.map +1 -0
  114. package/dist/esm/browser/download.d.ts +16 -0
  115. package/dist/esm/browser/download.d.ts.map +1 -0
  116. package/dist/esm/browser/download.js +36 -0
  117. package/dist/esm/browser/download.js.map +1 -0
  118. package/dist/esm/browser/index.d.ts +4 -0
  119. package/dist/esm/browser/index.d.ts.map +1 -0
  120. package/dist/esm/browser/index.js +4 -0
  121. package/dist/esm/browser/index.js.map +1 -0
  122. package/dist/esm/browser/queryOrThrow.d.ts +44 -0
  123. package/dist/esm/browser/queryOrThrow.d.ts.map +1 -0
  124. package/dist/esm/browser/queryOrThrow.js +39 -0
  125. package/dist/esm/browser/queryOrThrow.js.map +1 -0
  126. package/dist/esm/general/arrays.d.ts +70 -0
  127. package/dist/esm/general/arrays.d.ts.map +1 -0
  128. package/dist/esm/general/arrays.js +144 -0
  129. package/dist/esm/general/arrays.js.map +1 -0
  130. package/dist/esm/general/boolean.d.ts +10 -0
  131. package/dist/esm/general/boolean.d.ts.map +1 -0
  132. package/dist/esm/general/boolean.js +16 -0
  133. package/dist/esm/general/boolean.js.map +1 -0
  134. package/dist/esm/general/clock.d.ts +12 -0
  135. package/dist/esm/general/clock.d.ts.map +1 -0
  136. package/dist/esm/general/clock.js +19 -0
  137. package/dist/esm/general/clock.js.map +1 -0
  138. package/dist/esm/general/dates/create.d.ts +54 -0
  139. package/dist/esm/general/dates/create.d.ts.map +1 -0
  140. package/dist/esm/general/dates/create.js +73 -0
  141. package/dist/esm/general/dates/create.js.map +1 -0
  142. package/dist/esm/general/dates/dates.d.ts +56 -0
  143. package/dist/esm/general/dates/dates.d.ts.map +1 -0
  144. package/dist/esm/general/dates/dates.js +82 -0
  145. package/dist/esm/general/dates/dates.js.map +1 -0
  146. package/dist/esm/general/dates/get.d.ts +41 -0
  147. package/dist/esm/general/dates/get.d.ts.map +1 -0
  148. package/dist/esm/general/dates/get.js +70 -0
  149. package/dist/esm/general/dates/get.js.map +1 -0
  150. package/dist/esm/general/dates/index.d.ts +4 -0
  151. package/dist/esm/general/dates/index.d.ts.map +1 -0
  152. package/dist/esm/general/dates/index.js +4 -0
  153. package/dist/esm/general/dates/index.js.map +1 -0
  154. package/dist/esm/general/forms.d.ts +17 -0
  155. package/dist/esm/general/forms.d.ts.map +1 -0
  156. package/dist/esm/general/forms.js +27 -0
  157. package/dist/esm/general/forms.js.map +1 -0
  158. package/dist/esm/general/images.d.ts +17 -0
  159. package/dist/esm/general/images.d.ts.map +1 -0
  160. package/dist/esm/general/images.js +20 -0
  161. package/dist/esm/general/images.js.map +1 -0
  162. package/dist/esm/general/index.d.ts +15 -0
  163. package/dist/esm/general/index.d.ts.map +1 -0
  164. package/dist/esm/general/index.js +15 -0
  165. package/dist/esm/general/index.js.map +1 -0
  166. package/dist/esm/general/localization.d.ts +83 -0
  167. package/dist/esm/general/localization.d.ts.map +1 -0
  168. package/dist/esm/general/localization.js +188 -0
  169. package/dist/esm/general/localization.js.map +1 -0
  170. package/dist/esm/general/maps.d.ts +35 -0
  171. package/dist/esm/general/maps.d.ts.map +1 -0
  172. package/dist/esm/general/maps.js +59 -0
  173. package/dist/esm/general/maps.js.map +1 -0
  174. package/dist/esm/general/messenger/createMessenger.d.ts +10 -0
  175. package/dist/esm/general/messenger/createMessenger.d.ts.map +1 -0
  176. package/dist/esm/general/messenger/createMessenger.js +65 -0
  177. package/dist/esm/general/messenger/createMessenger.js.map +1 -0
  178. package/dist/esm/general/messenger/index.d.ts +3 -0
  179. package/dist/esm/general/messenger/index.d.ts.map +1 -0
  180. package/dist/esm/general/messenger/index.js +3 -0
  181. package/dist/esm/general/messenger/index.js.map +1 -0
  182. package/dist/esm/general/messenger/types.d.ts +26 -0
  183. package/dist/esm/general/messenger/types.d.ts.map +1 -0
  184. package/dist/esm/general/messenger/types.js +2 -0
  185. package/dist/esm/general/messenger/types.js.map +1 -0
  186. package/dist/esm/general/namedEntities.d.ts +256 -0
  187. package/dist/esm/general/namedEntities.d.ts.map +1 -0
  188. package/dist/esm/general/namedEntities.js +257 -0
  189. package/dist/esm/general/namedEntities.js.map +1 -0
  190. package/dist/esm/general/numbers.d.ts +43 -0
  191. package/dist/esm/general/numbers.d.ts.map +1 -0
  192. package/dist/esm/general/numbers.js +87 -0
  193. package/dist/esm/general/numbers.js.map +1 -0
  194. package/dist/esm/general/objects.d.ts +45 -0
  195. package/dist/esm/general/objects.d.ts.map +1 -0
  196. package/dist/esm/general/objects.js +91 -0
  197. package/dist/esm/general/objects.js.map +1 -0
  198. package/dist/esm/general/sorting.d.ts +32 -0
  199. package/dist/esm/general/sorting.d.ts.map +1 -0
  200. package/dist/esm/general/sorting.js +67 -0
  201. package/dist/esm/general/sorting.js.map +1 -0
  202. package/dist/esm/general/string.d.ts +31 -0
  203. package/dist/esm/general/string.d.ts.map +1 -0
  204. package/dist/esm/general/string.js +68 -0
  205. package/dist/esm/general/string.js.map +1 -0
  206. package/dist/esm/general/timeout.d.ts +8 -0
  207. package/dist/esm/general/timeout.d.ts.map +1 -0
  208. package/dist/esm/general/timeout.js +14 -0
  209. package/dist/esm/general/timeout.js.map +1 -0
  210. package/dist/esm/index.d.ts +4 -0
  211. package/dist/esm/index.d.ts.map +1 -0
  212. package/dist/esm/index.js +4 -0
  213. package/dist/esm/index.js.map +1 -0
  214. package/dist/esm/node/index.d.ts +25 -0
  215. package/dist/esm/node/index.d.ts.map +1 -0
  216. package/dist/esm/node/index.js +27 -0
  217. package/dist/esm/node/index.js.map +1 -0
  218. package/package.json +62 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"clock.js","sourceRoot":"","sources":["../../../src/general/clock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAE3C;;;;;GAKG;AACH,MAAM,UAAU,iBAAiB,CAAC,IAAU;IAK3C,MAAM,iBAAiB,GAAG,IAAI,CAAC,UAAU,EAAE,GAAG,EAAE,CAAC;IACjD,MAAM,gBAAgB,GAAG,IAAI,CAAC,UAAU,EAAE,GAAG,EAAE,CAAC;IAChD,MAAM,iBAAiB,GAAG,CAAC,gBAAgB,GAAG,IAAI,CAAC,UAAU,EAAE,CAAC,GAAG,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC;IAC7E,MAAM,cAAc,GAAG,CAAC,IAAI,CAAC,QAAQ,EAAE,GAAG,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,CAAC;IACxD,MAAM,eAAe,GACpB,CAAC,cAAc,GAAG,gBAAgB,GAAG,IAAI,CAAC,UAAU,EAAE,CAAC,GAAG,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC;IAE1E,MAAM,KAAK,GAAG,WAAW,CAAC,eAAe,GAAG,GAAG,EAAE,CAAC,CAAC,CAAC;IACpD,MAAM,OAAO,GAAG,WAAW,CAAC,iBAAiB,GAAG,GAAG,EAAE,CAAC,CAAC,CAAC;IACxD,MAAM,OAAO,GAAG,WAAW,CAAC,iBAAiB,GAAG,GAAG,EAAE,CAAC,CAAC,CAAC;IACxD,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC;AACpC,CAAC","sourcesContent":["import { toPrecision } from \"./numbers.js\";\n\n/**\n * Gets the rotations for the clock hands, with 0deg being 12 o'clock.\n *\n * @param date The date to get the rotations for.\n * @returns The rotations for the clock hands.\n */\nexport function getClockRotations(date: Date): {\n\thours: number;\n\tminutes: number;\n\tseconds: number;\n} {\n\tconst secondsPercentage = date.getSeconds() / 60;\n\tconst minutesInSeconds = date.getMinutes() * 60;\n\tconst minutesPercentage = (minutesInSeconds + date.getSeconds()) / (60 * 60);\n\tconst hoursInSeconds = (date.getHours() % 12) * 60 * 60;\n\tconst hoursPercentage =\n\t\t(hoursInSeconds + minutesInSeconds + date.getSeconds()) / (12 * 60 * 60);\n\n\tconst hours = toPrecision(hoursPercentage * 360, 2);\n\tconst minutes = toPrecision(minutesPercentage * 360, 2);\n\tconst seconds = toPrecision(secondsPercentage * 360, 2);\n\treturn { hours, minutes, seconds };\n}\n"]}
@@ -0,0 +1,54 @@
1
+ import type { DateMethod } from "./dates.js";
2
+ /**
3
+ * Provides a way to create a new Date object that is an exact copy of an
4
+ * existing Date object.
5
+ *
6
+ * @param date The Date object to clone.
7
+ * @returns A new Date object that is an exact copy of the original.
8
+ */
9
+ export declare function cloneDate(date: Date): Date;
10
+ /**
11
+ * Provides a way to obtain a new Date object with a specific component,
12
+ * adjusted by a given value while preserving the other components of the
13
+ * original Date object.
14
+ *
15
+ * @param oldDate The Date object to clone.
16
+ * @param field The component of the Date object to adjust.
17
+ * @param adjustment The amount to adjust the component by.
18
+ * @returns A new Date object with the specified component adjusted.
19
+ */
20
+ export declare function createDateFromAdjustment(oldDate: Date, field: DateMethod, adjustment: number): Date;
21
+ /**
22
+ * Provides a way to obtain a new Date object with the day of the month modified
23
+ * while preserving the other components of the original Date object.
24
+ *
25
+ * @param oldDate The Date object to clone.
26
+ * @param date The day of the month to set.
27
+ * @returns A new Date object with the day of the month modified.
28
+ */
29
+ export declare function createDateFromDate(oldDate: Date, date: number): Date;
30
+ /**
31
+ * Provides a way to obtain a new Date object that is created from a time
32
+ * string.
33
+ *
34
+ * @param dateString The string to convert to a Date object.
35
+ * @returns A Date object created from the string.
36
+ */
37
+ export declare function createDateFromString(dateString: string): Date;
38
+ /**
39
+ * Provides a way to obtain a new Date object that represents the end of that
40
+ * day.
41
+ *
42
+ * @param oldDate The Date object to clone.
43
+ * @returns A date object representing the end of the day.
44
+ */
45
+ export declare function createEndOfDay(oldDate: Date): Date;
46
+ /**
47
+ * Provides a way to obtain a new Date object that represents the start of that
48
+ * day.
49
+ *
50
+ * @param oldDate The Date object to clone.
51
+ * @returns A date object representing the start of the day.
52
+ */
53
+ export declare function createStartOfDay(oldDate: Date): Date;
54
+ //# sourceMappingURL=create.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../../../src/general/dates/create.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAG7C;;;;;;GAMG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,CAE1C;AAED;;;;;;;;;GASG;AACH,wBAAgB,wBAAwB,CACvC,OAAO,EAAE,IAAI,EACb,KAAK,EAAE,UAAU,EACjB,UAAU,EAAE,MAAM,GAChB,IAAI,CAON;AACD;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAEpE;AAED;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,CAE7D;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,IAAI,GAAG,IAAI,CAGlD;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,IAAI,GAAG,IAAI,CAGpD"}
@@ -0,0 +1,73 @@
1
+ import { DateEquivalents } from "./dates.js";
2
+ /**
3
+ * Provides a way to create a new Date object that is an exact copy of an
4
+ * existing Date object.
5
+ *
6
+ * @param date The Date object to clone.
7
+ * @returns A new Date object that is an exact copy of the original.
8
+ */
9
+ export function cloneDate(date) {
10
+ return new Date(date);
11
+ }
12
+ /**
13
+ * Provides a way to obtain a new Date object with a specific component,
14
+ * adjusted by a given value while preserving the other components of the
15
+ * original Date object.
16
+ *
17
+ * @param oldDate The Date object to clone.
18
+ * @param field The component of the Date object to adjust.
19
+ * @param adjustment The amount to adjust the component by.
20
+ * @returns A new Date object with the specified component adjusted.
21
+ */
22
+ export function createDateFromAdjustment(oldDate, field, adjustment) {
23
+ const method = DateEquivalents[field];
24
+ const date = cloneDate(oldDate);
25
+ const oldFieldValue = date[method.get]();
26
+ const newFieldValue = oldFieldValue + adjustment;
27
+ const mutatedDate = date[method.set](newFieldValue);
28
+ return new Date(mutatedDate);
29
+ }
30
+ /**
31
+ * Provides a way to obtain a new Date object with the day of the month modified
32
+ * while preserving the other components of the original Date object.
33
+ *
34
+ * @param oldDate The Date object to clone.
35
+ * @param date The day of the month to set.
36
+ * @returns A new Date object with the day of the month modified.
37
+ */
38
+ export function createDateFromDate(oldDate, date) {
39
+ return new Date(oldDate.setDate(date));
40
+ }
41
+ /**
42
+ * Provides a way to obtain a new Date object that is created from a time
43
+ * string.
44
+ *
45
+ * @param dateString The string to convert to a Date object.
46
+ * @returns A Date object created from the string.
47
+ */
48
+ export function createDateFromString(dateString) {
49
+ return new Date(dateString);
50
+ }
51
+ /**
52
+ * Provides a way to obtain a new Date object that represents the end of that
53
+ * day.
54
+ *
55
+ * @param oldDate The Date object to clone.
56
+ * @returns A date object representing the end of the day.
57
+ */
58
+ export function createEndOfDay(oldDate) {
59
+ const date = cloneDate(oldDate);
60
+ return new Date(date.setHours(23, 59, 59, 999));
61
+ }
62
+ /**
63
+ * Provides a way to obtain a new Date object that represents the start of that
64
+ * day.
65
+ *
66
+ * @param oldDate The Date object to clone.
67
+ * @returns A date object representing the start of the day.
68
+ */
69
+ export function createStartOfDay(oldDate) {
70
+ const date = cloneDate(oldDate);
71
+ return new Date(date.setHours(0, 0, 0, 0));
72
+ }
73
+ //# sourceMappingURL=create.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create.js","sourceRoot":"","sources":["../../../../src/general/dates/create.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAE7C;;;;;;GAMG;AACH,MAAM,UAAU,SAAS,CAAC,IAAU;IACnC,OAAO,IAAI,IAAI,CAAC,IAAI,CAAC,CAAC;AACvB,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,wBAAwB,CACvC,OAAa,EACb,KAAiB,EACjB,UAAkB;IAElB,MAAM,MAAM,GAAG,eAAe,CAAC,KAAK,CAAC,CAAC;IACtC,MAAM,IAAI,GAAG,SAAS,CAAC,OAAO,CAAC,CAAC;IAChC,MAAM,aAAa,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC;IACzC,MAAM,aAAa,GAAG,aAAa,GAAG,UAAU,CAAC;IACjD,MAAM,WAAW,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,aAAa,CAAC,CAAC;IACpD,OAAO,IAAI,IAAI,CAAC,WAAW,CAAC,CAAC;AAC9B,CAAC;AACD;;;;;;;GAOG;AACH,MAAM,UAAU,kBAAkB,CAAC,OAAa,EAAE,IAAY;IAC7D,OAAO,IAAI,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;AACxC,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,oBAAoB,CAAC,UAAkB;IACtD,OAAO,IAAI,IAAI,CAAC,UAAU,CAAC,CAAC;AAC7B,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,cAAc,CAAC,OAAa;IAC3C,MAAM,IAAI,GAAG,SAAS,CAAC,OAAO,CAAC,CAAC;IAChC,OAAO,IAAI,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,GAAG,CAAC,CAAC,CAAC;AACjD,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,gBAAgB,CAAC,OAAa;IAC7C,MAAM,IAAI,GAAG,SAAS,CAAC,OAAO,CAAC,CAAC;IAChC,OAAO,IAAI,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;AAC5C,CAAC","sourcesContent":["import type { DateMethod } from \"./dates.js\";\nimport { DateEquivalents } from \"./dates.js\";\n\n/**\n * Provides a way to create a new Date object that is an exact copy of an\n * existing Date object.\n *\n * @param date The Date object to clone.\n * @returns A new Date object that is an exact copy of the original.\n */\nexport function cloneDate(date: Date): Date {\n\treturn new Date(date);\n}\n\n/**\n * Provides a way to obtain a new Date object with a specific component,\n * adjusted by a given value while preserving the other components of the\n * original Date object.\n *\n * @param oldDate The Date object to clone.\n * @param field The component of the Date object to adjust.\n * @param adjustment The amount to adjust the component by.\n * @returns A new Date object with the specified component adjusted.\n */\nexport function createDateFromAdjustment(\n\toldDate: Date,\n\tfield: DateMethod,\n\tadjustment: number,\n): Date {\n\tconst method = DateEquivalents[field];\n\tconst date = cloneDate(oldDate);\n\tconst oldFieldValue = date[method.get]();\n\tconst newFieldValue = oldFieldValue + adjustment;\n\tconst mutatedDate = date[method.set](newFieldValue);\n\treturn new Date(mutatedDate);\n}\n/**\n * Provides a way to obtain a new Date object with the day of the month modified\n * while preserving the other components of the original Date object.\n *\n * @param oldDate The Date object to clone.\n * @param date The day of the month to set.\n * @returns A new Date object with the day of the month modified.\n */\nexport function createDateFromDate(oldDate: Date, date: number): Date {\n\treturn new Date(oldDate.setDate(date));\n}\n\n/**\n * Provides a way to obtain a new Date object that is created from a time\n * string.\n *\n * @param dateString The string to convert to a Date object.\n * @returns A Date object created from the string.\n */\nexport function createDateFromString(dateString: string): Date {\n\treturn new Date(dateString);\n}\n\n/**\n * Provides a way to obtain a new Date object that represents the end of that\n * day.\n *\n * @param oldDate The Date object to clone.\n * @returns A date object representing the end of the day.\n */\nexport function createEndOfDay(oldDate: Date): Date {\n\tconst date = cloneDate(oldDate);\n\treturn new Date(date.setHours(23, 59, 59, 999));\n}\n\n/**\n * Provides a way to obtain a new Date object that represents the start of that\n * day.\n *\n * @param oldDate The Date object to clone.\n * @returns A date object representing the start of the day.\n */\nexport function createStartOfDay(oldDate: Date): Date {\n\tconst date = cloneDate(oldDate);\n\treturn new Date(date.setHours(0, 0, 0, 0));\n}\n"]}
@@ -0,0 +1,56 @@
1
+ /**
2
+ * The DateEquivalents object serves as a mapping of date and time components to
3
+ * their corresponding setter and getter functions in JavaScript's Date object.
4
+ * Each property within DateEquivalents represents a specific component (such as
5
+ * date, time, full year, month, hours, minutes, seconds, and milliseconds) and
6
+ * contains two string values: set: Represents the name of the function that
7
+ * sets the value of the corresponding date or time component. get: Represents
8
+ * the name of the function that retrieves the value of the corresponding date
9
+ * or time component.
10
+ */
11
+ export declare const DateEquivalents: DateEquivalent;
12
+ /** Export */
13
+ export type DateMethod = keyof typeof DateEquivalents;
14
+ /**
15
+ * Provide mappings between date and time components and their corresponding
16
+ * setter and getter function names in the Date object.
17
+ */
18
+ export type DateThing = "date" | "fullYear" | "hours" | "milliseconds" | "minutes" | "month" | "seconds" | "time";
19
+ type DateEquivalent = {
20
+ [k in DateThing]: {
21
+ get: `get${Capitalize<k>}`;
22
+ set: `set${Capitalize<k>}`;
23
+ };
24
+ };
25
+ /**
26
+ * Determines if two Date objects represent the same month, day, and year.
27
+ *
28
+ * @param date1 The first date to compare.
29
+ * @param date2 The second date to compare.
30
+ * @returns A boolean value indicating whether the two dates represent the same
31
+ * month, day, and year.
32
+ */
33
+ export declare function datesMatch(date1: Date, date2: Date): boolean;
34
+ /**
35
+ * Provides a way to determine if a given Date falls within a specified range.
36
+ *
37
+ * @param testDate The date to test.
38
+ * @param startDate The start of the range.
39
+ * @param endDate The end of the range.
40
+ * @returns A boolean value indicating whether the testDate falls within the
41
+ * range.
42
+ */
43
+ export declare function isBetween(testDate: Date, startDate: Date, endDate: Date): boolean;
44
+ /**
45
+ * Compares the year and month components of the month1 and month2 dates. It
46
+ * returns true if the year and month are the same in both dates, and false
47
+ * otherwise.
48
+ *
49
+ * @param month1 The first month to compare.
50
+ * @param month2 The second month to compare.
51
+ * @returns A boolean value indicating whether the year and month components of
52
+ * the two dates are the same.
53
+ */
54
+ export declare function monthsMatch(month1: Date, month2: Date): boolean;
55
+ export {};
56
+ //# sourceMappingURL=dates.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dates.d.ts","sourceRoot":"","sources":["../../../../src/general/dates/dates.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,eAAO,MAAM,eAAe,EAAE,cAiCpB,CAAC;AAEX,aAAa;AACb,MAAM,MAAM,UAAU,GAAG,MAAM,OAAO,eAAe,CAAC;AAEtD;;;GAGG;AACH,MAAM,MAAM,SAAS,GAClB,MAAM,GACN,UAAU,GACV,OAAO,GACP,cAAc,GACd,SAAS,GACT,OAAO,GACP,SAAS,GACT,MAAM,CAAC;AAEV,KAAK,cAAc,GAAG;KACpB,CAAC,IAAI,SAAS,GAAG;QACjB,GAAG,EAAE,MAAM,UAAU,CAAC,CAAC,CAAC,EAAE,CAAC;QAC3B,GAAG,EAAE,MAAM,UAAU,CAAC,CAAC,CAAC,EAAE,CAAC;KAC3B;CACD,CAAC;AAEF;;;;;;;GAOG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,GAAG,OAAO,CAE5D;AAED;;;;;;;;GAQG;AACH,wBAAgB,SAAS,CACxB,QAAQ,EAAE,IAAI,EACd,SAAS,EAAE,IAAI,EACf,OAAO,EAAE,IAAI,GACX,OAAO,CAET;AAED;;;;;;;;;GASG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,GAAG,OAAO,CAK/D"}
@@ -0,0 +1,82 @@
1
+ /**
2
+ * The DateEquivalents object serves as a mapping of date and time components to
3
+ * their corresponding setter and getter functions in JavaScript's Date object.
4
+ * Each property within DateEquivalents represents a specific component (such as
5
+ * date, time, full year, month, hours, minutes, seconds, and milliseconds) and
6
+ * contains two string values: set: Represents the name of the function that
7
+ * sets the value of the corresponding date or time component. get: Represents
8
+ * the name of the function that retrieves the value of the corresponding date
9
+ * or time component.
10
+ */
11
+ export const DateEquivalents = {
12
+ date: {
13
+ get: "getDate",
14
+ set: "setDate",
15
+ },
16
+ fullYear: {
17
+ get: "getFullYear",
18
+ set: "setFullYear",
19
+ },
20
+ hours: {
21
+ get: "getHours",
22
+ set: "setHours",
23
+ },
24
+ milliseconds: {
25
+ get: "getMilliseconds",
26
+ set: "setMilliseconds",
27
+ },
28
+ minutes: {
29
+ get: "getMinutes",
30
+ set: "setMinutes",
31
+ },
32
+ month: {
33
+ get: "getMonth",
34
+ set: "setMonth",
35
+ },
36
+ seconds: {
37
+ get: "getSeconds",
38
+ set: "setSeconds",
39
+ },
40
+ time: {
41
+ get: "getTime",
42
+ set: "setTime",
43
+ },
44
+ };
45
+ /**
46
+ * Determines if two Date objects represent the same month, day, and year.
47
+ *
48
+ * @param date1 The first date to compare.
49
+ * @param date2 The second date to compare.
50
+ * @returns A boolean value indicating whether the two dates represent the same
51
+ * month, day, and year.
52
+ */
53
+ export function datesMatch(date1, date2) {
54
+ return monthsMatch(date1, date2) && date1.getDate() === date2.getDate();
55
+ }
56
+ /**
57
+ * Provides a way to determine if a given Date falls within a specified range.
58
+ *
59
+ * @param testDate The date to test.
60
+ * @param startDate The start of the range.
61
+ * @param endDate The end of the range.
62
+ * @returns A boolean value indicating whether the testDate falls within the
63
+ * range.
64
+ */
65
+ export function isBetween(testDate, startDate, endDate) {
66
+ return testDate >= startDate && testDate <= endDate;
67
+ }
68
+ /**
69
+ * Compares the year and month components of the month1 and month2 dates. It
70
+ * returns true if the year and month are the same in both dates, and false
71
+ * otherwise.
72
+ *
73
+ * @param month1 The first month to compare.
74
+ * @param month2 The second month to compare.
75
+ * @returns A boolean value indicating whether the year and month components of
76
+ * the two dates are the same.
77
+ */
78
+ export function monthsMatch(month1, month2) {
79
+ return (month1.getFullYear() === month2.getFullYear() &&
80
+ month1.getMonth() === month2.getMonth());
81
+ }
82
+ //# sourceMappingURL=dates.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dates.js","sourceRoot":"","sources":["../../../../src/general/dates/dates.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,eAAe,GAAmB;IAC9C,IAAI,EAAE;QACL,GAAG,EAAE,SAAS;QACd,GAAG,EAAE,SAAS;KACd;IACD,QAAQ,EAAE;QACT,GAAG,EAAE,aAAa;QAClB,GAAG,EAAE,aAAa;KAClB;IACD,KAAK,EAAE;QACN,GAAG,EAAE,UAAU;QACf,GAAG,EAAE,UAAU;KACf;IACD,YAAY,EAAE;QACb,GAAG,EAAE,iBAAiB;QACtB,GAAG,EAAE,iBAAiB;KACtB;IACD,OAAO,EAAE;QACR,GAAG,EAAE,YAAY;QACjB,GAAG,EAAE,YAAY;KACjB;IACD,KAAK,EAAE;QACN,GAAG,EAAE,UAAU;QACf,GAAG,EAAE,UAAU;KACf;IACD,OAAO,EAAE;QACR,GAAG,EAAE,YAAY;QACjB,GAAG,EAAE,YAAY;KACjB;IACD,IAAI,EAAE;QACL,GAAG,EAAE,SAAS;QACd,GAAG,EAAE,SAAS;KACd;CACQ,CAAC;AA0BX;;;;;;;GAOG;AACH,MAAM,UAAU,UAAU,CAAC,KAAW,EAAE,KAAW;IAClD,OAAO,WAAW,CAAC,KAAK,EAAE,KAAK,CAAC,IAAI,KAAK,CAAC,OAAO,EAAE,KAAK,KAAK,CAAC,OAAO,EAAE,CAAC;AACzE,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,SAAS,CACxB,QAAc,EACd,SAAe,EACf,OAAa;IAEb,OAAO,QAAQ,IAAI,SAAS,IAAI,QAAQ,IAAI,OAAO,CAAC;AACrD,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,WAAW,CAAC,MAAY,EAAE,MAAY;IACrD,OAAO,CACN,MAAM,CAAC,WAAW,EAAE,KAAK,MAAM,CAAC,WAAW,EAAE;QAC7C,MAAM,CAAC,QAAQ,EAAE,KAAK,MAAM,CAAC,QAAQ,EAAE,CACvC,CAAC;AACH,CAAC","sourcesContent":["/**\n * The DateEquivalents object serves as a mapping of date and time components to\n * their corresponding setter and getter functions in JavaScript's Date object.\n * Each property within DateEquivalents represents a specific component (such as\n * date, time, full year, month, hours, minutes, seconds, and milliseconds) and\n * contains two string values: set: Represents the name of the function that\n * sets the value of the corresponding date or time component. get: Represents\n * the name of the function that retrieves the value of the corresponding date\n * or time component.\n */\nexport const DateEquivalents: DateEquivalent = {\n\tdate: {\n\t\tget: \"getDate\",\n\t\tset: \"setDate\",\n\t},\n\tfullYear: {\n\t\tget: \"getFullYear\",\n\t\tset: \"setFullYear\",\n\t},\n\thours: {\n\t\tget: \"getHours\",\n\t\tset: \"setHours\",\n\t},\n\tmilliseconds: {\n\t\tget: \"getMilliseconds\",\n\t\tset: \"setMilliseconds\",\n\t},\n\tminutes: {\n\t\tget: \"getMinutes\",\n\t\tset: \"setMinutes\",\n\t},\n\tmonth: {\n\t\tget: \"getMonth\",\n\t\tset: \"setMonth\",\n\t},\n\tseconds: {\n\t\tget: \"getSeconds\",\n\t\tset: \"setSeconds\",\n\t},\n\ttime: {\n\t\tget: \"getTime\",\n\t\tset: \"setTime\",\n\t},\n} as const;\n\n/** Export */\nexport type DateMethod = keyof typeof DateEquivalents;\n\n/**\n * Provide mappings between date and time components and their corresponding\n * setter and getter function names in the Date object.\n */\nexport type DateThing =\n\t| \"date\"\n\t| \"fullYear\"\n\t| \"hours\"\n\t| \"milliseconds\"\n\t| \"minutes\"\n\t| \"month\"\n\t| \"seconds\"\n\t| \"time\";\n\ntype DateEquivalent = {\n\t[k in DateThing]: {\n\t\tget: `get${Capitalize<k>}`;\n\t\tset: `set${Capitalize<k>}`;\n\t};\n};\n\n/**\n * Determines if two Date objects represent the same month, day, and year.\n *\n * @param date1 The first date to compare.\n * @param date2 The second date to compare.\n * @returns A boolean value indicating whether the two dates represent the same\n * month, day, and year.\n */\nexport function datesMatch(date1: Date, date2: Date): boolean {\n\treturn monthsMatch(date1, date2) && date1.getDate() === date2.getDate();\n}\n\n/**\n * Provides a way to determine if a given Date falls within a specified range.\n *\n * @param testDate The date to test.\n * @param startDate The start of the range.\n * @param endDate The end of the range.\n * @returns A boolean value indicating whether the testDate falls within the\n * range.\n */\nexport function isBetween(\n\ttestDate: Date,\n\tstartDate: Date,\n\tendDate: Date,\n): boolean {\n\treturn testDate >= startDate && testDate <= endDate;\n}\n\n/**\n * Compares the year and month components of the month1 and month2 dates. It\n * returns true if the year and month are the same in both dates, and false\n * otherwise.\n *\n * @param month1 The first month to compare.\n * @param month2 The second month to compare.\n * @returns A boolean value indicating whether the year and month components of\n * the two dates are the same.\n */\nexport function monthsMatch(month1: Date, month2: Date): boolean {\n\treturn (\n\t\tmonth1.getFullYear() === month2.getFullYear() &&\n\t\tmonth1.getMonth() === month2.getMonth()\n\t);\n}\n"]}
@@ -0,0 +1,41 @@
1
+ /**
2
+ * Provides a way to obtain the number of days in a specific month of a
3
+ * particular year.
4
+ *
5
+ * @param year The year for which to obtain the number of days in a month.
6
+ * @param month The month for which to obtain the number of days.
7
+ * @returns The number of days in the specified month of the specified year.
8
+ */
9
+ export declare function getDaysInMonth(year: number, month: number): number;
10
+ /**
11
+ * Calculates the UTC offset caused by daylight savings time between the first
12
+ * date and the second date.
13
+ *
14
+ * @param firstTime The first date.
15
+ * @param secondTime The second date.
16
+ * @returns The UTC offset caused by daylight savings time between the first and
17
+ * second dates.
18
+ */
19
+ export declare function getDSTOffset(firstTime: Date, secondTime: Date): -60 | 0 | 60;
20
+ /**
21
+ * Provides a way to obtain the Date object representing the first day of the
22
+ * current week, with the time portion set to the start of the day.
23
+ *
24
+ * @returns A Date object representing the first day of the current week.
25
+ */
26
+ export declare function getFirstDayOfWeek(): Date;
27
+ /**
28
+ * Provides a way to obtain the Date object representing the last day of the
29
+ * current week, with the time portion set to the end of the day.
30
+ *
31
+ * @returns A Date object representing the last day of the current week.
32
+ */
33
+ export declare function getLastDayOfWeek(): Date;
34
+ /**
35
+ * Provides a convenient way to obtain the current date and time as a Date
36
+ * object.
37
+ *
38
+ * @returns A Date object representing the current date and time.
39
+ */
40
+ export declare function getRightNow(): Date;
41
+ //# sourceMappingURL=get.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get.d.ts","sourceRoot":"","sources":["../../../../src/general/dates/get.ts"],"names":[],"mappings":"AAMA;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAElE;AAED;;;;;;;;GAQG;AACH,wBAAgB,YAAY,CAAC,SAAS,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,GAAG,CAAC,EAAE,GAAG,CAAC,GAAG,EAAE,CAc5E;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,IAAI,IAAI,CAIxC;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,IAAI,IAAI,CAIvC;AACD;;;;;GAKG;AACH,wBAAgB,WAAW,IAAI,IAAI,CAElC"}
@@ -0,0 +1,70 @@
1
+ import { createDateFromAdjustment, createEndOfDay, createStartOfDay, } from "./create.js";
2
+ /**
3
+ * Provides a way to obtain the number of days in a specific month of a
4
+ * particular year.
5
+ *
6
+ * @param year The year for which to obtain the number of days in a month.
7
+ * @param month The month for which to obtain the number of days.
8
+ * @returns The number of days in the specified month of the specified year.
9
+ */
10
+ export function getDaysInMonth(year, month) {
11
+ return new Date(year, month, 0).getDate();
12
+ }
13
+ /**
14
+ * Calculates the UTC offset caused by daylight savings time between the first
15
+ * date and the second date.
16
+ *
17
+ * @param firstTime The first date.
18
+ * @param secondTime The second date.
19
+ * @returns The UTC offset caused by daylight savings time between the first and
20
+ * second dates.
21
+ */
22
+ export function getDSTOffset(firstTime, secondTime) {
23
+ const firstString = firstTime.toString();
24
+ const secondString = secondTime.toString();
25
+ const isDaylight = (s) => {
26
+ return s.includes("Daylight");
27
+ };
28
+ if (isDaylight(firstString) && isDaylight(secondString)) {
29
+ return 0;
30
+ }
31
+ else if (!isDaylight(firstString) && !isDaylight(secondString)) {
32
+ return 0;
33
+ }
34
+ else if (isDaylight(firstString) && !isDaylight(secondString)) {
35
+ return -60;
36
+ }
37
+ return 60;
38
+ }
39
+ /**
40
+ * Provides a way to obtain the Date object representing the first day of the
41
+ * current week, with the time portion set to the start of the day.
42
+ *
43
+ * @returns A Date object representing the first day of the current week.
44
+ */
45
+ export function getFirstDayOfWeek() {
46
+ const today = getRightNow();
47
+ const raw = createDateFromAdjustment(today, "date", today.getDay() * -1);
48
+ return createStartOfDay(raw);
49
+ }
50
+ /**
51
+ * Provides a way to obtain the Date object representing the last day of the
52
+ * current week, with the time portion set to the end of the day.
53
+ *
54
+ * @returns A Date object representing the last day of the current week.
55
+ */
56
+ export function getLastDayOfWeek() {
57
+ const today = getRightNow();
58
+ const raw = createDateFromAdjustment(today, "date", 6 - today.getDay());
59
+ return createEndOfDay(raw);
60
+ }
61
+ /**
62
+ * Provides a convenient way to obtain the current date and time as a Date
63
+ * object.
64
+ *
65
+ * @returns A Date object representing the current date and time.
66
+ */
67
+ export function getRightNow() {
68
+ return new Date();
69
+ }
70
+ //# sourceMappingURL=get.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get.js","sourceRoot":"","sources":["../../../../src/general/dates/get.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,wBAAwB,EACxB,cAAc,EACd,gBAAgB,GAChB,MAAM,aAAa,CAAC;AAErB;;;;;;;GAOG;AACH,MAAM,UAAU,cAAc,CAAC,IAAY,EAAE,KAAa;IACzD,OAAO,IAAI,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;AAC3C,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,YAAY,CAAC,SAAe,EAAE,UAAgB;IAC7D,MAAM,WAAW,GAAG,SAAS,CAAC,QAAQ,EAAE,CAAC;IACzC,MAAM,YAAY,GAAG,UAAU,CAAC,QAAQ,EAAE,CAAC;IAC3C,MAAM,UAAU,GAAG,CAAC,CAAS,EAAE,EAAE;QAChC,OAAO,CAAC,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;IAC/B,CAAC,CAAC;IACF,IAAI,UAAU,CAAC,WAAW,CAAC,IAAI,UAAU,CAAC,YAAY,CAAC,EAAE,CAAC;QACzD,OAAO,CAAC,CAAC;IACV,CAAC;SAAM,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC,IAAI,CAAC,UAAU,CAAC,YAAY,CAAC,EAAE,CAAC;QAClE,OAAO,CAAC,CAAC;IACV,CAAC;SAAM,IAAI,UAAU,CAAC,WAAW,CAAC,IAAI,CAAC,UAAU,CAAC,YAAY,CAAC,EAAE,CAAC;QACjE,OAAO,CAAC,EAAE,CAAC;IACZ,CAAC;IACD,OAAO,EAAE,CAAC;AACX,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,iBAAiB;IAChC,MAAM,KAAK,GAAG,WAAW,EAAE,CAAC;IAC5B,MAAM,GAAG,GAAG,wBAAwB,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC;IACzE,OAAO,gBAAgB,CAAC,GAAG,CAAC,CAAC;AAC9B,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,gBAAgB;IAC/B,MAAM,KAAK,GAAG,WAAW,EAAE,CAAC;IAC5B,MAAM,GAAG,GAAG,wBAAwB,CAAC,KAAK,EAAE,MAAM,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC;IACxE,OAAO,cAAc,CAAC,GAAG,CAAC,CAAC;AAC5B,CAAC;AACD;;;;;GAKG;AACH,MAAM,UAAU,WAAW;IAC1B,OAAO,IAAI,IAAI,EAAE,CAAC;AACnB,CAAC","sourcesContent":["import {\n\tcreateDateFromAdjustment,\n\tcreateEndOfDay,\n\tcreateStartOfDay,\n} from \"./create.js\";\n\n/**\n * Provides a way to obtain the number of days in a specific month of a\n * particular year.\n *\n * @param year The year for which to obtain the number of days in a month.\n * @param month The month for which to obtain the number of days.\n * @returns The number of days in the specified month of the specified year.\n */\nexport function getDaysInMonth(year: number, month: number): number {\n\treturn new Date(year, month, 0).getDate();\n}\n\n/**\n * Calculates the UTC offset caused by daylight savings time between the first\n * date and the second date.\n *\n * @param firstTime The first date.\n * @param secondTime The second date.\n * @returns The UTC offset caused by daylight savings time between the first and\n * second dates.\n */\nexport function getDSTOffset(firstTime: Date, secondTime: Date): -60 | 0 | 60 {\n\tconst firstString = firstTime.toString();\n\tconst secondString = secondTime.toString();\n\tconst isDaylight = (s: string) => {\n\t\treturn s.includes(\"Daylight\");\n\t};\n\tif (isDaylight(firstString) && isDaylight(secondString)) {\n\t\treturn 0;\n\t} else if (!isDaylight(firstString) && !isDaylight(secondString)) {\n\t\treturn 0;\n\t} else if (isDaylight(firstString) && !isDaylight(secondString)) {\n\t\treturn -60;\n\t}\n\treturn 60;\n}\n\n/**\n * Provides a way to obtain the Date object representing the first day of the\n * current week, with the time portion set to the start of the day.\n *\n * @returns A Date object representing the first day of the current week.\n */\nexport function getFirstDayOfWeek(): Date {\n\tconst today = getRightNow();\n\tconst raw = createDateFromAdjustment(today, \"date\", today.getDay() * -1);\n\treturn createStartOfDay(raw);\n}\n\n/**\n * Provides a way to obtain the Date object representing the last day of the\n * current week, with the time portion set to the end of the day.\n *\n * @returns A Date object representing the last day of the current week.\n */\nexport function getLastDayOfWeek(): Date {\n\tconst today = getRightNow();\n\tconst raw = createDateFromAdjustment(today, \"date\", 6 - today.getDay());\n\treturn createEndOfDay(raw);\n}\n/**\n * Provides a convenient way to obtain the current date and time as a Date\n * object.\n *\n * @returns A Date object representing the current date and time.\n */\nexport function getRightNow(): Date {\n\treturn new Date();\n}\n"]}
@@ -0,0 +1,4 @@
1
+ export * from "./create.js";
2
+ export * from "./dates.js";
3
+ export * from "./get.js";
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/general/dates/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC"}
@@ -0,0 +1,4 @@
1
+ export * from "./create.js";
2
+ export * from "./dates.js";
3
+ export * from "./get.js";
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/general/dates/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC","sourcesContent":["export * from \"./create.js\";\nexport * from \"./dates.js\";\nexport * from \"./get.js\";\n"]}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Appends all the checkboxes in a form to a FormData object (whether they are
3
+ * checked or not).
4
+ *
5
+ * @param form The form element.
6
+ * @param data The FormData object to append the checkboxes to.
7
+ */
8
+ export declare function appendCheckboxesToFormData(form: HTMLFormElement, data: FormData): void;
9
+ /**
10
+ * Creates a pretty field name from the name attribute of the input. (Removes
11
+ * the group name as well)
12
+ *
13
+ * @param name The name attribute of the input.
14
+ * @returns The pretty field name.
15
+ */
16
+ export declare function getPrettyFieldName(name: string): string;
17
+ //# sourceMappingURL=forms.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"forms.d.ts","sourceRoot":"","sources":["../../../src/general/forms.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AACH,wBAAgB,0BAA0B,CACzC,IAAI,EAAE,eAAe,EACrB,IAAI,EAAE,QAAQ,GACZ,IAAI,CAUN;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAIvD"}
@@ -0,0 +1,27 @@
1
+ import { toTitleCase } from "./string.js";
2
+ /**
3
+ * Appends all the checkboxes in a form to a FormData object (whether they are
4
+ * checked or not).
5
+ *
6
+ * @param form The form element.
7
+ * @param data The FormData object to append the checkboxes to.
8
+ */
9
+ export function appendCheckboxesToFormData(form, data) {
10
+ /** All the checkbox elements in the form. */
11
+ const boxes = Array.from(form.querySelectorAll('input[type="checkbox"]'));
12
+ //This is so we get the state of all the checkboxes whether they are checked or not. Typically only checked checkboxes get sent.
13
+ boxes.forEach((checkbox) => {
14
+ data.append(checkbox.name, String(checkbox.checked));
15
+ });
16
+ }
17
+ /**
18
+ * Creates a pretty field name from the name attribute of the input. (Removes
19
+ * the group name as well)
20
+ *
21
+ * @param name The name attribute of the input.
22
+ * @returns The pretty field name.
23
+ */
24
+ export function getPrettyFieldName(name) {
25
+ return toTitleCase(name.replace(/([^[]+)\[([^\]]+)]/g, "$2").replace(/[_-]/g, " "));
26
+ }
27
+ //# sourceMappingURL=forms.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"forms.js","sourceRoot":"","sources":["../../../src/general/forms.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE1C;;;;;;GAMG;AACH,MAAM,UAAU,0BAA0B,CACzC,IAAqB,EACrB,IAAc;IAEd,6CAA6C;IAC7C,MAAM,KAAK,GAAG,KAAK,CAAC,IAAI,CACvB,IAAI,CAAC,gBAAgB,CAAmB,wBAAwB,CAAC,CACjE,CAAC;IAEF,gIAAgI;IAChI,KAAK,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,EAAE;QAC1B,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC;IACtD,CAAC,CAAC,CAAC;AACJ,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,kBAAkB,CAAC,IAAY;IAC9C,OAAO,WAAW,CACjB,IAAI,CAAC,OAAO,CAAC,qBAAqB,EAAE,IAAI,CAAC,CAAC,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC,CAC/D,CAAC;AACH,CAAC","sourcesContent":["import { toTitleCase } from \"./string.js\";\n\n/**\n * Appends all the checkboxes in a form to a FormData object (whether they are\n * checked or not).\n *\n * @param form The form element.\n * @param data The FormData object to append the checkboxes to.\n */\nexport function appendCheckboxesToFormData(\n\tform: HTMLFormElement,\n\tdata: FormData,\n): void {\n\t/** All the checkbox elements in the form. */\n\tconst boxes = Array.from(\n\t\tform.querySelectorAll<HTMLInputElement>('input[type=\"checkbox\"]'),\n\t);\n\n\t//This is so we get the state of all the checkboxes whether they are checked or not. Typically only checked checkboxes get sent.\n\tboxes.forEach((checkbox) => {\n\t\tdata.append(checkbox.name, String(checkbox.checked));\n\t});\n}\n\n/**\n * Creates a pretty field name from the name attribute of the input. (Removes\n * the group name as well)\n *\n * @param name The name attribute of the input.\n * @returns The pretty field name.\n */\nexport function getPrettyFieldName(name: string): string {\n\treturn toTitleCase(\n\t\tname.replace(/([^[]+)\\[([^\\]]+)]/g, \"$2\").replace(/[_-]/g, \" \"),\n\t);\n}\n"]}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Extract the src value from an imported image. This is a workaround for
3
+ * WebPack configurations importing the path to the image, but Next.js importing
4
+ * an object.
5
+ *
6
+ * @example
7
+ * import image from "./image.png";
8
+ * <img src={image} alt=""> //This will work without the function in WebPack, but not Next.js.
9
+ * <img src={extractSource(image)} alt=""> //This will work in both.
10
+ *
11
+ * @param image The imported image to extract the source from.
12
+ * @returns The source of the image.
13
+ */
14
+ export declare function extractSource(image: string | {
15
+ src: string;
16
+ }): string;
17
+ //# sourceMappingURL=images.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"images.d.ts","sourceRoot":"","sources":["../../../src/general/images.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG;IAAE,GAAG,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,CAKrE"}
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Extract the src value from an imported image. This is a workaround for
3
+ * WebPack configurations importing the path to the image, but Next.js importing
4
+ * an object.
5
+ *
6
+ * @example
7
+ * import image from "./image.png";
8
+ * <img src={image} alt=""> //This will work without the function in WebPack, but not Next.js.
9
+ * <img src={extractSource(image)} alt=""> //This will work in both.
10
+ *
11
+ * @param image The imported image to extract the source from.
12
+ * @returns The source of the image.
13
+ */
14
+ export function extractSource(image) {
15
+ if (typeof image === "string") {
16
+ return image;
17
+ }
18
+ return image.src;
19
+ }
20
+ //# sourceMappingURL=images.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"images.js","sourceRoot":"","sources":["../../../src/general/images.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,aAAa,CAAC,KAA+B;IAC5D,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC/B,OAAO,KAAK,CAAC;IACd,CAAC;IACD,OAAO,KAAK,CAAC,GAAG,CAAC;AAClB,CAAC","sourcesContent":["/**\n * Extract the src value from an imported image. This is a workaround for\n * WebPack configurations importing the path to the image, but Next.js importing\n * an object.\n *\n * @example\n * \timport image from \"./image.png\";\n * \t<img src={image} alt=\"\"> //This will work without the function in WebPack, but not Next.js.\n * \t<img src={extractSource(image)} alt=\"\"> //This will work in both.\n *\n * @param image The imported image to extract the source from.\n * @returns The source of the image.\n */\nexport function extractSource(image: string | { src: string }): string {\n\tif (typeof image === \"string\") {\n\t\treturn image;\n\t}\n\treturn image.src;\n}\n"]}
@@ -0,0 +1,15 @@
1
+ export * from "./arrays.js";
2
+ export * from "./boolean.js";
3
+ export * from "./clock.js";
4
+ export * from "./dates/index.js";
5
+ export * from "./forms.js";
6
+ export * from "./images.js";
7
+ export * from "./localization.js";
8
+ export * from "./maps.js";
9
+ export * from "./messenger/index.js";
10
+ export * from "./numbers.js";
11
+ export * from "./objects.js";
12
+ export * from "./sorting.js";
13
+ export * from "./string.js";
14
+ export * from "./timeout.js";
15
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/general/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,kBAAkB,CAAC;AACjC,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,mBAAmB,CAAC;AAClC,cAAc,WAAW,CAAC;AAC1B,cAAc,sBAAsB,CAAC;AACrC,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC"}
@@ -0,0 +1,15 @@
1
+ export * from "./arrays.js";
2
+ export * from "./boolean.js";
3
+ export * from "./clock.js";
4
+ export * from "./dates/index.js";
5
+ export * from "./forms.js";
6
+ export * from "./images.js";
7
+ export * from "./localization.js";
8
+ export * from "./maps.js";
9
+ export * from "./messenger/index.js";
10
+ export * from "./numbers.js";
11
+ export * from "./objects.js";
12
+ export * from "./sorting.js";
13
+ export * from "./string.js";
14
+ export * from "./timeout.js";
15
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/general/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,kBAAkB,CAAC;AACjC,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,mBAAmB,CAAC;AAClC,cAAc,WAAW,CAAC;AAC1B,cAAc,sBAAsB,CAAC;AACrC,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC","sourcesContent":["export * from \"./arrays.js\";\nexport * from \"./boolean.js\";\nexport * from \"./clock.js\";\nexport * from \"./dates/index.js\";\nexport * from \"./forms.js\";\nexport * from \"./images.js\";\nexport * from \"./localization.js\";\nexport * from \"./maps.js\";\nexport * from \"./messenger/index.js\";\nexport * from \"./numbers.js\";\nexport * from \"./objects.js\";\nexport * from \"./sorting.js\";\nexport * from \"./string.js\";\nexport * from \"./timeout.js\";\n"]}