@alextheman/utility 2.21.0 → 3.0.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.js CHANGED
@@ -1,674 +1,521 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
3
- var __hasOwnProp = Object.prototype.hasOwnProperty;
4
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
5
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6
- var __spreadValues = (a, b) => {
7
- for (var prop in b || (b = {}))
8
- if (__hasOwnProp.call(b, prop))
9
- __defNormalProp(a, prop, b[prop]);
10
- if (__getOwnPropSymbols)
11
- for (var prop of __getOwnPropSymbols(b)) {
12
- if (__propIsEnum.call(b, prop))
13
- __defNormalProp(a, prop, b[prop]);
14
- }
15
- return a;
16
- };
17
- var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
1
+ import path from "path";
2
+ import z, { z as z$1 } from "zod";
18
3
 
19
- // src/functions/addDaysToDate.ts
4
+ //#region src/functions/addDaysToDate.ts
20
5
  function addDaysToDate(currentDate = /* @__PURE__ */ new Date(), dayIncrement = 1) {
21
- const newDate = currentDate;
22
- newDate.setDate(newDate.getDate() + dayIncrement);
23
- return newDate;
6
+ const newDate = currentDate;
7
+ newDate.setDate(newDate.getDate() + dayIncrement);
8
+ return newDate;
24
9
  }
25
10
  var addDaysToDate_default = addDaysToDate;
26
11
 
27
- // src/functions/appendSemicolon.ts
12
+ //#endregion
13
+ //#region src/functions/appendSemicolon.ts
28
14
  function appendSemicolon(stringToAppendTo) {
29
- if (stringToAppendTo.includes("\n")) {
30
- throw new Error("MULTIPLE_LINE_ERROR");
31
- }
32
- const stringWithNoTrailingWhitespace = stringToAppendTo.trimEnd();
33
- if (stringWithNoTrailingWhitespace === "") {
34
- return "";
35
- }
36
- return stringWithNoTrailingWhitespace[stringWithNoTrailingWhitespace.length - 1] === ";" ? stringWithNoTrailingWhitespace : `${stringWithNoTrailingWhitespace};`;
15
+ if (stringToAppendTo.includes("\n")) throw new Error("MULTIPLE_LINE_ERROR");
16
+ const stringWithNoTrailingWhitespace = stringToAppendTo.trimEnd();
17
+ if (stringWithNoTrailingWhitespace === "") return "";
18
+ return stringWithNoTrailingWhitespace[stringWithNoTrailingWhitespace.length - 1] === ";" ? stringWithNoTrailingWhitespace : `${stringWithNoTrailingWhitespace};`;
37
19
  }
38
20
  var appendSemicolon_default = appendSemicolon;
39
21
 
40
- // src/functions/camelToKebab.ts
22
+ //#endregion
23
+ //#region src/functions/camelToKebab.ts
41
24
  function camelToKebab(string) {
42
- return string.replace(/([a-z0-9])([A-Z])/g, "$1-$2").replace(/([A-Z])([A-Z][a-z])/g, "$1-$2").toLowerCase();
25
+ return string.replace(/([a-z0-9])([A-Z])/g, "$1-$2").replace(/([A-Z])([A-Z][a-z])/g, "$1-$2").toLowerCase();
43
26
  }
44
27
  var camelToKebab_default = camelToKebab;
45
28
 
46
- // src/functions/convertFileToBase64.ts
29
+ //#endregion
30
+ //#region src/functions/convertFileToBase64.ts
47
31
  function convertFileToBase64(file) {
48
- return new Promise((resolve, reject) => {
49
- const reader = new FileReader();
50
- reader.readAsDataURL(file);
51
- reader.onload = () => {
52
- if (reader.result === null) {
53
- reject(new Error("FILE_CONVERSION_ERROR"));
54
- return;
55
- }
56
- resolve(reader.result);
57
- };
58
- reader.onerror = () => {
59
- reject(new Error("FILE_READER_ERROR"));
60
- };
61
- });
32
+ return new Promise((resolve, reject) => {
33
+ const reader = new FileReader();
34
+ reader.readAsDataURL(file);
35
+ reader.onload = () => {
36
+ if (reader.result === null) {
37
+ reject(/* @__PURE__ */ new Error("FILE_CONVERSION_ERROR"));
38
+ return;
39
+ }
40
+ resolve(reader.result);
41
+ };
42
+ reader.onerror = () => {
43
+ reject(/* @__PURE__ */ new Error("FILE_READER_ERROR"));
44
+ };
45
+ });
62
46
  }
63
47
  var convertFileToBase64_default = convertFileToBase64;
64
48
 
65
- // src/functions/createFormData.ts
49
+ //#endregion
50
+ //#region src/functions/createFormData.ts
66
51
  function getNullableResolutionStrategy(key, strategy) {
67
- var _a;
68
- return (_a = typeof strategy === "object" ? strategy[key] : strategy) != null ? _a : "empty";
52
+ return (typeof strategy === "object" ? strategy[key] : strategy) ?? "empty";
69
53
  }
