@alextheman/utility 1.9.1 → 1.10.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 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() % 4 !== 0 && firstDate.getDate() === 28) {
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() % 4 === 0 && firstDate.getDate() === 29) {
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() % 4 !== 0 && firstDate.getDate() === 28) {
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() % 4 === 0 && firstDate.getDate() === 29) {
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,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alextheman/utility",
3
- "version": "1.9.1",
3
+ "version": "1.10.0",
4
4
  "main": "dist/index.cjs",
5
5
  "module": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -25,10 +25,10 @@
25
25
  "license": "ISC",
26
26
  "description": "",
27
27
  "devDependencies": {
28
- "@alextheman/eslint-plugin": "^1.2.10",
29
- "@eslint/js": "^9.32.0",
30
- "@types/node": "^24.2.0",
31
- "eslint": "^9.32.0",
28
+ "@alextheman/eslint-plugin": "^1.2.11",
29
+ "@eslint/js": "^9.33.0",
30
+ "@types/node": "^24.2.1",
31
+ "eslint": "^9.33.0",
32
32
  "eslint-import-resolver-typescript": "^4.4.4",
33
33
  "eslint-plugin-import": "^2.32.0",
34
34
  "globals": "^16.3.0",