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