70
54
  function createFormData(data, options = {
71
- arrayResolution: "stringify",
72
- nullableResolution: "empty"
55
+ arrayResolution: "stringify",
56
+ nullableResolution: "empty"
73
57
  }) {
74
- const formData = new FormData();
75
- function resolveNullablesByStrategy(key, value, resolutionStrategy) {
76
- switch (resolutionStrategy) {
77
- case "empty":
78
- formData.append(String(key), "");
79
- break;
80
- case "stringify":
81
- formData.append(String(key), JSON.stringify(value));
82
- break;
83
- case "omit":
84
- break;
85
- default:
86
- throw new TypeError("SLOPPY_PURE_JAVASCRIPT_USER_ERROR");
87
- }
88
- }
89
- function resolveNullables(key, value, options2) {
90
- if (options2.nullableResolution) {
91
- resolveNullablesByStrategy(
92
- key,
93
- value,
94
- getNullableResolutionStrategy(key, options2.nullableResolution)
95
- );
96
- return;
97
- }
98
- if (options2.undefinedResolution || options2.nullResolution) {
99
- if (data[key] === void 0 && options2.undefinedResolution) {
100
- resolveNullablesByStrategy(
101
- key,
102
- value,
103
- getNullableResolutionStrategy(key, options2.undefinedResolution)
104
- );
105
- return;
106
- }
107
- if (data[key] === null && options2.nullResolution) {
108
- resolveNullablesByStrategy(
109
- key,
110
- value,
111
- getNullableResolutionStrategy(key, options2.nullResolution)
112
- );
113
- }
114
- }
115
- }
116
- const entries = Object.entries(data);
117
- for (const [key, value] of entries) {
118
- if (value instanceof Blob) {
119
- formData.append(String(key), value);
120
- } else if (value === void 0 || value === null) {
121
- resolveNullables(key, value, options);
122
- } else if (typeof value === "object") {
123
- if (Array.isArray(value)) {
124
- if (value.some((item) => {
125
- return item instanceof Blob;
126
- }) && (options.arrayResolution === "stringify" || typeof options.arrayResolution === "object" && options.arrayResolution[key] === "stringify")) {
127
- throw new TypeError("CANNOT_STRINGIFY_BLOB");
128
- }
129
- if (options.arrayResolution === "multiple" || typeof options.arrayResolution === "object" && options.arrayResolution[key] === "multiple") {
130
- for (const item of value) {
131
- if ((typeof item === "object" || !item) && !(item instanceof Blob)) {
132
- throw new TypeError("NON_PRIMITIVE_ARRAY_ITEMS_FOUND");
133
- }
134
- if (item instanceof Blob) {
135
- formData.append(String(key), item);
136
- } else {
137
- formData.append(String(key), String(item));
138
- }
139
- }
140
- continue;
141
- }
142
- }
143
- formData.append(String(key), JSON.stringify(value));
144
- } else {
145
- formData.append(String(key), String(value));
146
- }
147
- }
148
- return formData;
58
+ const formData = new FormData();
59
+ function resolveNullablesByStrategy(key, value, resolutionStrategy) {
60
+ switch (resolutionStrategy) {
61
+ case "empty":
62
+ formData.append(String(key), "");
63
+ break;
64
+ case "stringify":
65
+ formData.append(String(key), JSON.stringify(value));
66
+ break;
67
+ case "omit": break;
68
+ default: throw new TypeError("SLOPPY_PURE_JAVASCRIPT_USER_ERROR");
69
+ }
70
+ }
71
+ function resolveNullables(key, value, options$1) {
72
+ if (options$1.nullableResolution) {
73
+ resolveNullablesByStrategy(key, value, getNullableResolutionStrategy(key, options$1.nullableResolution));
74
+ return;
75
+ }
76
+ if (options$1.undefinedResolution || options$1.nullResolution) {
77
+ if (data[key] === void 0 && options$1.undefinedResolution) {
78
+ resolveNullablesByStrategy(key, value, getNullableResolutionStrategy(key, options$1.undefinedResolution));
79
+ return;
80
+ }
81
+ if (data[key] === null && options$1.nullResolution) resolveNullablesByStrategy(key, value, getNullableResolutionStrategy(key, options$1.nullResolution));
82
+ }
83
+ }
84
+ const entries = Object.entries(data);
85
+ for (const [key, value] of entries) if (value instanceof Blob) formData.append(String(key), value);
86
+ else if (value === void 0 || value === null) resolveNullables(key, value, options);
87
+ else if (typeof value === "object") {
88
+ if (Array.isArray(value)) {
89
+ if (value.some((item) => {
90
+ return item instanceof Blob;
91
+ }) && (options.arrayResolution === "stringify" || typeof options.arrayResolution === "object" && options.arrayResolution[key] === "stringify")) throw new TypeError("CANNOT_STRINGIFY_BLOB");
92
+ if (options.arrayResolution === "multiple" || typeof options.arrayResolution === "object" && options.arrayResolution[key] === "multiple") {
93
+ for (const item of value) {
94
+ if ((typeof item === "object" || !item) && !(item instanceof Blob)) throw new TypeError("NON_PRIMITIVE_ARRAY_ITEMS_FOUND");
95
+ if (item instanceof Blob) formData.append(String(key), item);
96
+ else formData.append(String(key), String(item));
97
+ }
98
+ continue;
99
+ }
100
+ }
101
+ formData.append(String(key), JSON.stringify(value));
102
+ } else formData.append(String(key), String(value));
103
+ return formData;
149
104
  }
150
105
  var createFormData_default = createFormData;
151
106
 
152
- // src/functions/createTemplateStringsArray.ts
107
+ //#endregion
108
+ //#region src/functions/createTemplateStringsArray.ts
153
109
  function createTemplateStringsArray(strings) {
154
- return Object.assign([...strings], { raw: [...strings] });
110
+ return Object.assign([...strings], { raw: [...strings] });
155
111
  }
156
112
  var createTemplateStringsArray_default = createTemplateStringsArray;
157
113
 
158
- // src/functions/fillArray.ts
114
+ //#endregion
115
+ //#region src/functions/fillArray.ts
159
116
  function fillArray(callback, length = 1) {
160
- const outputArray = new Array(length).fill(null).map((_, index) => {
161
- return callback(index);
162
- });
163
- const isAsync = outputArray.some((item) => {
164
- return item instanceof Promise;
165
- });
166
- if (isAsync) {
167
- return Promise.all(outputArray);
168
- }
169
- return outputArray;
117
+ const outputArray = new Array(length).fill(null).map((_, index) => {
118
+ return callback(index);
119
+ });
120
+ if (outputArray.some((item) => {
121
+ return item instanceof Promise;
122
+ })) return Promise.all(outputArray);
123
+ return outputArray;
170
124
  }
171
125
  var fillArray_default = fillArray;
172
126
 
173
- // src/functions/isSameDate.ts
127
+ //#endregion
128
+ //#region src/functions/isSameDate.ts
174
129
  function isSameDate(firstDate, secondDate) {
175
- return firstDate.getDate() === secondDate.getDate() && firstDate.getMonth() === secondDate.getMonth() && firstDate.getFullYear() === secondDate.getFullYear();
130
+ return firstDate.getDate() === secondDate.getDate() && firstDate.getMonth() === secondDate.getMonth() && firstDate.getFullYear() === secondDate.getFullYear();
176
131
  }
