@alextheman/utility 1.12.0 → 1.13.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 +54 -21
- package/dist/index.d.cts +16 -9
- package/dist/index.d.ts +16 -9
- package/dist/index.js +54 -21
- package/package.json +5 -5
package/dist/index.cjs
CHANGED
|
@@ -3,6 +3,7 @@ var __defProp = Object.defineProperty;
|
|
|
3
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
6
7
|
var __export = (target, all) => {
|
|
7
8
|
for (var name in all)
|
|
8
9
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -16,19 +17,22 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
17
|
return to;
|
|
17
18
|
};
|
|
18
19
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
19
21
|
|
|
20
22
|
// src/index.ts
|
|
21
23
|
var index_exports = {};
|
|
22
24
|
__export(index_exports, {
|
|
25
|
+
APIError: () => APIError_default,
|
|
23
26
|
addDaysToDate: () => addDaysToDate_default,
|
|
24
27
|
appendSemicolon: () => appendSemicolon_default,
|
|
25
28
|
convertFileToBase64: () => convertFileToBase64_default,
|
|
26
29
|
formatDateAndTime: () => formatDateAndTime_default,
|
|
27
30
|
getRandomNumber: () => getRandomNumber_default,
|
|
31
|
+
httpErrorCodeLookup: () => httpErrorCodeLookup,
|
|
28
32
|
isLeapYear: () => isLeapYear_default,
|
|
29
33
|
isMonthlyMultiple: () => isMonthlyMultiple_default,
|
|
30
34
|
isSameDate: () => isSameDate_default,
|
|
31
|
-
newEnv: () =>
|
|
35
|
+
newEnv: () => Env_default,
|
|
32
36
|
randomiseArray: () => randomiseArray_default,
|
|
33
37
|
range: () => range_default,
|
|
34
38
|
truncate: () => truncate_default,
|
|
@@ -36,7 +40,7 @@ __export(index_exports, {
|
|
|
36
40
|
});
|
|
37
41
|
module.exports = __toCommonJS(index_exports);
|
|
38
42
|
|
|
39
|
-
// src/addDaysToDate.ts
|
|
43
|
+
// src/functions/addDaysToDate.ts
|
|
40
44
|
function addDaysToDate(currentDate = /* @__PURE__ */ new Date(), dayIncrement = 1) {
|
|
41
45
|
const newDate = currentDate;
|
|
42
46
|
newDate.setDate(newDate.getDate() + dayIncrement);
|
|
@@ -44,7 +48,7 @@ function addDaysToDate(currentDate = /* @__PURE__ */ new Date(), dayIncrement =
|
|
|
44
48
|
}
|
|
45
49
|
var addDaysToDate_default = addDaysToDate;
|
|
46
50
|
|
|
47
|
-
// src/appendSemicolon.ts
|
|
51
|
+
// src/functions/appendSemicolon.ts
|
|
48
52
|
function appendSemicolon(stringToAppendTo) {
|
|
49
53
|
if (stringToAppendTo.includes("\n")) {
|
|
50
54
|
throw new Error("MULTIPLE_LINE_ERROR");
|
|
@@ -57,7 +61,7 @@ function appendSemicolon(stringToAppendTo) {
|
|
|
57
61
|
}
|
|
58
62
|
var appendSemicolon_default = appendSemicolon;
|
|
59
63
|
|
|
60
|
-
// src/convertFileToBase64.ts
|
|
64
|
+
// src/functions/convertFileToBase64.ts
|
|
61
65
|
function convertFileToBase64(file) {
|
|
62
66
|
return new Promise((resolve, reject) => {
|
|
63
67
|
const reader = new FileReader();
|
|
@@ -76,13 +80,13 @@ function convertFileToBase64(file) {
|
|
|
76
80
|
}
|
|
77
81
|
var convertFileToBase64_default = convertFileToBase64;
|
|
78
82
|
|
|
79
|
-
// src/isSameDate.ts
|
|
83
|
+
// src/functions/isSameDate.ts
|
|
80
84
|
function isSameDate(firstDate, secondDate) {
|
|
81
85
|
return firstDate.getDate() === secondDate.getDate() && firstDate.getMonth() === secondDate.getMonth() && firstDate.getFullYear() === secondDate.getFullYear();
|
|
82
86
|
}
|
|
83
87
|
var isSameDate_default = isSameDate;
|
|
84
88
|
|
|
85
|
-
// src/formatDateAndTime.ts
|
|
89
|
+
// src/functions/formatDateAndTime.ts
|
|
86
90
|
function formatDateAndTime(inputDate) {
|
|
87
91
|
const yesterday = addDaysToDate_default(/* @__PURE__ */ new Date(), -1);
|
|
88
92
|
const today = /* @__PURE__ */ new Date();
|
|
@@ -100,7 +104,7 @@ function formatDateAndTime(inputDate) {
|
|
|
100
104
|
}
|
|
101
105
|
var formatDateAndTime_default = formatDateAndTime;
|
|
102
106
|
|
|
103
|
-
// src/getRandomNumber.ts
|
|
107
|
+
// src/functions/getRandomNumber.ts
|
|
104
108
|
function getRandomNumber(lowerBound, upperBound) {
|
|
105
109
|
if (lowerBound % 1 !== 0 || upperBound % 1 !== 0) {
|
|
106
110
|
throw new Error("NON_INTEGER_INPUTS");
|
|
@@ -109,7 +113,7 @@ function getRandomNumber(lowerBound, upperBound) {
|
|
|
109
113
|
}
|
|
110
114
|
var getRandomNumber_default = getRandomNumber;
|
|
111
115
|
|
|
112
|
-
// src/isLeapYear.ts
|
|
116
|
+
// src/functions/isLeapYear.ts
|
|
113
117
|
function isLeapYear(year) {
|
|
114
118
|
if (year % 1 !== 0) {
|
|
115
119
|
throw new Error("NON_INTEGER_INPUT");
|
|
@@ -118,7 +122,7 @@ function isLeapYear(year) {
|
|
|
118
122
|
}
|
|
119
123
|
var isLeapYear_default = isLeapYear;
|
|
120
124
|
|
|
121
|
-
// src/isMonthlyMultiple.ts
|
|
125
|
+
// src/functions/isMonthlyMultiple.ts
|
|
122
126
|
function endOfMonthChecksButNotFebruary(firstDate, secondDate) {
|
|
123
127
|
if ([3, 5, 8, 10].includes(firstDate.getMonth())) {
|
|
124
128
|
return firstDate.getDate() === 30 && secondDate.getDate() === 31;
|
|
@@ -155,15 +159,7 @@ function isMonthlyMultiple(firstDate, secondDate) {
|
|
|
155
159
|
}
|
|
156
160
|
var isMonthlyMultiple_default = isMonthlyMultiple;
|
|
157
161
|
|
|
158
|
-
// src/
|
|
159
|
-
var import_zod = require("zod");
|
|
160
|
-
var envSchema = import_zod.z.enum(["test", "development", "production"]);
|
|
161
|
-
function newEnv(data) {
|
|
162
|
-
return envSchema.parse(data);
|
|
163
|
-
}
|
|
164
|
-
var newEnv_default = newEnv;
|
|
165
|
-
|
|
166
|
-
// src/randomiseArray.ts
|
|
162
|
+
// src/functions/randomiseArray.ts
|
|
167
163
|
function randomiseArray(array) {
|
|
168
164
|
const mutableArray = [...array];
|
|
169
165
|
const outputArray = [];
|
|
@@ -175,7 +171,7 @@ function randomiseArray(array) {
|
|
|
175
171
|
}
|
|
176
172
|
var randomiseArray_default = randomiseArray;
|
|
177
173
|
|
|
178
|
-
// src/range.ts
|
|
174
|
+
// src/functions/range.ts
|
|
179
175
|
function range(start, stop, step = 1) {
|
|
180
176
|
const numbers = [];
|
|
181
177
|
if (step === 0) {
|
|
@@ -199,13 +195,13 @@ function range(start, stop, step = 1) {
|
|
|
199
195
|
}
|
|
200
196
|
var range_default = range;
|
|
201
197
|
|
|
202
|
-
// src/truncate.ts
|
|
198
|
+
// src/functions/truncate.ts
|
|
203
199
|
function truncate(stringToTruncate, maxLength = 5) {
|
|
204
200
|
return stringToTruncate.length > maxLength ? `${stringToTruncate.slice(0, maxLength)}...` : stringToTruncate;
|
|
205
201
|
}
|
|
206
202
|
var truncate_default = truncate;
|
|
207
203
|
|
|
208
|
-
// src/wait.ts
|
|
204
|
+
// src/functions/wait.ts
|
|
209
205
|
function wait(seconds) {
|
|
210
206
|
return new Promise((resolve, _) => {
|
|
211
207
|
setTimeout(() => {
|
|
@@ -214,13 +210,50 @@ function wait(seconds) {
|
|
|
214
210
|
});
|
|
215
211
|
}
|
|
216
212
|
var wait_default = wait;
|
|
213
|
+
|
|
214
|
+
// src/types/Env.ts
|
|
215
|
+
var import_zod = require("zod");
|
|
216
|
+
var envSchema = import_zod.z.enum(["test", "development", "production"]);
|
|
217
|
+
function newEnv(data = "development") {
|
|
218
|
+
return envSchema.parse(data);
|
|
219
|
+
}
|
|
220
|
+
var Env_default = newEnv;
|
|
221
|
+
|
|
222
|
+
// src/types/APIError.ts
|
|
223
|
+
var httpErrorCodeLookup = {
|
|
224
|
+
400: "BAD_REQUEST",
|
|
225
|
+
401: "UNAUTHORISED",
|
|
226
|
+
403: "FORBIDDEN",
|
|
227
|
+
404: "NOT_FOUND",
|
|
228
|
+
/* Supporting this one too because it's funny. You'll never use it in practice because
|
|
229
|
+
why would an error give a teapot, but it's funny. Do not question me. */
|
|
230
|
+
418: "I_AM_A_TEAPOT",
|
|
231
|
+
500: "INTERNAL_SERVER_ERROR"
|
|
232
|
+
};
|
|
233
|
+
var APIError = class extends Error {
|
|
234
|
+
constructor(status = 500, message, options) {
|
|
235
|
+
var _a;
|
|
236
|
+
super(message, options);
|
|
237
|
+
__publicField(this, "status");
|
|
238
|
+
this.status = status;
|
|
239
|
+
if (message) {
|
|
240
|
+
this.message = message;
|
|
241
|
+
} else {
|
|
242
|
+
this.message = (_a = httpErrorCodeLookup[this.status]) != null ? _a : "API_ERROR";
|
|
243
|
+
}
|
|
244
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
245
|
+
}
|
|
246
|
+
};
|
|
247
|
+
var APIError_default = APIError;
|
|
217
248
|
// Annotate the CommonJS export names for ESM import in node:
|
|
218
249
|
0 && (module.exports = {
|
|
250
|
+
APIError,
|
|
219
251
|
addDaysToDate,
|
|
220
252
|
appendSemicolon,
|
|
221
253
|
convertFileToBase64,
|
|
222
254
|
formatDateAndTime,
|
|
223
255
|
getRandomNumber,
|
|
256
|
+
httpErrorCodeLookup,
|
|
224
257
|
isLeapYear,
|
|
225
258
|
isMonthlyMultiple,
|
|
226
259
|
isSameDate,
|
package/dist/index.d.cts
CHANGED
|
@@ -16,14 +16,6 @@ declare function isMonthlyMultiple(firstDate: Date, secondDate: Date): boolean;
|
|
|
16
16
|
|
|
17
17
|
declare function isSameDate(firstDate: Date, secondDate: Date): boolean;
|
|
18
18
|
|
|
19
|
-
declare const envSchema: z.ZodEnum<{
|
|
20
|
-
test: "test";
|
|
21
|
-
development: "development";
|
|
22
|
-
production: "production";
|
|
23
|
-
}>;
|
|
24
|
-
type Env = z.infer<typeof envSchema>;
|
|
25
|
-
declare function newEnv(data: unknown): Env;
|
|
26
|
-
|
|
27
19
|
declare function randomiseArray(array: unknown[]): unknown[];
|
|
28
20
|
|
|
29
21
|
declare function range(start: number, stop: number, step?: number): number[];
|
|
@@ -32,4 +24,19 @@ declare function truncate(stringToTruncate: string, maxLength?: number): string;
|
|
|
32
24
|
|
|
33
25
|
declare function wait(seconds: number): Promise<void>;
|
|
34
26
|
|
|
35
|
-
|
|
27
|
+
declare const envSchema: z.ZodEnum<{
|
|
28
|
+
test: "test";
|
|
29
|
+
development: "development";
|
|
30
|
+
production: "production";
|
|
31
|
+
}>;
|
|
32
|
+
type Env = z.infer<typeof envSchema>;
|
|
33
|
+
declare function newEnv(data?: unknown): Env;
|
|
34
|
+
|
|
35
|
+
type HTTPErrorCodes = 400 | 401 | 403 | 404 | 418 | 500;
|
|
36
|
+
declare const httpErrorCodeLookup: Record<HTTPErrorCodes, string>;
|
|
37
|
+
declare class APIError extends Error {
|
|
38
|
+
status: number;
|
|
39
|
+
constructor(status?: number, message?: string, options?: ErrorOptions);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export { APIError, type Env, type HTTPErrorCodes, addDaysToDate, appendSemicolon, convertFileToBase64, formatDateAndTime, getRandomNumber, httpErrorCodeLookup, isLeapYear, isMonthlyMultiple, isSameDate, newEnv, randomiseArray, range, truncate, wait };
|
package/dist/index.d.ts
CHANGED
|
@@ -16,14 +16,6 @@ declare function isMonthlyMultiple(firstDate: Date, secondDate: Date): boolean;
|
|
|
16
16
|
|
|
17
17
|
declare function isSameDate(firstDate: Date, secondDate: Date): boolean;
|
|
18
18
|
|
|
19
|
-
declare const envSchema: z.ZodEnum<{
|
|
20
|
-
test: "test";
|
|
21
|
-
development: "development";
|
|
22
|
-
production: "production";
|
|
23
|
-
}>;
|
|
24
|
-
type Env = z.infer<typeof envSchema>;
|
|
25
|
-
declare function newEnv(data: unknown): Env;
|
|
26
|
-
|
|
27
19
|
declare function randomiseArray(array: unknown[]): unknown[];
|
|
28
20
|
|
|
29
21
|
declare function range(start: number, stop: number, step?: number): number[];
|
|
@@ -32,4 +24,19 @@ declare function truncate(stringToTruncate: string, maxLength?: number): string;
|
|
|
32
24
|
|
|
33
25
|
declare function wait(seconds: number): Promise<void>;
|
|
34
26
|
|
|
35
|
-
|
|
27
|
+
declare const envSchema: z.ZodEnum<{
|
|
28
|
+
test: "test";
|
|
29
|
+
development: "development";
|
|
30
|
+
production: "production";
|
|
31
|
+
}>;
|
|
32
|
+
type Env = z.infer<typeof envSchema>;
|
|
33
|
+
declare function newEnv(data?: unknown): Env;
|
|
34
|
+
|
|
35
|
+
type HTTPErrorCodes = 400 | 401 | 403 | 404 | 418 | 500;
|
|
36
|
+
declare const httpErrorCodeLookup: Record<HTTPErrorCodes, string>;
|
|
37
|
+
declare class APIError extends Error {
|
|
38
|
+
status: number;
|
|
39
|
+
constructor(status?: number, message?: string, options?: ErrorOptions);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export { APIError, type Env, type HTTPErrorCodes, addDaysToDate, appendSemicolon, convertFileToBase64, formatDateAndTime, getRandomNumber, httpErrorCodeLookup, isLeapYear, isMonthlyMultiple, isSameDate, newEnv, randomiseArray, range, truncate, wait };
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
4
|
+
|
|
5
|
+
// src/functions/addDaysToDate.ts
|
|
2
6
|
function addDaysToDate(currentDate = /* @__PURE__ */ new Date(), dayIncrement = 1) {
|
|
3
7
|
const newDate = currentDate;
|
|
4
8
|
newDate.setDate(newDate.getDate() + dayIncrement);
|
|
@@ -6,7 +10,7 @@ function addDaysToDate(currentDate = /* @__PURE__ */ new Date(), dayIncrement =
|
|
|
6
10
|
}
|
|
7
11
|
var addDaysToDate_default = addDaysToDate;
|
|
8
12
|
|
|
9
|
-
// src/appendSemicolon.ts
|
|
13
|
+
// src/functions/appendSemicolon.ts
|
|
10
14
|
function appendSemicolon(stringToAppendTo) {
|
|
11
15
|
if (stringToAppendTo.includes("\n")) {
|
|
12
16
|
throw new Error("MULTIPLE_LINE_ERROR");
|
|
@@ -19,7 +23,7 @@ function appendSemicolon(stringToAppendTo) {
|
|
|
19
23
|
}
|
|
20
24
|
var appendSemicolon_default = appendSemicolon;
|
|
21
25
|
|
|
22
|
-
// src/convertFileToBase64.ts
|
|
26
|
+
// src/functions/convertFileToBase64.ts
|
|
23
27
|
function convertFileToBase64(file) {
|
|
24
28
|
return new Promise((resolve, reject) => {
|
|
25
29
|
const reader = new FileReader();
|
|
@@ -38,13 +42,13 @@ function convertFileToBase64(file) {
|
|
|
38
42
|
}
|
|
39
43
|
var convertFileToBase64_default = convertFileToBase64;
|
|
40
44
|
|
|
41
|
-
// src/isSameDate.ts
|
|
45
|
+
// src/functions/isSameDate.ts
|
|
42
46
|
function isSameDate(firstDate, secondDate) {
|
|
43
47
|
return firstDate.getDate() === secondDate.getDate() && firstDate.getMonth() === secondDate.getMonth() && firstDate.getFullYear() === secondDate.getFullYear();
|
|
44
48
|
}
|
|
45
49
|
var isSameDate_default = isSameDate;
|
|
46
50
|
|
|
47
|
-
// src/formatDateAndTime.ts
|
|
51
|
+
// src/functions/formatDateAndTime.ts
|
|
48
52
|
function formatDateAndTime(inputDate) {
|
|
49
53
|
const yesterday = addDaysToDate_default(/* @__PURE__ */ new Date(), -1);
|
|
50
54
|
const today = /* @__PURE__ */ new Date();
|
|
@@ -62,7 +66,7 @@ function formatDateAndTime(inputDate) {
|
|
|
62
66
|
}
|
|
63
67
|
var formatDateAndTime_default = formatDateAndTime;
|
|
64
68
|
|
|
65
|
-
// src/getRandomNumber.ts
|
|
69
|
+
// src/functions/getRandomNumber.ts
|
|
66
70
|
function getRandomNumber(lowerBound, upperBound) {
|
|
67
71
|
if (lowerBound % 1 !== 0 || upperBound % 1 !== 0) {
|
|
68
72
|
throw new Error("NON_INTEGER_INPUTS");
|
|
@@ -71,7 +75,7 @@ function getRandomNumber(lowerBound, upperBound) {
|
|
|
71
75
|
}
|
|
72
76
|
var getRandomNumber_default = getRandomNumber;
|
|
73
77
|
|
|
74
|
-
// src/isLeapYear.ts
|
|
78
|
+
// src/functions/isLeapYear.ts
|
|
75
79
|
function isLeapYear(year) {
|
|
76
80
|
if (year % 1 !== 0) {
|
|
77
81
|
throw new Error("NON_INTEGER_INPUT");
|
|
@@ -80,7 +84,7 @@ function isLeapYear(year) {
|
|
|
80
84
|
}
|
|
81
85
|
var isLeapYear_default = isLeapYear;
|
|
82
86
|
|
|
83
|
-
// src/isMonthlyMultiple.ts
|
|
87
|
+
// src/functions/isMonthlyMultiple.ts
|
|
84
88
|
function endOfMonthChecksButNotFebruary(firstDate, secondDate) {
|
|
85
89
|
if ([3, 5, 8, 10].includes(firstDate.getMonth())) {
|
|
86
90
|
return firstDate.getDate() === 30 && secondDate.getDate() === 31;
|
|
@@ -117,15 +121,7 @@ function isMonthlyMultiple(firstDate, secondDate) {
|
|
|
117
121
|
}
|
|
118
122
|
var isMonthlyMultiple_default = isMonthlyMultiple;
|
|
119
123
|
|
|
120
|
-
// src/
|
|
121
|
-
import { z } from "zod";
|
|
122
|
-
var envSchema = z.enum(["test", "development", "production"]);
|
|
123
|
-
function newEnv(data) {
|
|
124
|
-
return envSchema.parse(data);
|
|
125
|
-
}
|
|
126
|
-
var newEnv_default = newEnv;
|
|
127
|
-
|
|
128
|
-
// src/randomiseArray.ts
|
|
124
|
+
// src/functions/randomiseArray.ts
|
|
129
125
|
function randomiseArray(array) {
|
|
130
126
|
const mutableArray = [...array];
|
|
131
127
|
const outputArray = [];
|
|
@@ -137,7 +133,7 @@ function randomiseArray(array) {
|
|
|
137
133
|
}
|
|
138
134
|
var randomiseArray_default = randomiseArray;
|
|
139
135
|
|
|
140
|
-
// src/range.ts
|
|
136
|
+
// src/functions/range.ts
|
|
141
137
|
function range(start, stop, step = 1) {
|
|
142
138
|
const numbers = [];
|
|
143
139
|
if (step === 0) {
|
|
@@ -161,13 +157,13 @@ function range(start, stop, step = 1) {
|
|
|
161
157
|
}
|
|
162
158
|
var range_default = range;
|
|
163
159
|
|
|
164
|
-
// src/truncate.ts
|
|
160
|
+
// src/functions/truncate.ts
|
|
165
161
|
function truncate(stringToTruncate, maxLength = 5) {
|
|
166
162
|
return stringToTruncate.length > maxLength ? `${stringToTruncate.slice(0, maxLength)}...` : stringToTruncate;
|
|
167
163
|
}
|
|
168
164
|
var truncate_default = truncate;
|
|
169
165
|
|
|
170
|
-
// src/wait.ts
|
|
166
|
+
// src/functions/wait.ts
|
|
171
167
|
function wait(seconds) {
|
|
172
168
|
return new Promise((resolve, _) => {
|
|
173
169
|
setTimeout(() => {
|
|
@@ -176,16 +172,53 @@ function wait(seconds) {
|
|
|
176
172
|
});
|
|
177
173
|
}
|
|
178
174
|
var wait_default = wait;
|
|
175
|
+
|
|
176
|
+
// src/types/Env.ts
|
|
177
|
+
import { z } from "zod";
|
|
178
|
+
var envSchema = z.enum(["test", "development", "production"]);
|
|
179
|
+
function newEnv(data = "development") {
|
|
180
|
+
return envSchema.parse(data);
|
|
181
|
+
}
|
|
182
|
+
var Env_default = newEnv;
|
|
183
|
+
|
|
184
|
+
// src/types/APIError.ts
|
|
185
|
+
var httpErrorCodeLookup = {
|
|
186
|
+
400: "BAD_REQUEST",
|
|
187
|
+
401: "UNAUTHORISED",
|
|
188
|
+
403: "FORBIDDEN",
|
|
189
|
+
404: "NOT_FOUND",
|
|
190
|
+
/* Supporting this one too because it's funny. You'll never use it in practice because
|
|
191
|
+
why would an error give a teapot, but it's funny. Do not question me. */
|
|
192
|
+
418: "I_AM_A_TEAPOT",
|
|
193
|
+
500: "INTERNAL_SERVER_ERROR"
|
|
194
|
+
};
|
|
195
|
+
var APIError = class extends Error {
|
|
196
|
+
constructor(status = 500, message, options) {
|
|
197
|
+
var _a;
|
|
198
|
+
super(message, options);
|
|
199
|
+
__publicField(this, "status");
|
|
200
|
+
this.status = status;
|
|
201
|
+
if (message) {
|
|
202
|
+
this.message = message;
|
|
203
|
+
} else {
|
|
204
|
+
this.message = (_a = httpErrorCodeLookup[this.status]) != null ? _a : "API_ERROR";
|
|
205
|
+
}
|
|
206
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
207
|
+
}
|
|
208
|
+
};
|
|
209
|
+
var APIError_default = APIError;
|
|
179
210
|
export {
|
|
211
|
+
APIError_default as APIError,
|
|
180
212
|
addDaysToDate_default as addDaysToDate,
|
|
181
213
|
appendSemicolon_default as appendSemicolon,
|
|
182
214
|
convertFileToBase64_default as convertFileToBase64,
|
|
183
215
|
formatDateAndTime_default as formatDateAndTime,
|
|
184
216
|
getRandomNumber_default as getRandomNumber,
|
|
217
|
+
httpErrorCodeLookup,
|
|
185
218
|
isLeapYear_default as isLeapYear,
|
|
186
219
|
isMonthlyMultiple_default as isMonthlyMultiple,
|
|
187
220
|
isSameDate_default as isSameDate,
|
|
188
|
-
|
|
221
|
+
Env_default as newEnv,
|
|
189
222
|
randomiseArray_default as randomiseArray,
|
|
190
223
|
range_default as range,
|
|
191
224
|
truncate_default as truncate,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alextheman/utility",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.13.0",
|
|
4
4
|
"main": "dist/index.cjs",
|
|
5
5
|
"module": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -25,10 +25,10 @@
|
|
|
25
25
|
"license": "ISC",
|
|
26
26
|
"description": "",
|
|
27
27
|
"devDependencies": {
|
|
28
|
-
"@alextheman/eslint-plugin": "^1.6.
|
|
29
|
-
"@eslint/js": "^9.
|
|
28
|
+
"@alextheman/eslint-plugin": "^1.6.8",
|
|
29
|
+
"@eslint/js": "^9.34.0",
|
|
30
30
|
"@types/node": "^24.3.0",
|
|
31
|
-
"eslint": "^9.
|
|
31
|
+
"eslint": "^9.34.0",
|
|
32
32
|
"eslint-import-resolver-typescript": "^4.4.4",
|
|
33
33
|
"eslint-plugin-import": "^2.32.0",
|
|
34
34
|
"globals": "^16.3.0",
|
|
@@ -42,6 +42,6 @@
|
|
|
42
42
|
"vitest": "^3.2.4"
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"zod": "^4.0
|
|
45
|
+
"zod": "^4.1.0"
|
|
46
46
|
}
|
|
47
47
|
}
|