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