177
132
  var isSameDate_default = isSameDate;
178
133
 
179
- // src/functions/formatDateAndTime.ts
134
+ //#endregion
135
+ //#region src/functions/formatDateAndTime.ts
180
136
  function formatDateAndTime(inputDate) {
181
- const yesterday = addDaysToDate_default(/* @__PURE__ */ new Date(), -1);
182
- const today = /* @__PURE__ */ new Date();
183
- const inputTime = `${inputDate.getHours().toString().padStart(2, "0")}:${inputDate.getMinutes().toString().padStart(2, "0")}`;
184
- if (isSameDate_default(inputDate, yesterday)) {
185
- return `Yesterday at ${inputTime}`;
186
- }
187
- if (isSameDate_default(inputDate, today)) {
188
- return `Today at ${inputTime}`;
189
- }
190
- const formattedInputDay = inputDate.getDate().toString().padStart(2, "0");
191
- const formattedInputMonth = (inputDate.getMonth() + 1).toString().padStart(2, "0");
192
- const formattedInputYear = inputDate.getFullYear().toString();
193
- return `${formattedInputDay}/${formattedInputMonth}/${formattedInputYear}, ${inputTime}`;
137
+ const yesterday = addDaysToDate_default(/* @__PURE__ */ new Date(), -1);
138
+ const today = /* @__PURE__ */ new Date();
139
+ const inputTime = `${inputDate.getHours().toString().padStart(2, "0")}:${inputDate.getMinutes().toString().padStart(2, "0")}`;
140
+ if (isSameDate_default(inputDate, yesterday)) return `Yesterday at ${inputTime}`;
141
+ if (isSameDate_default(inputDate, today)) return `Today at ${inputTime}`;
142
+ return `${inputDate.getDate().toString().padStart(2, "0")}/${(inputDate.getMonth() + 1).toString().padStart(2, "0")}/${inputDate.getFullYear().toString()}, ${inputTime}`;
194
143
  }
195
144
  var formatDateAndTime_default = formatDateAndTime;
196
145
 
197
- // src/functions/parseIntStrict.ts
198
- var IntegerParsingError = new TypeError("INTEGER_PARSING_ERROR");
146
+ //#endregion
147
+ //#region src/functions/parseIntStrict.ts
148
+ const IntegerParsingError = /* @__PURE__ */ new TypeError("INTEGER_PARSING_ERROR");
199
149
  function parseIntStrict(...[string, radix]) {
200
- const trimmedString = string.trim();
201
- const pattern = radix && radix > 10 && radix <= 36 ? (
202
- // String.fromCharCode() gets the maximum possible alphabetical character for a base above 10
203
- new RegExp(`^[+-]?[0-9a-${String.fromCharCode(87 + radix - 1)}]+$`, "i")
204
- ) : /^[+-]?\d+$/;
205
- if (!pattern.test(trimmedString)) {
206
- throw IntegerParsingError;
207
- }
208
- if (radix && radix < 10 && [...trimmedString].some((character) => {
209
- return parseInt(character) >= radix;
210
- })) {
211
- throw IntegerParsingError;
212
- }
213
- const parseIntResult = parseInt(trimmedString, radix);
214
- if (isNaN(parseIntResult)) {
215
- throw IntegerParsingError;
216
- }
217
- return parseIntResult;
150
+ const trimmedString = string.trim();
151
+ if (!(radix && radix > 10 && radix <= 36 ? new RegExp(`^[+-]?[0-9a-${String.fromCharCode(87 + radix - 1)}]+$`, "i") : /^[+-]?\d+$/).test(trimmedString)) throw IntegerParsingError;
152
+ if (radix && radix < 10 && [...trimmedString].some((character) => {
153
+ return parseInt(character) >= radix;
154
+ })) throw IntegerParsingError;
155
+ const parseIntResult = parseInt(trimmedString, radix);
156
+ if (isNaN(parseIntResult)) throw IntegerParsingError;
157
+ return parseIntResult;
218
158
  }
219
159
  var parseIntStrict_default = parseIntStrict;
220
160
 
221
- // src/functions/getRandomNumber.ts
161
+ //#endregion
162
+ //#region src/functions/getRandomNumber.ts
222
163
  function getRandomNumber(lowerBound, upperBound) {
223
- const parsedLowerBound = parseIntStrict_default(`${lowerBound}`);
224
- const parsedUpperBound = parseIntStrict_default(`${upperBound}`);
225
- return Math.floor(Math.random() * (parsedUpperBound - parsedLowerBound + 1) + parsedLowerBound);
164
+ const parsedLowerBound = parseIntStrict_default(`${lowerBound}`);
165
+ const parsedUpperBound = parseIntStrict_default(`${upperBound}`);
166
+ return Math.floor(Math.random() * (parsedUpperBound - parsedLowerBound + 1) + parsedLowerBound);
226
167
  }
227
168
  var getRandomNumber_default = getRandomNumber;
228
169
 
229
- // src/functions/getRecordKeys.ts
170
+ //#endregion
171
+ //#region src/functions/getRecordKeys.ts
230
172
  function getRecordKeys(record) {
231
- return Object.keys(record);
173
+ return Object.keys(record);
232
174
  }
233
175
  var getRecordKeys_default = getRecordKeys;
234
176
 
235
- // src/functions/isLeapYear.ts
177
+ //#endregion
178
+ //#region src/functions/isLeapYear.ts
236
179
  function isLeapYear(year) {
237
- const parsedYear = parseIntStrict_default(`${year}`);
238
- return parsedYear % 4 === 0 && parsedYear % 100 !== 0 || parsedYear % 400 === 0;
180
+ const parsedYear = parseIntStrict_default(`${year}`);
181
+ return parsedYear % 4 === 0 && parsedYear % 100 !== 0 || parsedYear % 400 === 0;
239
182
  }
240
183
  var isLeapYear_default = isLeapYear;
241
184
 
