@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.
- package/README.md +49 -0
- package/dist/cjs/browser/dom.cjs +95 -0
- package/dist/cjs/browser/dom.d.ts +44 -0
- package/dist/cjs/browser/dom.d.ts.map +1 -0
- package/dist/cjs/browser/dom.js.map +1 -0
- package/dist/cjs/browser/download.cjs +40 -0
- package/dist/cjs/browser/download.d.ts +16 -0
- package/dist/cjs/browser/download.d.ts.map +1 -0
- package/dist/cjs/browser/download.js.map +1 -0
- package/dist/cjs/browser/index.cjs +20 -0
- package/dist/cjs/browser/index.d.ts +4 -0
- package/dist/cjs/browser/index.d.ts.map +1 -0
- package/dist/cjs/browser/index.js.map +1 -0
- package/dist/cjs/browser/queryOrThrow.cjs +42 -0
- package/dist/cjs/browser/queryOrThrow.d.ts +44 -0
- package/dist/cjs/browser/queryOrThrow.d.ts.map +1 -0
- package/dist/cjs/browser/queryOrThrow.js.map +1 -0
- package/dist/cjs/general/arrays.cjs +151 -0
- package/dist/cjs/general/arrays.d.ts +70 -0
- package/dist/cjs/general/arrays.d.ts.map +1 -0
- package/dist/cjs/general/arrays.js.map +1 -0
- package/dist/cjs/general/boolean.cjs +19 -0
- package/dist/cjs/general/boolean.d.ts +10 -0
- package/dist/cjs/general/boolean.d.ts.map +1 -0
- package/dist/cjs/general/boolean.js.map +1 -0
- package/dist/cjs/general/clock.cjs +22 -0
- package/dist/cjs/general/clock.d.ts +12 -0
- package/dist/cjs/general/clock.d.ts.map +1 -0
- package/dist/cjs/general/clock.js.map +1 -0
- package/dist/cjs/general/dates/create.cjs +81 -0
- package/dist/cjs/general/dates/create.d.ts +54 -0
- package/dist/cjs/general/dates/create.d.ts.map +1 -0
- package/dist/cjs/general/dates/create.js.map +1 -0
- package/dist/cjs/general/dates/dates.cjs +88 -0
- package/dist/cjs/general/dates/dates.d.ts +56 -0
- package/dist/cjs/general/dates/dates.d.ts.map +1 -0
- package/dist/cjs/general/dates/dates.js.map +1 -0
- package/dist/cjs/general/dates/get.cjs +77 -0
- package/dist/cjs/general/dates/get.d.ts +41 -0
- package/dist/cjs/general/dates/get.d.ts.map +1 -0
- package/dist/cjs/general/dates/get.js.map +1 -0
- package/dist/cjs/general/dates/index.cjs +20 -0
- package/dist/cjs/general/dates/index.d.ts +4 -0
- package/dist/cjs/general/dates/index.d.ts.map +1 -0
- package/dist/cjs/general/dates/index.js.map +1 -0
- package/dist/cjs/general/forms.cjs +31 -0
- package/dist/cjs/general/forms.d.ts +17 -0
- package/dist/cjs/general/forms.d.ts.map +1 -0
- package/dist/cjs/general/forms.js.map +1 -0
- package/dist/cjs/general/images.cjs +23 -0
- package/dist/cjs/general/images.d.ts +17 -0
- package/dist/cjs/general/images.d.ts.map +1 -0
- package/dist/cjs/general/images.js.map +1 -0
- package/dist/cjs/general/index.cjs +31 -0
- package/dist/cjs/general/index.d.ts +15 -0
- package/dist/cjs/general/index.d.ts.map +1 -0
- package/dist/cjs/general/index.js.map +1 -0
- package/dist/cjs/general/localization.cjs +199 -0
- package/dist/cjs/general/localization.d.ts +83 -0
- package/dist/cjs/general/localization.d.ts.map +1 -0
- package/dist/cjs/general/localization.js.map +1 -0
- package/dist/cjs/general/maps.cjs +63 -0
- package/dist/cjs/general/maps.d.ts +35 -0
- package/dist/cjs/general/maps.d.ts.map +1 -0
- package/dist/cjs/general/maps.js.map +1 -0
- package/dist/cjs/general/messenger/createMessenger.cjs +68 -0
- package/dist/cjs/general/messenger/createMessenger.d.ts +10 -0
- package/dist/cjs/general/messenger/createMessenger.d.ts.map +1 -0
- package/dist/cjs/general/messenger/createMessenger.js.map +1 -0
- package/dist/cjs/general/messenger/index.cjs +19 -0
- package/dist/cjs/general/messenger/index.d.ts +3 -0
- package/dist/cjs/general/messenger/index.d.ts.map +1 -0
- package/dist/cjs/general/messenger/index.js.map +1 -0
- package/dist/cjs/general/messenger/types.cjs +3 -0
- package/dist/cjs/general/messenger/types.d.ts +26 -0
- package/dist/cjs/general/messenger/types.d.ts.map +1 -0
- package/dist/cjs/general/messenger/types.js.map +1 -0
- package/dist/cjs/general/namedEntities.cjs +260 -0
- package/dist/cjs/general/namedEntities.d.ts +256 -0
- package/dist/cjs/general/namedEntities.d.ts.map +1 -0
- package/dist/cjs/general/namedEntities.js.map +1 -0
- package/dist/cjs/general/numbers.cjs +94 -0
- package/dist/cjs/general/numbers.d.ts +43 -0
- package/dist/cjs/general/numbers.d.ts.map +1 -0
- package/dist/cjs/general/numbers.js.map +1 -0
- package/dist/cjs/general/objects.cjs +98 -0
- package/dist/cjs/general/objects.d.ts +45 -0
- package/dist/cjs/general/objects.d.ts.map +1 -0
- package/dist/cjs/general/objects.js.map +1 -0
- package/dist/cjs/general/sorting.cjs +72 -0
- package/dist/cjs/general/sorting.d.ts +32 -0
- package/dist/cjs/general/sorting.d.ts.map +1 -0
- package/dist/cjs/general/sorting.js.map +1 -0
- package/dist/cjs/general/string.cjs +73 -0
- package/dist/cjs/general/string.d.ts +31 -0
- package/dist/cjs/general/string.d.ts.map +1 -0
- package/dist/cjs/general/string.js.map +1 -0
- package/dist/cjs/general/timeout.cjs +17 -0
- package/dist/cjs/general/timeout.d.ts +8 -0
- package/dist/cjs/general/timeout.d.ts.map +1 -0
- package/dist/cjs/general/timeout.js.map +1 -0
- package/dist/cjs/index.cjs +20 -0
- package/dist/cjs/index.d.ts +4 -0
- package/dist/cjs/index.d.ts.map +1 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/node/index.cjs +30 -0
- package/dist/cjs/node/index.d.ts +25 -0
- package/dist/cjs/node/index.d.ts.map +1 -0
- package/dist/cjs/node/index.js.map +1 -0
- package/dist/esm/browser/dom.d.ts +44 -0
- package/dist/esm/browser/dom.d.ts.map +1 -0
- package/dist/esm/browser/dom.js +88 -0
- package/dist/esm/browser/dom.js.map +1 -0
- package/dist/esm/browser/download.d.ts +16 -0
- package/dist/esm/browser/download.d.ts.map +1 -0
- package/dist/esm/browser/download.js +36 -0
- package/dist/esm/browser/download.js.map +1 -0
- package/dist/esm/browser/index.d.ts +4 -0
- package/dist/esm/browser/index.d.ts.map +1 -0
- package/dist/esm/browser/index.js +4 -0
- package/dist/esm/browser/index.js.map +1 -0
- package/dist/esm/browser/queryOrThrow.d.ts +44 -0
- package/dist/esm/browser/queryOrThrow.d.ts.map +1 -0
- package/dist/esm/browser/queryOrThrow.js +39 -0
- package/dist/esm/browser/queryOrThrow.js.map +1 -0
- package/dist/esm/general/arrays.d.ts +70 -0
- package/dist/esm/general/arrays.d.ts.map +1 -0
- package/dist/esm/general/arrays.js +144 -0
- package/dist/esm/general/arrays.js.map +1 -0
- package/dist/esm/general/boolean.d.ts +10 -0
- package/dist/esm/general/boolean.d.ts.map +1 -0
- package/dist/esm/general/boolean.js +16 -0
- package/dist/esm/general/boolean.js.map +1 -0
- package/dist/esm/general/clock.d.ts +12 -0
- package/dist/esm/general/clock.d.ts.map +1 -0
- package/dist/esm/general/clock.js +19 -0
- package/dist/esm/general/clock.js.map +1 -0
- package/dist/esm/general/dates/create.d.ts +54 -0
- package/dist/esm/general/dates/create.d.ts.map +1 -0
- package/dist/esm/general/dates/create.js +73 -0
- package/dist/esm/general/dates/create.js.map +1 -0
- package/dist/esm/general/dates/dates.d.ts +56 -0
- package/dist/esm/general/dates/dates.d.ts.map +1 -0
- package/dist/esm/general/dates/dates.js +82 -0
- package/dist/esm/general/dates/dates.js.map +1 -0
- package/dist/esm/general/dates/get.d.ts +41 -0
- package/dist/esm/general/dates/get.d.ts.map +1 -0
- package/dist/esm/general/dates/get.js +70 -0
- package/dist/esm/general/dates/get.js.map +1 -0
- package/dist/esm/general/dates/index.d.ts +4 -0
- package/dist/esm/general/dates/index.d.ts.map +1 -0
- package/dist/esm/general/dates/index.js +4 -0
- package/dist/esm/general/dates/index.js.map +1 -0
- package/dist/esm/general/forms.d.ts +17 -0
- package/dist/esm/general/forms.d.ts.map +1 -0
- package/dist/esm/general/forms.js +27 -0
- package/dist/esm/general/forms.js.map +1 -0
- package/dist/esm/general/images.d.ts +17 -0
- package/dist/esm/general/images.d.ts.map +1 -0
- package/dist/esm/general/images.js +20 -0
- package/dist/esm/general/images.js.map +1 -0
- package/dist/esm/general/index.d.ts +15 -0
- package/dist/esm/general/index.d.ts.map +1 -0
- package/dist/esm/general/index.js +15 -0
- package/dist/esm/general/index.js.map +1 -0
- package/dist/esm/general/localization.d.ts +83 -0
- package/dist/esm/general/localization.d.ts.map +1 -0
- package/dist/esm/general/localization.js +188 -0
- package/dist/esm/general/localization.js.map +1 -0
- package/dist/esm/general/maps.d.ts +35 -0
- package/dist/esm/general/maps.d.ts.map +1 -0
- package/dist/esm/general/maps.js +59 -0
- package/dist/esm/general/maps.js.map +1 -0
- package/dist/esm/general/messenger/createMessenger.d.ts +10 -0
- package/dist/esm/general/messenger/createMessenger.d.ts.map +1 -0
- package/dist/esm/general/messenger/createMessenger.js +65 -0
- package/dist/esm/general/messenger/createMessenger.js.map +1 -0
- package/dist/esm/general/messenger/index.d.ts +3 -0
- package/dist/esm/general/messenger/index.d.ts.map +1 -0
- package/dist/esm/general/messenger/index.js +3 -0
- package/dist/esm/general/messenger/index.js.map +1 -0
- package/dist/esm/general/messenger/types.d.ts +26 -0
- package/dist/esm/general/messenger/types.d.ts.map +1 -0
- package/dist/esm/general/messenger/types.js +2 -0
- package/dist/esm/general/messenger/types.js.map +1 -0
- package/dist/esm/general/namedEntities.d.ts +256 -0
- package/dist/esm/general/namedEntities.d.ts.map +1 -0
- package/dist/esm/general/namedEntities.js +257 -0
- package/dist/esm/general/namedEntities.js.map +1 -0
- package/dist/esm/general/numbers.d.ts +43 -0
- package/dist/esm/general/numbers.d.ts.map +1 -0
- package/dist/esm/general/numbers.js +87 -0
- package/dist/esm/general/numbers.js.map +1 -0
- package/dist/esm/general/objects.d.ts +45 -0
- package/dist/esm/general/objects.d.ts.map +1 -0
- package/dist/esm/general/objects.js +91 -0
- package/dist/esm/general/objects.js.map +1 -0
- package/dist/esm/general/sorting.d.ts +32 -0
- package/dist/esm/general/sorting.d.ts.map +1 -0
- package/dist/esm/general/sorting.js +67 -0
- package/dist/esm/general/sorting.js.map +1 -0
- package/dist/esm/general/string.d.ts +31 -0
- package/dist/esm/general/string.d.ts.map +1 -0
- package/dist/esm/general/string.js +68 -0
- package/dist/esm/general/string.js.map +1 -0
- package/dist/esm/general/timeout.d.ts +8 -0
- package/dist/esm/general/timeout.d.ts.map +1 -0
- package/dist/esm/general/timeout.js +14 -0
- package/dist/esm/general/timeout.js.map +1 -0
- package/dist/esm/index.d.ts +4 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js +4 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/node/index.d.ts +25 -0
- package/dist/esm/node/index.d.ts.map +1 -0
- package/dist/esm/node/index.js +27 -0
- package/dist/esm/node/index.js.map +1 -0
- package/package.json +62 -0
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getPrettyValue = getPrettyValue;
|
|
4
|
+
/**
|
|
5
|
+
* Replace a boolean value with a more user-friendly string. Does nothing if the
|
|
6
|
+
* existing value was a string
|
|
7
|
+
*
|
|
8
|
+
* @param rawValue The value to convert.
|
|
9
|
+
* @returns A user-friendly string representation of the value that was passed
|
|
10
|
+
* in.
|
|
11
|
+
*/
|
|
12
|
+
function getPrettyValue(rawValue) {
|
|
13
|
+
if (rawValue === true)
|
|
14
|
+
return "Yes";
|
|
15
|
+
if (rawValue === false)
|
|
16
|
+
return "No";
|
|
17
|
+
return rawValue;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=boolean.js.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Replace a boolean value with a more user-friendly string. Does nothing if the
|
|
3
|
+
* existing value was a string
|
|
4
|
+
*
|
|
5
|
+
* @param rawValue The value to convert.
|
|
6
|
+
* @returns A user-friendly string representation of the value that was passed
|
|
7
|
+
* in.
|
|
8
|
+
*/
|
|
9
|
+
export declare function getPrettyValue(rawValue: boolean | string): string;
|
|
10
|
+
//# sourceMappingURL=boolean.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"boolean.d.ts","sourceRoot":"","sources":["../../../src/general/boolean.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAC,QAAQ,EAAE,OAAO,GAAG,MAAM,GAAG,MAAM,CAIjE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"boolean.js","sourceRoot":"","sources":["../../../src/general/boolean.ts"],"names":[],"mappings":";;AAQA,wCAIC;AAZD;;;;;;;GAOG;AACH,SAAgB,cAAc,CAAC,QAA0B;IACxD,IAAI,QAAQ,KAAK,IAAI;QAAE,OAAO,KAAK,CAAC;IACpC,IAAI,QAAQ,KAAK,KAAK;QAAE,OAAO,IAAI,CAAC;IACpC,OAAO,QAAQ,CAAC;AACjB,CAAC","sourcesContent":["/**\n * Replace a boolean value with a more user-friendly string. Does nothing if the\n * existing value was a string\n *\n * @param rawValue The value to convert.\n * @returns A user-friendly string representation of the value that was passed\n * in.\n */\nexport function getPrettyValue(rawValue: boolean | string): string {\n\tif (rawValue === true) return \"Yes\";\n\tif (rawValue === false) return \"No\";\n\treturn rawValue;\n}\n"]}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getClockRotations = getClockRotations;
|
|
4
|
+
const numbers_js_1 = require("./numbers.cjs");
|
|
5
|
+
/**
|
|
6
|
+
* Gets the rotations for the clock hands, with 0deg being 12 o'clock.
|
|
7
|
+
*
|
|
8
|
+
* @param date The date to get the rotations for.
|
|
9
|
+
* @returns The rotations for the clock hands.
|
|
10
|
+
*/
|
|
11
|
+
function getClockRotations(date) {
|
|
12
|
+
const secondsPercentage = date.getSeconds() / 60;
|
|
13
|
+
const minutesInSeconds = date.getMinutes() * 60;
|
|
14
|
+
const minutesPercentage = (minutesInSeconds + date.getSeconds()) / (60 * 60);
|
|
15
|
+
const hoursInSeconds = (date.getHours() % 12) * 60 * 60;
|
|
16
|
+
const hoursPercentage = (hoursInSeconds + minutesInSeconds + date.getSeconds()) / (12 * 60 * 60);
|
|
17
|
+
const hours = (0, numbers_js_1.toPrecision)(hoursPercentage * 360, 2);
|
|
18
|
+
const minutes = (0, numbers_js_1.toPrecision)(minutesPercentage * 360, 2);
|
|
19
|
+
const seconds = (0, numbers_js_1.toPrecision)(secondsPercentage * 360, 2);
|
|
20
|
+
return { hours, minutes, seconds };
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=clock.js.map
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Gets the rotations for the clock hands, with 0deg being 12 o'clock.
|
|
3
|
+
*
|
|
4
|
+
* @param date The date to get the rotations for.
|
|
5
|
+
* @returns The rotations for the clock hands.
|
|
6
|
+
*/
|
|
7
|
+
export declare function getClockRotations(date: Date): {
|
|
8
|
+
hours: number;
|
|
9
|
+
minutes: number;
|
|
10
|
+
seconds: number;
|
|
11
|
+
};
|
|
12
|
+
//# sourceMappingURL=clock.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"clock.d.ts","sourceRoot":"","sources":["../../../src/general/clock.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,IAAI,GAAG;IAC9C,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;CAChB,CAYA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"clock.js","sourceRoot":"","sources":["../../../src/general/clock.ts"],"names":[],"mappings":";;AAQA,8CAgBC;AAxBD,6CAA2C;AAE3C;;;;;GAKG;AACH,SAAgB,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,IAAA,wBAAW,EAAC,eAAe,GAAG,GAAG,EAAE,CAAC,CAAC,CAAC;IACpD,MAAM,OAAO,GAAG,IAAA,wBAAW,EAAC,iBAAiB,GAAG,GAAG,EAAE,CAAC,CAAC,CAAC;IACxD,MAAM,OAAO,GAAG,IAAA,wBAAW,EAAC,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,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.cloneDate = cloneDate;
|
|
4
|
+
exports.createDateFromAdjustment = createDateFromAdjustment;
|
|
5
|
+
exports.createDateFromDate = createDateFromDate;
|
|
6
|
+
exports.createDateFromString = createDateFromString;
|
|
7
|
+
exports.createEndOfDay = createEndOfDay;
|
|
8
|
+
exports.createStartOfDay = createStartOfDay;
|
|
9
|
+
const dates_js_1 = require("./dates.cjs");
|
|
10
|
+
/**
|
|
11
|
+
* Provides a way to create a new Date object that is an exact copy of an
|
|
12
|
+
* existing Date object.
|
|
13
|
+
*
|
|
14
|
+
* @param date The Date object to clone.
|
|
15
|
+
* @returns A new Date object that is an exact copy of the original.
|
|
16
|
+
*/
|
|
17
|
+
function cloneDate(date) {
|
|
18
|
+
return new Date(date);
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Provides a way to obtain a new Date object with a specific component,
|
|
22
|
+
* adjusted by a given value while preserving the other components of the
|
|
23
|
+
* original Date object.
|
|
24
|
+
*
|
|
25
|
+
* @param oldDate The Date object to clone.
|
|
26
|
+
* @param field The component of the Date object to adjust.
|
|
27
|
+
* @param adjustment The amount to adjust the component by.
|
|
28
|
+
* @returns A new Date object with the specified component adjusted.
|
|
29
|
+
*/
|
|
30
|
+
function createDateFromAdjustment(oldDate, field, adjustment) {
|
|
31
|
+
const method = dates_js_1.DateEquivalents[field];
|
|
32
|
+
const date = cloneDate(oldDate);
|
|
33
|
+
const oldFieldValue = date[method.get]();
|
|
34
|
+
const newFieldValue = oldFieldValue + adjustment;
|
|
35
|
+
const mutatedDate = date[method.set](newFieldValue);
|
|
36
|
+
return new Date(mutatedDate);
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Provides a way to obtain a new Date object with the day of the month modified
|
|
40
|
+
* while preserving the other components of the original Date object.
|
|
41
|
+
*
|
|
42
|
+
* @param oldDate The Date object to clone.
|
|
43
|
+
* @param date The day of the month to set.
|
|
44
|
+
* @returns A new Date object with the day of the month modified.
|
|
45
|
+
*/
|
|
46
|
+
function createDateFromDate(oldDate, date) {
|
|
47
|
+
return new Date(oldDate.setDate(date));
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Provides a way to obtain a new Date object that is created from a time
|
|
51
|
+
* string.
|
|
52
|
+
*
|
|
53
|
+
* @param dateString The string to convert to a Date object.
|
|
54
|
+
* @returns A Date object created from the string.
|
|
55
|
+
*/
|
|
56
|
+
function createDateFromString(dateString) {
|
|
57
|
+
return new Date(dateString);
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Provides a way to obtain a new Date object that represents the end of that
|
|
61
|
+
* day.
|
|
62
|
+
*
|
|
63
|
+
* @param oldDate The Date object to clone.
|
|
64
|
+
* @returns A date object representing the end of the day.
|
|
65
|
+
*/
|
|
66
|
+
function createEndOfDay(oldDate) {
|
|
67
|
+
const date = cloneDate(oldDate);
|
|
68
|
+
return new Date(date.setHours(23, 59, 59, 999));
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Provides a way to obtain a new Date object that represents the start of that
|
|
72
|
+
* day.
|
|
73
|
+
*
|
|
74
|
+
* @param oldDate The Date object to clone.
|
|
75
|
+
* @returns A date object representing the start of the day.
|
|
76
|
+
*/
|
|
77
|
+
function createStartOfDay(oldDate) {
|
|
78
|
+
const date = cloneDate(oldDate);
|
|
79
|
+
return new Date(date.setHours(0, 0, 0, 0));
|
|
80
|
+
}
|
|
81
|
+
//# sourceMappingURL=create.js.map
|
|
@@ -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 @@
|
|
|
1
|
+
{"version":3,"file":"create.js","sourceRoot":"","sources":["../../../../src/general/dates/create.ts"],"names":[],"mappings":";;AAUA,8BAEC;AAYD,4DAWC;AASD,gDAEC;AASD,oDAEC;AASD,wCAGC;AASD,4CAGC;AAhFD,yCAA6C;AAE7C;;;;;;GAMG;AACH,SAAgB,SAAS,CAAC,IAAU;IACnC,OAAO,IAAI,IAAI,CAAC,IAAI,CAAC,CAAC;AACvB,CAAC;AAED;;;;;;;;;GASG;AACH,SAAgB,wBAAwB,CACvC,OAAa,EACb,KAAiB,EACjB,UAAkB;IAElB,MAAM,MAAM,GAAG,0BAAe,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,SAAgB,kBAAkB,CAAC,OAAa,EAAE,IAAY;IAC7D,OAAO,IAAI,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;AACxC,CAAC;AAED;;;;;;GAMG;AACH,SAAgB,oBAAoB,CAAC,UAAkB;IACtD,OAAO,IAAI,IAAI,CAAC,UAAU,CAAC,CAAC;AAC7B,CAAC;AAED;;;;;;GAMG;AACH,SAAgB,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,SAAgB,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,88 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DateEquivalents = void 0;
|
|
4
|
+
exports.datesMatch = datesMatch;
|
|
5
|
+
exports.isBetween = isBetween;
|
|
6
|
+
exports.monthsMatch = monthsMatch;
|
|
7
|
+
/**
|
|
8
|
+
* The DateEquivalents object serves as a mapping of date and time components to
|
|
9
|
+
* their corresponding setter and getter functions in JavaScript's Date object.
|
|
10
|
+
* Each property within DateEquivalents represents a specific component (such as
|
|
11
|
+
* date, time, full year, month, hours, minutes, seconds, and milliseconds) and
|
|
12
|
+
* contains two string values: set: Represents the name of the function that
|
|
13
|
+
* sets the value of the corresponding date or time component. get: Represents
|
|
14
|
+
* the name of the function that retrieves the value of the corresponding date
|
|
15
|
+
* or time component.
|
|
16
|
+
*/
|
|
17
|
+
exports.DateEquivalents = {
|
|
18
|
+
date: {
|
|
19
|
+
get: "getDate",
|
|
20
|
+
set: "setDate",
|
|
21
|
+
},
|
|
22
|
+
fullYear: {
|
|
23
|
+
get: "getFullYear",
|
|
24
|
+
set: "setFullYear",
|
|
25
|
+
},
|
|
26
|
+
hours: {
|
|
27
|
+
get: "getHours",
|
|
28
|
+
set: "setHours",
|
|
29
|
+
},
|
|
30
|
+
milliseconds: {
|
|
31
|
+
get: "getMilliseconds",
|
|
32
|
+
set: "setMilliseconds",
|
|
33
|
+
},
|
|
34
|
+
minutes: {
|
|
35
|
+
get: "getMinutes",
|
|
36
|
+
set: "setMinutes",
|
|
37
|
+
},
|
|
38
|
+
month: {
|
|
39
|
+
get: "getMonth",
|
|
40
|
+
set: "setMonth",
|
|
41
|
+
},
|
|
42
|
+
seconds: {
|
|
43
|
+
get: "getSeconds",
|
|
44
|
+
set: "setSeconds",
|
|
45
|
+
},
|
|
46
|
+
time: {
|
|
47
|
+
get: "getTime",
|
|
48
|
+
set: "setTime",
|
|
49
|
+
},
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
* Determines if two Date objects represent the same month, day, and year.
|
|
53
|
+
*
|
|
54
|
+
* @param date1 The first date to compare.
|
|
55
|
+
* @param date2 The second date to compare.
|
|
56
|
+
* @returns A boolean value indicating whether the two dates represent the same
|
|
57
|
+
* month, day, and year.
|
|
58
|
+
*/
|
|
59
|
+
function datesMatch(date1, date2) {
|
|
60
|
+
return monthsMatch(date1, date2) && date1.getDate() === date2.getDate();
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Provides a way to determine if a given Date falls within a specified range.
|
|
64
|
+
*
|
|
65
|
+
* @param testDate The date to test.
|
|
66
|
+
* @param startDate The start of the range.
|
|
67
|
+
* @param endDate The end of the range.
|
|
68
|
+
* @returns A boolean value indicating whether the testDate falls within the
|
|
69
|
+
* range.
|
|
70
|
+
*/
|
|
71
|
+
function isBetween(testDate, startDate, endDate) {
|
|
72
|
+
return testDate >= startDate && testDate <= endDate;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Compares the year and month components of the month1 and month2 dates. It
|
|
76
|
+
* returns true if the year and month are the same in both dates, and false
|
|
77
|
+
* otherwise.
|
|
78
|
+
*
|
|
79
|
+
* @param month1 The first month to compare.
|
|
80
|
+
* @param month2 The second month to compare.
|
|
81
|
+
* @returns A boolean value indicating whether the year and month components of
|
|
82
|
+
* the two dates are the same.
|
|
83
|
+
*/
|
|
84
|
+
function monthsMatch(month1, month2) {
|
|
85
|
+
return (month1.getFullYear() === month2.getFullYear() &&
|
|
86
|
+
month1.getMonth() === month2.getMonth());
|
|
87
|
+
}
|
|
88
|
+
//# sourceMappingURL=dates.js.map
|
|
@@ -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 @@
|
|
|
1
|
+
{"version":3,"file":"dates.js","sourceRoot":"","sources":["../../../../src/general/dates/dates.ts"],"names":[],"mappings":";;;AA6EA,gCAEC;AAWD,8BAMC;AAYD,kCAKC;AAjHD;;;;;;;;;GASG;AACU,QAAA,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,SAAgB,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,SAAgB,SAAS,CACxB,QAAc,EACd,SAAe,EACf,OAAa;IAEb,OAAO,QAAQ,IAAI,SAAS,IAAI,QAAQ,IAAI,OAAO,CAAC;AACrD,CAAC;AAED;;;;;;;;;GASG;AACH,SAAgB,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,77 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getDaysInMonth = getDaysInMonth;
|
|
4
|
+
exports.getDSTOffset = getDSTOffset;
|
|
5
|
+
exports.getFirstDayOfWeek = getFirstDayOfWeek;
|
|
6
|
+
exports.getLastDayOfWeek = getLastDayOfWeek;
|
|
7
|
+
exports.getRightNow = getRightNow;
|
|
8
|
+
const create_js_1 = require("./create.cjs");
|
|
9
|
+
/**
|
|
10
|
+
* Provides a way to obtain the number of days in a specific month of a
|
|
11
|
+
* particular year.
|
|
12
|
+
*
|
|
13
|
+
* @param year The year for which to obtain the number of days in a month.
|
|
14
|
+
* @param month The month for which to obtain the number of days.
|
|
15
|
+
* @returns The number of days in the specified month of the specified year.
|
|
16
|
+
*/
|
|
17
|
+
function getDaysInMonth(year, month) {
|
|
18
|
+
return new Date(year, month, 0).getDate();
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Calculates the UTC offset caused by daylight savings time between the first
|
|
22
|
+
* date and the second date.
|
|
23
|
+
*
|
|
24
|
+
* @param firstTime The first date.
|
|
25
|
+
* @param secondTime The second date.
|
|
26
|
+
* @returns The UTC offset caused by daylight savings time between the first and
|
|
27
|
+
* second dates.
|
|
28
|
+
*/
|
|
29
|
+
function getDSTOffset(firstTime, secondTime) {
|
|
30
|
+
const firstString = firstTime.toString();
|
|
31
|
+
const secondString = secondTime.toString();
|
|
32
|
+
const isDaylight = (s) => {
|
|
33
|
+
return s.includes("Daylight");
|
|
34
|
+
};
|
|
35
|
+
if (isDaylight(firstString) && isDaylight(secondString)) {
|
|
36
|
+
return 0;
|
|
37
|
+
}
|
|
38
|
+
else if (!isDaylight(firstString) && !isDaylight(secondString)) {
|
|
39
|
+
return 0;
|
|
40
|
+
}
|
|
41
|
+
else if (isDaylight(firstString) && !isDaylight(secondString)) {
|
|
42
|
+
return -60;
|
|
43
|
+
}
|
|
44
|
+
return 60;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Provides a way to obtain the Date object representing the first day of the
|
|
48
|
+
* current week, with the time portion set to the start of the day.
|
|
49
|
+
*
|
|
50
|
+
* @returns A Date object representing the first day of the current week.
|
|
51
|
+
*/
|
|
52
|
+
function getFirstDayOfWeek() {
|
|
53
|
+
const today = getRightNow();
|
|
54
|
+
const raw = (0, create_js_1.createDateFromAdjustment)(today, "date", today.getDay() * -1);
|
|
55
|
+
return (0, create_js_1.createStartOfDay)(raw);
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Provides a way to obtain the Date object representing the last day of the
|
|
59
|
+
* current week, with the time portion set to the end of the day.
|
|
60
|
+
*
|
|
61
|
+
* @returns A Date object representing the last day of the current week.
|
|
62
|
+
*/
|
|
63
|
+
function getLastDayOfWeek() {
|
|
64
|
+
const today = getRightNow();
|
|
65
|
+
const raw = (0, create_js_1.createDateFromAdjustment)(today, "date", 6 - today.getDay());
|
|
66
|
+
return (0, create_js_1.createEndOfDay)(raw);
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Provides a convenient way to obtain the current date and time as a Date
|
|
70
|
+
* object.
|
|
71
|
+
*
|
|
72
|
+
* @returns A Date object representing the current date and time.
|
|
73
|
+
*/
|
|
74
|
+
function getRightNow() {
|
|
75
|
+
return new Date();
|
|
76
|
+
}
|
|
77
|
+
//# sourceMappingURL=get.js.map
|
|
@@ -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 @@
|
|
|
1
|
+
{"version":3,"file":"get.js","sourceRoot":"","sources":["../../../../src/general/dates/get.ts"],"names":[],"mappings":";;AAcA,wCAEC;AAWD,oCAcC;AAQD,8CAIC;AAQD,4CAIC;AAOD,kCAEC;AA1ED,2CAIqB;AAErB;;;;;;;GAOG;AACH,SAAgB,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,SAAgB,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,SAAgB,iBAAiB;IAChC,MAAM,KAAK,GAAG,WAAW,EAAE,CAAC;IAC5B,MAAM,GAAG,GAAG,IAAA,oCAAwB,EAAC,KAAK,EAAE,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC;IACzE,OAAO,IAAA,4BAAgB,EAAC,GAAG,CAAC,CAAC;AAC9B,CAAC;AAED;;;;;GAKG;AACH,SAAgB,gBAAgB;IAC/B,MAAM,KAAK,GAAG,WAAW,EAAE,CAAC;IAC5B,MAAM,GAAG,GAAG,IAAA,oCAAwB,EAAC,KAAK,EAAE,MAAM,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC;IACxE,OAAO,IAAA,0BAAc,EAAC,GAAG,CAAC,CAAC;AAC5B,CAAC;AACD;;;;;GAKG;AACH,SAAgB,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,20 @@
|
|
|
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("./create.cjs"), exports);
|
|
18
|
+
__exportStar(require("./dates.cjs"), exports);
|
|
19
|
+
__exportStar(require("./get.cjs"), exports);
|
|
20
|
+
//# sourceMappingURL=index.js.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 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/general/dates/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,8CAA4B;AAC5B,6CAA2B;AAC3B,2CAAyB","sourcesContent":["export * from \"./create.js\";\nexport * from \"./dates.js\";\nexport * from \"./get.js\";\n"]}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.appendCheckboxesToFormData = appendCheckboxesToFormData;
|
|
4
|
+
exports.getPrettyFieldName = getPrettyFieldName;
|
|
5
|
+
const string_js_1 = require("./string.cjs");
|
|
6
|
+
/**
|
|
7
|
+
* Appends all the checkboxes in a form to a FormData object (whether they are
|
|
8
|
+
* checked or not).
|
|
9
|
+
*
|
|
10
|
+
* @param form The form element.
|
|
11
|
+
* @param data The FormData object to append the checkboxes to.
|
|
12
|
+
*/
|
|
13
|
+
function appendCheckboxesToFormData(form, data) {
|
|
14
|
+
/** All the checkbox elements in the form. */
|
|
15
|
+
const boxes = Array.from(form.querySelectorAll('input[type="checkbox"]'));
|
|
16
|
+
//This is so we get the state of all the checkboxes whether they are checked or not. Typically only checked checkboxes get sent.
|
|
17
|
+
boxes.forEach((checkbox) => {
|
|
18
|
+
data.append(checkbox.name, String(checkbox.checked));
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Creates a pretty field name from the name attribute of the input. (Removes
|
|
23
|
+
* the group name as well)
|
|
24
|
+
*
|
|
25
|
+
* @param name The name attribute of the input.
|
|
26
|
+
* @returns The pretty field name.
|
|
27
|
+
*/
|
|
28
|
+
function getPrettyFieldName(name) {
|
|
29
|
+
return (0, string_js_1.toTitleCase)(name.replace(/([^[]+)\[([^\]]+)]/g, "$2").replace(/[_-]/g, " "));
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=forms.js.map
|
|
@@ -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 @@
|
|
|
1
|
+
{"version":3,"file":"forms.js","sourceRoot":"","sources":["../../../src/general/forms.ts"],"names":[],"mappings":";;AASA,gEAaC;AASD,gDAIC;AAnCD,2CAA0C;AAE1C;;;;;;GAMG;AACH,SAAgB,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,SAAgB,kBAAkB,CAAC,IAAY;IAC9C,OAAO,IAAA,uBAAW,EACjB,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"]}
|