@alextheman/utility 1.9.2 → 1.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +13 -2
- package/dist/index.d.cts +3 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +12 -2
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -25,6 +25,7 @@ __export(index_exports, {
|
|
|
25
25
|
convertFileToBase64: () => convert_file_to_base_64_default,
|
|
26
26
|
formatDateAndTime: () => format_date_and_time_default,
|
|
27
27
|
getRandomNumber: () => get_random_number_default,
|
|
28
|
+
isLeapYear: () => is_leap_year_default,
|
|
28
29
|
isMonthlyMultiple: () => is_monthly_multiple_default,
|
|
29
30
|
isSameDate: () => is_same_date_default,
|
|
30
31
|
randomiseArray: () => randomise_array_default,
|
|
@@ -101,6 +102,15 @@ function getRandomNumber(lowerBound, upperBound) {
|
|
|
101
102
|
}
|
|
102
103
|
var get_random_number_default = getRandomNumber;
|
|
103
104
|
|
|
105
|
+
// src/is-leap-year.ts
|
|
106
|
+
function isLeapYear(year) {
|
|
107
|
+
if (year % 1 !== 0) {
|
|
108
|
+
throw new Error("NON_INTEGER_INPUT");
|
|
109
|
+
}
|
|
110
|
+
return year % 4 === 0 && year % 100 !== 0 || year % 400 === 0;
|
|
111
|
+
}
|
|
112
|
+
var is_leap_year_default = isLeapYear;
|
|
113
|
+
|
|
104
114
|
// src/is-monthly-multiple.ts
|
|
105
115
|
function endOfMonthChecksButNotFebruary(firstDate, secondDate) {
|
|
106
116
|
if ([3, 5, 8, 10].includes(firstDate.getMonth())) {
|
|
@@ -110,7 +120,7 @@ function endOfMonthChecksButNotFebruary(firstDate, secondDate) {
|
|
|
110
120
|
}
|
|
111
121
|
function nonLeapYearFebruaryChecks(firstDate, secondDate) {
|
|
112
122
|
if (firstDate.getMonth() === 1) {
|
|
113
|
-
if (firstDate.getFullYear()
|
|
123
|
+
if (!is_leap_year_default(firstDate.getFullYear()) && firstDate.getDate() === 28) {
|
|
114
124
|
return [28, 29, 30, 31].includes(secondDate.getDate());
|
|
115
125
|
}
|
|
116
126
|
}
|
|
@@ -118,7 +128,7 @@ function nonLeapYearFebruaryChecks(firstDate, secondDate) {
|
|
|
118
128
|
}
|
|
119
129
|
function leapYearFebruaryChecks(firstDate, secondDate) {
|
|
120
130
|
if (firstDate.getMonth() === 1) {
|
|
121
|
-
if (firstDate.getFullYear()
|
|
131
|
+
if (is_leap_year_default(firstDate.getFullYear()) && firstDate.getDate() === 29) {
|
|
122
132
|
return [29, 30, 31].includes(secondDate.getDate());
|
|
123
133
|
}
|
|
124
134
|
}
|
|
@@ -202,6 +212,7 @@ var wait_default = wait;
|
|
|
202
212
|
convertFileToBase64,
|
|
203
213
|
formatDateAndTime,
|
|
204
214
|
getRandomNumber,
|
|
215
|
+
isLeapYear,
|
|
205
216
|
isMonthlyMultiple,
|
|
206
217
|
isSameDate,
|
|
207
218
|
randomiseArray,
|
package/dist/index.d.cts
CHANGED
|
@@ -8,6 +8,8 @@ declare function formatDateAndTime(inputDate: Date): string;
|
|
|
8
8
|
|
|
9
9
|
declare function getRandomNumber(lowerBound: number, upperBound: number): number;
|
|
10
10
|
|
|
11
|
+
declare function isLeapYear(year: number): boolean;
|
|
12
|
+
|
|
11
13
|
declare function isMonthlyMultiple(firstDate: Date, secondDate: Date): boolean;
|
|
12
14
|
|
|
13
15
|
declare function isSameDate(firstDate: Date, secondDate: Date): boolean;
|
|
@@ -20,4 +22,4 @@ declare function truncate(stringToTruncate: string, maxLength?: number): string;
|
|
|
20
22
|
|
|
21
23
|
declare function wait(seconds: number): Promise<void>;
|
|
22
24
|
|
|
23
|
-
export { addDaysToDate, appendSemicolon, convertFileToBase64, formatDateAndTime, getRandomNumber, isMonthlyMultiple, isSameDate, randomiseArray, range, truncate, wait };
|
|
25
|
+
export { addDaysToDate, appendSemicolon, convertFileToBase64, formatDateAndTime, getRandomNumber, isLeapYear, isMonthlyMultiple, isSameDate, randomiseArray, range, truncate, wait };
|
package/dist/index.d.ts
CHANGED
|
@@ -8,6 +8,8 @@ declare function formatDateAndTime(inputDate: Date): string;
|
|
|
8
8
|
|
|
9
9
|
declare function getRandomNumber(lowerBound: number, upperBound: number): number;
|
|
10
10
|
|
|
11
|
+
declare function isLeapYear(year: number): boolean;
|
|
12
|
+
|
|
11
13
|
declare function isMonthlyMultiple(firstDate: Date, secondDate: Date): boolean;
|
|
12
14
|
|
|
13
15
|
declare function isSameDate(firstDate: Date, secondDate: Date): boolean;
|
|
@@ -20,4 +22,4 @@ declare function truncate(stringToTruncate: string, maxLength?: number): string;
|
|
|
20
22
|
|
|
21
23
|
declare function wait(seconds: number): Promise<void>;
|
|
22
24
|
|
|
23
|
-
export { addDaysToDate, appendSemicolon, convertFileToBase64, formatDateAndTime, getRandomNumber, isMonthlyMultiple, isSameDate, randomiseArray, range, truncate, wait };
|
|
25
|
+
export { addDaysToDate, appendSemicolon, convertFileToBase64, formatDateAndTime, getRandomNumber, isLeapYear, isMonthlyMultiple, isSameDate, randomiseArray, range, truncate, wait };
|
package/dist/index.js
CHANGED
|
@@ -65,6 +65,15 @@ function getRandomNumber(lowerBound, upperBound) {
|
|
|
65
65
|
}
|
|
66
66
|
var get_random_number_default = getRandomNumber;
|
|
67
67
|
|
|
68
|
+
// src/is-leap-year.ts
|
|
69
|
+
function isLeapYear(year) {
|
|
70
|
+
if (year % 1 !== 0) {
|
|
71
|
+
throw new Error("NON_INTEGER_INPUT");
|
|
72
|
+
}
|
|
73
|
+
return year % 4 === 0 && year % 100 !== 0 || year % 400 === 0;
|
|
74
|
+
}
|
|
75
|
+
var is_leap_year_default = isLeapYear;
|
|
76
|
+
|
|
68
77
|
// src/is-monthly-multiple.ts
|
|
69
78
|
function endOfMonthChecksButNotFebruary(firstDate, secondDate) {
|
|
70
79
|
if ([3, 5, 8, 10].includes(firstDate.getMonth())) {
|
|
@@ -74,7 +83,7 @@ function endOfMonthChecksButNotFebruary(firstDate, secondDate) {
|
|
|
74
83
|
}
|
|
75
84
|
function nonLeapYearFebruaryChecks(firstDate, secondDate) {
|
|
76
85
|
if (firstDate.getMonth() === 1) {
|
|
77
|
-
if (firstDate.getFullYear()
|
|
86
|
+
if (!is_leap_year_default(firstDate.getFullYear()) && firstDate.getDate() === 28) {
|
|
78
87
|
return [28, 29, 30, 31].includes(secondDate.getDate());
|
|
79
88
|
}
|
|
80
89
|
}
|
|
@@ -82,7 +91,7 @@ function nonLeapYearFebruaryChecks(firstDate, secondDate) {
|
|
|
82
91
|
}
|
|
83
92
|
function leapYearFebruaryChecks(firstDate, secondDate) {
|
|
84
93
|
if (firstDate.getMonth() === 1) {
|
|
85
|
-
if (firstDate.getFullYear()
|
|
94
|
+
if (is_leap_year_default(firstDate.getFullYear()) && firstDate.getDate() === 29) {
|
|
86
95
|
return [29, 30, 31].includes(secondDate.getDate());
|
|
87
96
|
}
|
|
88
97
|
}
|
|
@@ -165,6 +174,7 @@ export {
|
|
|
165
174
|
convert_file_to_base_64_default as convertFileToBase64,
|
|
166
175
|
format_date_and_time_default as formatDateAndTime,
|
|
167
176
|
get_random_number_default as getRandomNumber,
|
|
177
|
+
is_leap_year_default as isLeapYear,
|
|
168
178
|
is_monthly_multiple_default as isMonthlyMultiple,
|
|
169
179
|
is_same_date_default as isSameDate,
|
|
170
180
|
randomise_array_default as randomiseArray,
|