242
- // src/functions/isMonthlyMultiple.ts
185
+ //#endregion
186
+ //#region src/functions/isMonthlyMultiple.ts
243
187
  function endOfMonthChecksButNotFebruary(firstDate, secondDate) {
244
- if ([3, 5, 8, 10].includes(firstDate.getMonth())) {
245
- return firstDate.getDate() === 30 && secondDate.getDate() === 31;
246
- }
247
- return false;
188
+ if ([
189
+ 3,
190
+ 5,
191
+ 8,
192
+ 10
193
+ ].includes(firstDate.getMonth())) return firstDate.getDate() === 30 && secondDate.getDate() === 31;
194
+ return false;
248
195
  }
249
196
  function nonLeapYearFebruaryChecks(firstDate, secondDate) {
250
- if (firstDate.getMonth() === 1) {
251
- if (!isLeapYear_default(firstDate.getFullYear()) && firstDate.getDate() === 28) {
252
- return [28, 29, 30, 31].includes(secondDate.getDate());
253
- }
254
- }
255
- return false;
197
+ if (firstDate.getMonth() === 1) {
198
+ if (!isLeapYear_default(firstDate.getFullYear()) && firstDate.getDate() === 28) return [
199
+ 28,
200
+ 29,
201
+ 30,
202
+ 31
203
+ ].includes(secondDate.getDate());
204
+ }
205
+ return false;
256
206
  }
257
207
  function leapYearFebruaryChecks(firstDate, secondDate) {
258
- if (firstDate.getMonth() === 1) {
259
- if (isLeapYear_default(firstDate.getFullYear()) && firstDate.getDate() === 29) {
260
- return [29, 30, 31].includes(secondDate.getDate());
261
- }
262
- }
263
- return false;
208
+ if (firstDate.getMonth() === 1) {
209
+ if (isLeapYear_default(firstDate.getFullYear()) && firstDate.getDate() === 29) return [
210
+ 29,
211
+ 30,
212
+ 31
213
+ ].includes(secondDate.getDate());
214
+ }
215
+ return false;
264
216
  }
265
217
  function isMonthlyMultiple(firstDate, secondDate) {
266
- if (endOfMonthChecksButNotFebruary(firstDate, secondDate) || endOfMonthChecksButNotFebruary(secondDate, firstDate)) {
267
- return true;
268
- }
269
- if (nonLeapYearFebruaryChecks(firstDate, secondDate) || nonLeapYearFebruaryChecks(secondDate, firstDate)) {
270
- return true;
271
- }
272
- if (leapYearFebruaryChecks(firstDate, secondDate) || leapYearFebruaryChecks(secondDate, firstDate)) {
273
- return true;
274
- }
275
- return firstDate.getDate() === secondDate.getDate();
218
+ if (endOfMonthChecksButNotFebruary(firstDate, secondDate) || endOfMonthChecksButNotFebruary(secondDate, firstDate)) return true;
219
+ if (nonLeapYearFebruaryChecks(firstDate, secondDate) || nonLeapYearFebruaryChecks(secondDate, firstDate)) return true;
220
+ if (leapYearFebruaryChecks(firstDate, secondDate) || leapYearFebruaryChecks(secondDate, firstDate)) return true;
221
+ return firstDate.getDate() === secondDate.getDate();
276
222
  }
277
223
  var isMonthlyMultiple_default = isMonthlyMultiple;
278
224
 
279
- // src/functions/isOrdered.ts
225
+ //#endregion
226
+ //#region src/functions/isOrdered.ts
280
227
  function isOrdered(array) {
281
- const newArray = [...array];
282
- newArray.sort();
283
- for (const index in newArray) {
284
- if (newArray[index] !== array[index]) {
285
- return false;
286
- }
287
- }
288
- return true;
228
+ const newArray = [...array];
229
+ newArray.sort();
230
+ for (const index in newArray) if (newArray[index] !== array[index]) return false;
231
+ return true;
289
232
  }
290
233
  var isOrdered_default = isOrdered;
291
234
 
292
- // src/functions/kebabToCamel.ts
235
+ //#endregion
236
+ //#region src/functions/kebabToCamel.ts
293
237
  function kebabToCamel(string, options) {
294
- if (string !== string.toLowerCase()) {
295
- throw new Error("INVALID_KEBAB_CASE_INPUT");
296
- }
297
- if (string.startsWith("-") || string.endsWith("-") || string.includes("--")) {
298
- throw new Error("INVALID_KEBAB_CASE_INPUT");
299
- }
300
- let outputString = "";
301
- let skip = false;
302
- for (const stringIndex in [...string]) {
303
- if (skip) {
304
- skip = false;
305
- continue;
306
- }
307
- const index = parseIntStrict_default(stringIndex);
308
- if (index === 0 && (options == null ? void 0 : options.startWithUpper)) {
309
- outputString += string[index].toUpperCase();
310
- continue;
311
- }
312
- if (index === string.length - 1) {
313
- outputString += string[index];
314
- break;
315
- }
316
- if (string[index] === "-" && /^[a-zA-Z]+$/.test(string[index + 1])) {
317
- outputString += string[index + 1].toUpperCase();
318
- skip = true;
319
- } else {
320
- outputString += string[index];
321
- }
322
- }
323
- return outputString;
238
+ if (string !== string.toLowerCase()) throw new Error("INVALID_KEBAB_CASE_INPUT");
239
+ if (string.startsWith("-") || string.endsWith("-") || string.includes("--")) throw new Error("INVALID_KEBAB_CASE_INPUT");
240
+ let outputString = "";
241
+ let skip = false;
242
+ for (const stringIndex in [...string]) {
243
+ if (skip) {
244
+ skip = false;
245
+ continue;
246
+ }
247
+ const index = parseIntStrict_default(stringIndex);
248
+ if (index === 0 && options?.startWithUpper) {
249
+ outputString += string[index].toUpperCase();
250
+ continue;
251
+ }
252
+ if (index === string.length - 1) {
253
+ outputString += string[index];
254
+ break;
255
+ }
256
+ if (string[index] === "-" && /^[a-zA-Z]+$/.test(string[index + 1])) {
257
+ outputString += string[index + 1].toUpperCase();
258
+ skip = true;
259
+ } else outputString += string[index];
260
+ }
261
+ return outputString;
324
262
  }
325
263
  var kebabToCamel_default = kebabToCamel;
326
264
 
327
- // src/functions/normalizeImportPath.ts
328
- import path from "path";
265
+ //#endregion
266
+ //#region src/functions/normalizeImportPath.ts
329
267
  function normalizeImportPath(importPath) {
330
- const normalizedPath = path.posix.normalize(importPath);
331
- if (importPath.startsWith("./") && !normalizedPath.startsWith("./")) {
332
- return `./${normalizedPath}`;
333
- }
334
- return normalizedPath;
268
+ const normalizedPath = path.posix.normalize(importPath);
269
+ if (importPath.startsWith("./") && !normalizedPath.startsWith("./")) return `./${normalizedPath}`;
270
+ return normalizedPath;
335
271
  }
336
- var normaliseImportPath = normalizeImportPath;
272
+ const normaliseImportPath = normalizeImportPath;
337
273
  var normalizeImportPath_default = normalizeImportPath;
338
274
 
339
- // src/functions/omitProperties.ts
275
+ //#endregion
276
+ //#region src/functions/omitProperties.ts
340
277
  function omitProperties(object, keysToOmit) {
341
- const outputObject = __spreadValues({}, object);
342
- const keysArray = Array.isArray(keysToOmit) ? keysToOmit : [keysToOmit];
343
- keysArray.forEach((key) => {
344
- delete outputObject[key];
345
- });
346
- return outputObject;
278
+ const outputObject = { ...object };
279
+ (Array.isArray(keysToOmit) ? keysToOmit : [keysToOmit]).forEach((key) => {
280
+ delete outputObject[key];
281
+ });
282
+ return outputObject;
347
283
  }
348
284
  var omitProperties_default = omitProperties;
349
285
 
350
- // src/functions/paralleliseArrays.ts
286
+ //#endregion
287
+ //#region src/functions/paralleliseArrays.ts
351
288
  function paralleliseArrays(firstArray, secondArray) {
352
- const outputArray = [];
353
- for (let i = 0; i < firstArray.length; i++) {
354
- outputArray.push([firstArray[i], secondArray[i]]);
355
- }
356
- return outputArray;
289
+ const outputArray = [];
290
+ for (let i = 0; i < firstArray.length; i++) outputArray.push([firstArray[i], secondArray[i]]);
291
+ return outputArray;
357
292
  }
358
293
  var paralleliseArrays_default = paralleliseArrays;
359
294
 
360
- // src/types/APIError.ts
361
- var httpErrorCodeLookup = {
362
- 400: "BAD_REQUEST",
363
- 401: "UNAUTHORISED",
364
- 403: "FORBIDDEN",
365
- 404: "NOT_FOUND",
366
- /* Supporting this one too because it's funny. You'll never use it in practice because
367
- why would an error give a teapot, but it's funny. Do not question me. */
368
- 418: "I_AM_A_TEAPOT",
369
- 500: "INTERNAL_SERVER_ERROR"
295
+ //#endregion
296
+ //#region src/types/APIError.ts
297
+ const httpErrorCodeLookup = {
298
+ 400: "BAD_REQUEST",
299
+ 401: "UNAUTHORISED",
300
+ 403: "FORBIDDEN",
301
+ 404: "NOT_FOUND",
302
+ 418: "I_AM_A_TEAPOT",
303
+ 500: "INTERNAL_SERVER_ERROR"
370
304
  };
371
305
  var APIError = class extends Error {
372
- constructor(status = 500, message, options) {
373
- var _a;
374
- super(message, options);
375
- __publicField(this, "status");
376
- this.status = status;
377
- if (message) {
378
- this.message = message;
379
- } else {
380
- this.message = (_a = httpErrorCodeLookup[this.status]) != null ? _a : "API_ERROR";
381
- }
382
- Object.defineProperty(this, "message", { enumerable: true });
383
- Object.setPrototypeOf(this, new.target.prototype);
384
- }
385
- static check(input) {
386
- const data = input;
387
- return typeof data === "object" && data !== null && typeof (data == null ? void 0 : data.status) === "number" && typeof (data == null ? void 0 : data.message) === "string";
388
- }
306
+ status;
307
+ constructor(status = 500, message, options) {
308
+ super(message, options);
309
+ this.status = status;
310
+ if (message) this.message = message;
311
+ else this.message = httpErrorCodeLookup[this.status] ?? "API_ERROR";
312
+ Object.defineProperty(this, "message", { enumerable: true });
313
+ Object.setPrototypeOf(this, new.target.prototype);
314
+ }
315
+ static check(input) {
316
+ const data = input;
317
+ return typeof data === "object" && data !== null && typeof data?.status === "number" && typeof data?.message === "string";
318
+ }
389
319
  };
390
320
  var APIError_default = APIError;
391
321
 
392
- // src/types/DataError.ts
322
+ //#endregion
323
+ //#region src/types/DataError.ts
393
324
  var DataError = class extends Error {
394
- /** @param data - The data that caused the error. */
395
- /** @param message - A human-readable error message (e.g. The data provided is invalid). */
396
- /** @param code - A standardised code (e.g. UNEXPECTED_DATA). */
397
- /** @param options - Extra options to pass to super Error constructor. */
398
- constructor(data, message = "The data provided is invalid", code = "INVALID_DATA", options) {
399
- super(message, options);
400
- __publicField(this, "data");
401
- __publicField(this, "code");
402
- if (Error.captureStackTrace) {
403
- Error.captureStackTrace(this, new.target);
404
- }
405
- this.name = new.target.name;
406
- this.code = code;
407
- this.data = data;
408
- Object.defineProperty(this, "message", { enumerable: true });
409
- Object.setPrototypeOf(this, new.target.prototype);
410
- }
411
- static check(input) {
412
- const data = input;
413
- return typeof data === "object" && data !== null && typeof data.message === "string" && typeof data.code === "string" && "data" in data;
414
- }
325
+ data;
326
+ code;
327
+ /** @param data - The data that caused the error. */
328
+ /** @param message - A human-readable error message (e.g. The data provided is invalid). */
329
+ /** @param code - A standardised code (e.g. UNEXPECTED_DATA). */
330
+ /** @param options - Extra options to pass to super Error constructor. */
331
+ constructor(data, message = "The data provided is invalid", code = "INVALID_DATA", options) {
332
+ super(message, options);
333
+ if (Error.captureStackTrace) Error.captureStackTrace(this, new.target);
334
+ this.name = new.target.name;
335
+ this.code = code;
336
+ this.data = data;
337
+ Object.defineProperty(this, "message", { enumerable: true });
338
+ Object.setPrototypeOf(this, new.target.prototype);
339
+ }
340
+ static check(input) {
341
+ const data = input;
342
+ return typeof data === "object" && data !== null && typeof data.message === "string" && typeof data.code === "string" && "data" in data;
343
+ }
415
344
  };
416
345
  var DataError_default = DataError;
417
346
 
418
- // src/types/Email.ts
419
- import z from "zod";
420
- var emailSchema = z.email().brand();
347
+ //#endregion
348
+ //#region src/types/Email.ts
349
+ const emailSchema = z.email().brand();
421
350
  function parseEmail(data) {
422
- return emailSchema.parse(data);
351
+ return emailSchema.parse(data);
423
352
  }
424
353
  var Email_default = parseEmail;
425
354
 
426
- // src/types/Env.ts
427
- import { z as z2 } from "zod";
428
- var envSchema = z2.enum(["test", "development", "production"]);
355
+ //#endregion
356
+ //#region src/types/Env.ts
357
+ const envSchema = z$1.enum([
358
+ "test",
359
+ "development",
360
+ "production"
361
+ ]);
429
362
  function parseEnv(data = "development") {
430
- return envSchema.parse(data);
363
+ return envSchema.parse(data);
431
364
  }
432
365
  var Env_default = parseEnv;
433
366
 
434
- // src/types/UUID.ts
435
- import z3 from "zod";
436
- var uuidSchema = z3.uuid().brand();
367
+ //#endregion
368
+ //#region src/types/UUID.ts
369
+ const uuidSchema = z.uuid().brand();
437
370
  function parseUUID(UUID) {
438
- return uuidSchema.parse(UUID);
371
+ return uuidSchema.parse(UUID);
439
372
  }
440
373
  var UUID_default = parseUUID;
441
374
 
442
- // src/functions/parseZodSchema.ts
375
+ //#endregion
376
+ //#region src/functions/parseZodSchema.ts
443
377
  function parseZodSchema(schema, data) {
444
- const parsedResult = schema.safeParse(data);
445
- if (!parsedResult.success) {
446
- throw new DataError_default(data);
447
- }
448
- return parsedResult.data;
378
+ const parsedResult = schema.safeParse(data);
379
+ if (!parsedResult.success) throw new DataError_default(data);
380
+ return parsedResult.data;
449
381
  }
450
382
  var parseZodSchema_default = parseZodSchema;
451
383
 
452
- // src/functions/randomiseArray.ts
384
+ //#endregion
385
+ //#region src/functions/randomiseArray.ts
453
386
  function randomiseArray(array) {
454
- const mutableArray = [...array];
455
- const outputArray = [];
456
- do {
457
- const indexToRemove = getRandomNumber_default(0, mutableArray.length - 1);
458
- outputArray.push(mutableArray.splice(indexToRemove, 1)[0]);
459
- } while (mutableArray.length > 0);
460
- return outputArray;
387
+ const mutableArray = [...array];
388
+ const outputArray = [];
389
+ do {
390
+ const indexToRemove = getRandomNumber_default(0, mutableArray.length - 1);
391
+ outputArray.push(mutableArray.splice(indexToRemove, 1)[0]);
392
+ } while (mutableArray.length > 0);
393
+ return outputArray;
461
394
  }
462
395
  var randomiseArray_default = randomiseArray;
463
396
 
464
- // src/functions/range.ts
397
+ //#endregion
398
+ //#region src/functions/range.ts
465
399
  function range(start, stop, step = 1) {
466
- const numbers = [];
467
- if (step === 0) {
468
- throw new Error("ZERO_STEP_SIZE_NOT_ALLOWED");
469
- } else if (step > 0) {
470
- if (start > stop) {
471
- throw new Error("INVALID_BOUNDARIES");
472
- }
473
- for (let i = start; i < stop; i += step) {
474
- numbers.push(i);
475
- }
476
- } else if (step < 0) {
477
- if (start < stop) {
478
- throw new Error("INVALID_BOUNDARIES");
479
- }
480
- for (let i = start; i > stop; i += step) {
481
- numbers.push(i);
482
- }
483
- }
484
- return numbers;
400
+ const numbers = [];
401
+ if (step === 0) throw new Error("ZERO_STEP_SIZE_NOT_ALLOWED");
402
+ else if (step > 0) {
403
+ if (start > stop) throw new Error("INVALID_BOUNDARIES");
404
+ for (let i = start; i < stop; i += step) numbers.push(i);
405
+ } else if (step < 0) {
406
+ if (start < stop) throw new Error("INVALID_BOUNDARIES");
407
+ for (let i = start; i > stop; i += step) numbers.push(i);
408
+ }
409
+ return numbers;
485
410
  }
486
411
  var range_default = range;
487
412
 
488
- // src/functions/removeDuplicates.ts
413
+ //#endregion
414
+ //#region src/functions/removeDuplicates.ts
489
415
  function removeDuplicates(array) {
490
- const outputArray = [];
491
- for (const item of array) {
492
- if (!outputArray.includes(item)) {
493
- outputArray.push(item);
494
- }
495
- }
496
- return outputArray;
416
+ const outputArray = [];
417
+ for (const item of array) if (!outputArray.includes(item)) outputArray.push(item);
418
+ return outputArray;
497
419
  }
498
420
  var removeDuplicates_default = removeDuplicates;
499
421
 
500
- // src/functions/stringListToArray.ts
422
+ //#endregion
423
+ //#region src/functions/stringListToArray.ts
501
424
  function stringListToArray(stringList, { separator = ",", trimWhitespace = true } = {}) {
502
- if (trimWhitespace && stringList.trim() === "") {
503
- return [];
504
- }
505
- const arrayList = stringList.split(separator != null ? separator : "");
506
- return trimWhitespace ? arrayList.map((item) => {
507
- return item.trim();
508
- }) : arrayList;
425
+ if (trimWhitespace && stringList.trim() === "") return [];
426
+ const arrayList = stringList.split(separator ?? "");
427
+ return trimWhitespace ? arrayList.map((item) => {
428
+ return item.trim();
429
+ }) : arrayList;
509
430
  }
510
431
  var stringListToArray_default = stringListToArray;
511
432
 
512
- // src/functions/stringToBoolean.ts
433
+ //#endregion
434
+ //#region src/functions/stringToBoolean.ts
513
435
  function stringToBoolean(inputString) {
514
- const normalisedString = inputString.toLowerCase();
515
- if (normalisedString !== "true" && normalisedString !== "false") {
516
- throw new TypeError("INVALID_BOOLEAN_STRING");
517
- }
518
- return normalisedString === "true";
436
+ const normalisedString = inputString.toLowerCase();
437
+ if (normalisedString !== "true" && normalisedString !== "false") throw new TypeError("INVALID_BOOLEAN_STRING");
438
+ return normalisedString === "true";
519
439
  }
520
440
  var stringToBoolean_default = stringToBoolean;
521
441
 
522
- // src/functions/truncate.ts
442
+ //#endregion
443
+ //#region src/functions/truncate.ts
523
444
  function truncate(stringToTruncate, maxLength = 5) {
524
- return stringToTruncate.length > maxLength ? `${stringToTruncate.slice(0, maxLength)}...` : stringToTruncate;
445
+ return stringToTruncate.length > maxLength ? `${stringToTruncate.slice(0, maxLength)}...` : stringToTruncate;
525
446
  }
526
447
  var truncate_default = truncate;
527
448
 
528
- // src/functions/wait.ts
449
+ //#endregion
450
+ //#region src/functions/wait.ts
529
451
  function wait(seconds) {
530
- return new Promise((resolve, _) => {
531
- setTimeout(() => {
532
- resolve();
533
- }, seconds * 1e3);
534
- });
452
+ return new Promise((resolve, _) => {
453
+ setTimeout(() => {
454
+ resolve();
455
+ }, seconds * 1e3);
456
+ });
535
457
  }
536
458
  var wait_default = wait;
537
459
 
538
- // src/functions/taggedTemplate/interpolate.ts
460
+ //#endregion
461
+ //#region src/functions/taggedTemplate/interpolate.ts
539
462
  function interpolate(strings, ...interpolations) {
540
- let result = "";
541
- for (const [string, interpolation = ""] of paralleliseArrays_default(strings, interpolations)) {
542
- result += string + interpolation;
543
- }
544
- return result;
463
+ let result = "";
464
+ for (const [string, interpolation = ""] of paralleliseArrays_default(strings, interpolations)) result += string + interpolation;
465
+ return result;
545
466
  }
546
467
  var interpolate_default = interpolate;
547
468
 
548
- // src/functions/taggedTemplate/interpolateObjects.ts
469
+ //#endregion
470
+ //#region src/functions/taggedTemplate/interpolateObjects.ts
549
471
  function interpolateObjects(strings, ...values) {
550
- let result = "";
551
- for (let i = 0; i < strings.length; i++) {
552
- result += strings[i];
553
- if (i !== strings.length - 1) {
554
- result += values[i] && typeof values[i] === "object" ? JSON.stringify(values[i]) : values[i];
555
- }
556
- }
557
- return result;
472
+ let result = "";
473
+ for (let i = 0; i < strings.length; i++) {
474
+ result += strings[i];
475
+ if (i !== strings.length - 1) result += values[i] && typeof values[i] === "object" ? JSON.stringify(values[i]) : values[i];
476
+ }
477
+ return result;
558
478
  }
559
479
  var interpolateObjects_default = interpolateObjects;
560
480
 
561
- // src/functions/taggedTemplate/removeIndents.ts
481
+ //#endregion
482
+ //#region src/functions/taggedTemplate/removeIndents.ts
562
483
  function calculateTabSize(line, whitespaceLength) {
563
- const potentialWhitespacePart = line.slice(0, whitespaceLength);
564
- const trimmedString = line.trimStart();
565
- if (potentialWhitespacePart.trim() !== "") {
566
- return 0;
567
- }
568
- const tabSize = line.length - (trimmedString.length + whitespaceLength);
569
- return tabSize < 0 ? 0 : tabSize;
484
+ const potentialWhitespacePart = line.slice(0, whitespaceLength);
485
+ const trimmedString = line.trimStart();
486
+ if (potentialWhitespacePart.trim() !== "") return 0;
487
+ const tabSize = line.length - (trimmedString.length + whitespaceLength);
488
+ return tabSize < 0 ? 0 : tabSize;
570
489
  }
571
490
  function getWhitespaceLength(lines) {
572
- const [firstNonEmptyLine] = lines.filter((line) => {
573
- return line.trim() !== "";
574
- });
575
- return firstNonEmptyLine.length - firstNonEmptyLine.trimStart().length;
491
+ const [firstNonEmptyLine] = lines.filter((line) => {
492
+ return line.trim() !== "";
493
+ });
494
+ return firstNonEmptyLine.length - firstNonEmptyLine.trimStart().length;
576
495
  }
577
496
  function reduceLines(lines, { preserveTabs = true }) {
578
- const slicedLines = lines.slice(1);
579
- const isFirstLineEmpty = lines[0].trim() === "";
580
- const whitespaceLength = getWhitespaceLength(isFirstLineEmpty ? lines : slicedLines);
581
- return (isFirstLineEmpty ? slicedLines : lines).map((line) => {
582
- const tabSize = calculateTabSize(line, whitespaceLength);
583
- return (preserveTabs ? fillArray_default(() => {
584
- return " ";
585
- }, tabSize).join("") : "") + line.trimStart();
586
- }).join("\n");
497
+ const slicedLines = lines.slice(1);
498
+ const isFirstLineEmpty = lines[0].trim() === "";
499
+ const whitespaceLength = getWhitespaceLength(isFirstLineEmpty ? lines : slicedLines);
500
+ return (isFirstLineEmpty ? slicedLines : lines).map((line) => {
501
+ const tabSize = calculateTabSize(line, whitespaceLength);
502
+ return (preserveTabs ? fillArray_default(() => {
503
+ return " ";
504
+ }, tabSize).join("") : "") + line.trimStart();
505
+ }).join("\n");
587
506
  }
588
507
  function removeIndents(first, ...args) {
589
- if (typeof first === "object" && first !== null && !Array.isArray(first)) {
590
- const options2 = first;
591
- return (strings2, ...interpolations2) => {
592
- return removeIndents(strings2, ...interpolations2, options2);
593
- };
594
- }
595
- const strings = first;
596
- const options = typeof args[args.length - 1] === "object" && !Array.isArray(args[args.length - 1]) ? args.pop() : {};
597
- const interpolations = [...args];
598
- const fullString = interpolate_default(strings, ...interpolations);
599
- return reduceLines(fullString.split("\n"), options);
508
+ if (typeof first === "object" && first !== null && !Array.isArray(first)) {
509
+ const options$1 = first;
510
+ return (strings$1, ...interpolations) => {
511
+ return removeIndents(strings$1, ...interpolations, options$1);
512
+ };
513
+ }
514
+ const strings = first;
515
+ const options = typeof args[args.length - 1] === "object" && !Array.isArray(args[args.length - 1]) ? args.pop() : {};
516
+ return reduceLines(interpolate_default(strings, ...[...args]).split("\n"), options);
600
517
  }
601
518
  var removeIndents_default = removeIndents;
602
519
 
603
- // src/functions/taggedTemplate/stripIndents.ts
604
- function calculateTabSize2(line, whitespaceLength = 12) {
605
- const potentialWhitespacePart = line.slice(0, whitespaceLength);
606
- const trimmedString = line.trimStart();
607
- if (potentialWhitespacePart.trim() !== "") {
608
- return 0;
609
- }
610
- const tabSize = line.length - (trimmedString.length + whitespaceLength);
611
- return tabSize < 0 ? 0 : tabSize;
612
- }
613
- function reduceLines2(lines, { whitespaceLength = 12, preserveTabs = true }) {
614
- return lines.map((line) => {
615
- const tabSize = calculateTabSize2(line, whitespaceLength);
616
- return (preserveTabs ? fillArray_default(() => {
617
- return " ";
618
- }, tabSize).join("") : "") + line.trimStart();
619
- }).join("\n");
620
- }
621
- function stripIndents(first, ...args) {
622
- if (typeof first === "object" && first !== null && !Array.isArray(first)) {
623
- const options2 = first;
624
- return (strings2, ...interpolations2) => {
625
- return stripIndents(strings2, ...interpolations2, options2);
626
- };
627
- }
628
- const strings = first;
629
- const options = typeof args[args.length - 1] === "object" && !Array.isArray(args[args.length - 1]) ? args.pop() : {};
630
- const interpolations = [...args];
631
- const fullString = interpolate_default(strings, ...interpolations);
632
- return reduceLines2(fullString.split("\n"), options);
633
- }
634
- var stripIndents_default = stripIndents;
635
- export {
636
- APIError_default as APIError,
637
- DataError_default as DataError,
638
- addDaysToDate_default as addDaysToDate,
639
- appendSemicolon_default as appendSemicolon,
640
- camelToKebab_default as camelToKebab,
641
- convertFileToBase64_default as convertFileToBase64,
642
- createFormData_default as createFormData,
643
- createTemplateStringsArray_default as createTemplateStringsArray,
644
- fillArray_default as fillArray,
645
- formatDateAndTime_default as formatDateAndTime,
646
- getRandomNumber_default as getRandomNumber,
647
- getRecordKeys_default as getRecordKeys,
648
- httpErrorCodeLookup,
649
- interpolate_default as interpolate,
650
- interpolateObjects_default as interpolateObjects,
651
- isLeapYear_default as isLeapYear,
652
- isMonthlyMultiple_default as isMonthlyMultiple,
653
- isOrdered_default as isOrdered,
654
- isSameDate_default as isSameDate,
655
- kebabToCamel_default as kebabToCamel,
656
- normaliseImportPath,
657
- normalizeImportPath_default as normalizeImportPath,
658
- omitProperties_default as omitProperties,
659
- paralleliseArrays_default as paralleliseArrays,
660
- Email_default as parseEmail,
661
- Env_default as parseEnv,
662
- parseIntStrict_default as parseIntStrict,
663
- UUID_default as parseUUID,
664
- parseZodSchema_default as parseZodSchema,
665
- randomiseArray_default as randomiseArray,
666
- range_default as range,
667
- removeDuplicates_default as removeDuplicates,
668
- removeIndents_default as removeIndents,
669
- stringListToArray_default as stringListToArray,
670
- stringToBoolean_default as stringToBoolean,
671
- stripIndents_default as stripIndents,
672
- truncate_default as truncate,
673
- wait_default as wait
674
- };
520
+ //#endregion
521
+ export { APIError_default as APIError, DataError_default as DataError, addDaysToDate_default as addDaysToDate, appendSemicolon_default as appendSemicolon, camelToKebab_default as camelToKebab, convertFileToBase64_default as convertFileToBase64, createFormData_default as createFormData, createTemplateStringsArray_default as createTemplateStringsArray, fillArray_default as fillArray, formatDateAndTime_default as formatDateAndTime, getRandomNumber_default as getRandomNumber, getRecordKeys_default as getRecordKeys, httpErrorCodeLookup, interpolate_default as interpolate, interpolateObjects_default as interpolateObjects, isLeapYear_default as isLeapYear, isMonthlyMultiple_default as isMonthlyMultiple, isOrdered_default as isOrdered, isSameDate_default as isSameDate, kebabToCamel_default as kebabToCamel, normaliseImportPath, normalizeImportPath_default as normalizeImportPath, omitProperties_default as omitProperties, paralleliseArrays_default as paralleliseArrays, Email_default as parseEmail, Env_default as parseEnv, parseIntStrict_default as parseIntStrict, UUID_default as parseUUID, parseZodSchema_default as parseZodSchema, randomiseArray_default as randomiseArray, range_default as range, removeDuplicates_default as removeDuplicates, removeIndents_default as removeIndents, stringListToArray_default as stringListToArray, stringToBoolean_default as stringToBoolean, truncate_default as truncate, wait_default as wait };