@nr1e/commons 0.0.3-alpha.2 → 0.0.3-alpha.21
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/bitsnbytes/b64.d.ts +1 -0
- package/bitsnbytes/b64.d.ts.map +1 -0
- package/bitsnbytes/b64.js +17 -25
- package/bitsnbytes/b64.js.map +1 -1
- package/bitsnbytes/index.d.ts +1 -0
- package/bitsnbytes/index.d.ts.map +1 -0
- package/bitsnbytes/index.js +1 -17
- package/bitsnbytes/index.js.map +1 -1
- package/errors/errors.d.ts +52 -30
- package/errors/errors.d.ts.map +1 -0
- package/errors/errors.js +104 -101
- package/errors/errors.js.map +1 -1
- package/errors/index.d.ts +1 -0
- package/errors/index.d.ts.map +1 -0
- package/errors/index.js +1 -17
- package/errors/index.js.map +1 -1
- package/http/http-method.d.ts +1 -0
- package/http/http-method.d.ts.map +1 -0
- package/http/http-method.js +2 -5
- package/http/http-method.js.map +1 -1
- package/http/http-status-code.d.ts +1 -0
- package/http/http-status-code.d.ts.map +1 -0
- package/http/http-status-code.js +2 -5
- package/http/http-status-code.js.map +1 -1
- package/http/index.d.ts +1 -0
- package/http/index.d.ts.map +1 -0
- package/http/index.js +2 -18
- package/http/index.js.map +1 -1
- package/lang/index.d.ts +2 -0
- package/lang/index.d.ts.map +1 -0
- package/lang/index.js +2 -17
- package/lang/index.js.map +1 -1
- package/lang/sleep.d.ts +7 -0
- package/lang/sleep.d.ts.map +1 -0
- package/lang/sleep.js +9 -0
- package/lang/sleep.js.map +1 -0
- package/lang/type-functions.d.ts +1 -0
- package/lang/type-functions.d.ts.map +1 -0
- package/lang/type-functions.js +3 -9
- package/lang/type-functions.js.map +1 -1
- package/package.json +37 -19
- package/validator/index.d.ts +1 -0
- package/validator/index.d.ts.map +1 -0
- package/validator/index.js +1 -17
- package/validator/index.js.map +1 -1
- package/validator/validators.d.ts +1 -0
- package/validator/validators.d.ts.map +1 -0
- package/validator/validators.js +37 -64
- package/validator/validators.js.map +1 -1
- package/.prettierrc.js +0 -3
- package/LICENSE +0 -26
- package/README.md +0 -14
- package/index.d.ts +0 -5
- package/index.js +0 -9
- package/index.js.map +0 -1
- package/jest.config.js +0 -8
package/errors/errors.js
CHANGED
|
@@ -1,232 +1,235 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const http_1 = require("../http");
|
|
5
|
-
const lang_1 = require("../lang");
|
|
1
|
+
import { HttpStatusCode } from '../http';
|
|
2
|
+
import { isError, isObject } from '../lang';
|
|
3
|
+
export { isError } from '../lang';
|
|
6
4
|
/**
|
|
7
5
|
* Checks if the given parameter is an HttpError.
|
|
8
6
|
*
|
|
9
|
-
* @param e
|
|
7
|
+
* @param e The parameter to check
|
|
10
8
|
*/
|
|
11
|
-
function isHttpError(e) {
|
|
12
|
-
return
|
|
9
|
+
export function isHttpError(e) {
|
|
10
|
+
return isObject(e) && !!(e && e.stack && e.statusCode && e.message && e.name);
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Thrown when a resource cannot be found.
|
|
14
|
+
*/
|
|
15
|
+
export class NotFoundError extends Error {
|
|
16
|
+
statusCode = HttpStatusCode.NOT_FOUND;
|
|
17
|
+
/**
|
|
18
|
+
* The max-age value to set in the Cache-Control header if used in a middleware.
|
|
19
|
+
*/
|
|
20
|
+
maxAge;
|
|
21
|
+
constructor(message, maxAge) {
|
|
22
|
+
message = message ?? 'Not found';
|
|
23
|
+
super(message);
|
|
24
|
+
this.name = 'NotFoundError';
|
|
25
|
+
this.maxAge = maxAge;
|
|
26
|
+
}
|
|
13
27
|
}
|
|
14
|
-
exports.isHttpError = isHttpError;
|
|
15
28
|
/**
|
|
16
29
|
* Checks if the given parameter is a NotFoundError.
|
|
17
30
|
*
|
|
18
|
-
* @param e
|
|
31
|
+
* @param e The parameter to check
|
|
19
32
|
*/
|
|
20
|
-
function isNotFoundError(e) {
|
|
33
|
+
export function isNotFoundError(e) {
|
|
21
34
|
return isHttpError(e) && e.name === 'NotFoundError';
|
|
22
35
|
}
|
|
23
|
-
exports.isNotFoundError = isNotFoundError;
|
|
24
36
|
/**
|
|
25
|
-
* Thrown when a
|
|
37
|
+
* Thrown when a request is missing authentication credentials.
|
|
26
38
|
*/
|
|
27
|
-
class
|
|
39
|
+
export class UnauthorizedError extends Error {
|
|
40
|
+
statusCode = HttpStatusCode.UNAUTHORIZED;
|
|
28
41
|
constructor(message) {
|
|
29
|
-
message = message
|
|
42
|
+
message = message ?? 'Unauthorized';
|
|
30
43
|
super(message);
|
|
31
|
-
this.
|
|
32
|
-
this.name = 'NotFoundError';
|
|
44
|
+
this.name = 'UnauthorizedError';
|
|
33
45
|
}
|
|
34
46
|
}
|
|
35
|
-
exports.NotFoundError = NotFoundError;
|
|
36
47
|
/**
|
|
37
|
-
* Checks if the given parameter is a
|
|
48
|
+
* Checks if the given parameter is a UnauthorizedError.
|
|
38
49
|
*
|
|
39
|
-
* @param e
|
|
50
|
+
* @param e The parameter to check
|
|
40
51
|
*/
|
|
41
|
-
function
|
|
42
|
-
return isHttpError(e) && e.name === '
|
|
52
|
+
export function isUnauthorizedError(e) {
|
|
53
|
+
return isHttpError(e) && e.name === 'UnauthorizedError';
|
|
43
54
|
}
|
|
44
|
-
exports.isForbiddenError = isForbiddenError;
|
|
45
55
|
/**
|
|
46
|
-
* Thrown when
|
|
56
|
+
* Thrown when credentials are present, but the requested operations is not allowed.
|
|
47
57
|
*/
|
|
48
|
-
class ForbiddenError extends Error {
|
|
58
|
+
export class ForbiddenError extends Error {
|
|
59
|
+
statusCode = HttpStatusCode.FORBIDDEN;
|
|
49
60
|
constructor(message) {
|
|
50
|
-
message = message
|
|
61
|
+
message = message ?? 'Forbidden';
|
|
51
62
|
super(message);
|
|
52
|
-
this.statusCode = http_1.HttpStatusCode.FORBIDDEN;
|
|
53
63
|
this.name = 'ForbiddenError';
|
|
54
64
|
}
|
|
55
65
|
}
|
|
56
|
-
exports.ForbiddenError = ForbiddenError;
|
|
57
66
|
/**
|
|
58
|
-
* Checks if the given
|
|
67
|
+
* Checks if the given parameter is a ForbiddenError.
|
|
59
68
|
*
|
|
60
|
-
* @param e
|
|
69
|
+
* @param e The parameter to check
|
|
61
70
|
*/
|
|
62
|
-
function
|
|
63
|
-
return isHttpError(e) && e.name === '
|
|
71
|
+
export function isForbiddenError(e) {
|
|
72
|
+
return isHttpError(e) && e.name === 'ForbiddenError';
|
|
64
73
|
}
|
|
65
|
-
exports.isValidationError = isValidationError;
|
|
66
74
|
/**
|
|
67
75
|
* Thrown when a validation error occurs.
|
|
68
76
|
*/
|
|
69
|
-
class ValidationError extends Error {
|
|
77
|
+
export class ValidationError extends Error {
|
|
78
|
+
statusCode = HttpStatusCode.BAD_REQUEST;
|
|
70
79
|
constructor(message) {
|
|
71
|
-
message = message
|
|
80
|
+
message = message ?? 'Validation error';
|
|
72
81
|
super(message);
|
|
73
|
-
this.statusCode = http_1.HttpStatusCode.BAD_REQUEST;
|
|
74
82
|
this.name = 'ValidationError';
|
|
75
83
|
}
|
|
76
84
|
}
|
|
77
|
-
exports.ValidationError = ValidationError;
|
|
78
85
|
/**
|
|
79
|
-
* Checks if the given
|
|
86
|
+
* Checks if the given variable is a ValidationError.
|
|
80
87
|
*
|
|
81
|
-
* @param e
|
|
88
|
+
* @param e The variable to check
|
|
82
89
|
*/
|
|
83
|
-
function
|
|
84
|
-
return isHttpError(e) && e.name === '
|
|
90
|
+
export function isValidationError(e) {
|
|
91
|
+
return isHttpError(e) && e.name === 'ValidationError';
|
|
85
92
|
}
|
|
86
|
-
exports.isBadRequestError = isBadRequestError;
|
|
87
93
|
/**
|
|
88
94
|
* Thrown when a bad request is made.
|
|
89
95
|
*/
|
|
90
|
-
class BadRequestError extends Error {
|
|
96
|
+
export class BadRequestError extends Error {
|
|
97
|
+
statusCode = HttpStatusCode.BAD_REQUEST;
|
|
91
98
|
constructor(message) {
|
|
92
|
-
message = message
|
|
93
|
-
super(message
|
|
94
|
-
this.statusCode = http_1.HttpStatusCode.BAD_REQUEST;
|
|
99
|
+
message = message ?? 'Bad request';
|
|
100
|
+
super(message ?? 'Bad request');
|
|
95
101
|
this.name = 'BadRequestError';
|
|
96
102
|
}
|
|
97
103
|
}
|
|
98
|
-
exports.BadRequestError = BadRequestError;
|
|
99
104
|
/**
|
|
100
|
-
* Checks if the given parameter is a
|
|
105
|
+
* Checks if the given parameter is a BadRequestError.
|
|
101
106
|
*
|
|
102
|
-
* @param e
|
|
107
|
+
* @param e The parameter to check
|
|
103
108
|
*/
|
|
104
|
-
function
|
|
105
|
-
return isHttpError(e) && e.name === '
|
|
109
|
+
export function isBadRequestError(e) {
|
|
110
|
+
return isHttpError(e) && e.name === 'BadRequestError';
|
|
106
111
|
}
|
|
107
|
-
exports.isInternalServerError = isInternalServerError;
|
|
108
112
|
/**
|
|
109
113
|
* Throws when an internal server error occurs.
|
|
110
114
|
*/
|
|
111
|
-
class InternalServerError extends Error {
|
|
115
|
+
export class InternalServerError extends Error {
|
|
116
|
+
statusCode = HttpStatusCode.INTERNAL_SERVER_ERROR;
|
|
112
117
|
constructor(message) {
|
|
113
|
-
message = message
|
|
118
|
+
message = message ?? 'Internal server error';
|
|
114
119
|
super(message);
|
|
115
|
-
this.statusCode = http_1.HttpStatusCode.INTERNAL_SERVER_ERROR;
|
|
116
120
|
this.name = 'InternalServerError';
|
|
117
121
|
}
|
|
118
122
|
}
|
|
119
|
-
exports.InternalServerError = InternalServerError;
|
|
120
123
|
/**
|
|
121
|
-
* Checks if the given parameter is a
|
|
124
|
+
* Checks if the given parameter is a InternalServerError.
|
|
122
125
|
*
|
|
123
|
-
* @param e
|
|
126
|
+
* @param e The parameter to check
|
|
124
127
|
*/
|
|
125
|
-
function
|
|
126
|
-
return isHttpError(e) && e.name === '
|
|
128
|
+
export function isInternalServerError(e) {
|
|
129
|
+
return isHttpError(e) && e.name === 'InternalServerError';
|
|
127
130
|
}
|
|
128
|
-
exports.isConflictError = isConflictError;
|
|
129
131
|
/**
|
|
130
132
|
* Thrown when a conflict occurs.
|
|
131
133
|
*/
|
|
132
|
-
class ConflictError extends Error {
|
|
134
|
+
export class ConflictError extends Error {
|
|
135
|
+
statusCode = HttpStatusCode.CONFLICT;
|
|
133
136
|
constructor(message) {
|
|
134
|
-
message = message
|
|
137
|
+
message = message ?? 'Conflict';
|
|
135
138
|
super(message);
|
|
136
|
-
this.statusCode = http_1.HttpStatusCode.CONFLICT;
|
|
137
139
|
this.name = 'ConflictError';
|
|
138
140
|
}
|
|
139
141
|
}
|
|
140
|
-
exports.ConflictError = ConflictError;
|
|
141
142
|
/**
|
|
142
|
-
* Checks if the given parameter is a
|
|
143
|
+
* Checks if the given parameter is a ConflictError.
|
|
143
144
|
*
|
|
144
|
-
* @param e
|
|
145
|
+
* @param e The parameter to check
|
|
145
146
|
*/
|
|
146
|
-
function
|
|
147
|
-
return isHttpError(e) && e.name === '
|
|
147
|
+
export function isConflictError(e) {
|
|
148
|
+
return isHttpError(e) && e.name === 'ConflictError';
|
|
148
149
|
}
|
|
149
|
-
exports.isUnsupportedMediaTypeError = isUnsupportedMediaTypeError;
|
|
150
150
|
/**
|
|
151
151
|
* Thrown when a unsupported media type is used.
|
|
152
152
|
*/
|
|
153
|
-
class UnsupportedMediaTypeError extends Error {
|
|
153
|
+
export class UnsupportedMediaTypeError extends Error {
|
|
154
|
+
statusCode = HttpStatusCode.UNSUPPORTED_MEDIA_TYPE;
|
|
154
155
|
constructor(message) {
|
|
155
|
-
message = message
|
|
156
|
+
message = message ?? 'Unsupported media type';
|
|
156
157
|
super(message);
|
|
157
|
-
this.statusCode = http_1.HttpStatusCode.UNSUPPORTED_MEDIA_TYPE;
|
|
158
158
|
this.name = 'UnsupportedMediaTypeError';
|
|
159
159
|
}
|
|
160
160
|
}
|
|
161
|
-
exports.UnsupportedMediaTypeError = UnsupportedMediaTypeError;
|
|
162
161
|
/**
|
|
163
|
-
* Checks if the given parameter is a
|
|
162
|
+
* Checks if the given parameter is a UnsupportedMediaTypeError.
|
|
164
163
|
*
|
|
165
|
-
* @param e
|
|
164
|
+
* @param e The parameter to check
|
|
166
165
|
*/
|
|
167
|
-
function
|
|
168
|
-
return isHttpError(e) && e.name === '
|
|
166
|
+
export function isUnsupportedMediaTypeError(e) {
|
|
167
|
+
return isHttpError(e) && e.name === 'UnsupportedMediaTypeError';
|
|
169
168
|
}
|
|
170
|
-
exports.isNotImplementedError = isNotImplementedError;
|
|
171
169
|
/**
|
|
172
170
|
* Thrown when a requested operation is not implemented.
|
|
173
171
|
*/
|
|
174
|
-
class NotImplementedError extends Error {
|
|
172
|
+
export class NotImplementedError extends Error {
|
|
173
|
+
statusCode = HttpStatusCode.NOT_IMPLEMENTED;
|
|
174
|
+
expose = true;
|
|
175
175
|
constructor(message) {
|
|
176
|
-
message = message
|
|
176
|
+
message = message ?? 'Not implemented';
|
|
177
177
|
super(message);
|
|
178
|
-
this.statusCode = http_1.HttpStatusCode.NOT_IMPLEMENTED;
|
|
179
|
-
this.expose = true;
|
|
180
178
|
this.name = 'NotImplementedError';
|
|
181
179
|
}
|
|
182
180
|
}
|
|
183
|
-
exports.NotImplementedError = NotImplementedError;
|
|
184
181
|
/**
|
|
185
|
-
* Checks if the given parameter is a
|
|
182
|
+
* Checks if the given parameter is a NotImplementedError.
|
|
186
183
|
*
|
|
187
|
-
* @param e
|
|
184
|
+
* @param e The parameter to check
|
|
188
185
|
*/
|
|
189
|
-
function
|
|
190
|
-
return (
|
|
186
|
+
export function isNotImplementedError(e) {
|
|
187
|
+
return isHttpError(e) && e.name === 'NotImplementedError';
|
|
191
188
|
}
|
|
192
|
-
exports.isIllegalArgumentError = isIllegalArgumentError;
|
|
193
189
|
/**
|
|
194
190
|
* Thrown when an illegal argument is passed to a function.
|
|
195
191
|
*/
|
|
196
|
-
class IllegalArgumentError extends Error {
|
|
192
|
+
export class IllegalArgumentError extends Error {
|
|
193
|
+
argName;
|
|
197
194
|
constructor(argName, message) {
|
|
198
|
-
message = message
|
|
195
|
+
message = message ?? `Illegal argument ${argName}`;
|
|
199
196
|
super(message);
|
|
200
197
|
this.argName = argName;
|
|
201
198
|
this.name = 'IllegalArgumentError';
|
|
202
199
|
}
|
|
203
200
|
}
|
|
204
|
-
|
|
201
|
+
/**
|
|
202
|
+
* Checks if the given parameter is a IllegalArgumentError.
|
|
203
|
+
*
|
|
204
|
+
* @param e The parameter to check
|
|
205
|
+
*/
|
|
206
|
+
export function isIllegalArgumentError(e) {
|
|
207
|
+
return isError(e) && e.name === 'IllegalArgumentError';
|
|
208
|
+
}
|
|
205
209
|
/**
|
|
206
210
|
* Converts the given parameter to an HttpError.
|
|
207
211
|
*
|
|
208
212
|
* @param code The HTTP status code
|
|
209
213
|
* @param message The error message
|
|
210
214
|
*/
|
|
211
|
-
function toError(code, message) {
|
|
215
|
+
export function toError(code, message) {
|
|
212
216
|
switch (code) {
|
|
213
|
-
case
|
|
217
|
+
case HttpStatusCode.NOT_FOUND:
|
|
214
218
|
return new NotFoundError(message);
|
|
215
|
-
case
|
|
219
|
+
case HttpStatusCode.FORBIDDEN:
|
|
216
220
|
return new ForbiddenError(message);
|
|
217
|
-
case
|
|
221
|
+
case HttpStatusCode.BAD_REQUEST:
|
|
218
222
|
return new BadRequestError(message);
|
|
219
|
-
case
|
|
223
|
+
case HttpStatusCode.INTERNAL_SERVER_ERROR:
|
|
220
224
|
return new InternalServerError(message);
|
|
221
|
-
case
|
|
225
|
+
case HttpStatusCode.CONFLICT:
|
|
222
226
|
return new ConflictError(message);
|
|
223
|
-
case
|
|
227
|
+
case HttpStatusCode.UNSUPPORTED_MEDIA_TYPE:
|
|
224
228
|
return new UnsupportedMediaTypeError(message);
|
|
225
|
-
case
|
|
229
|
+
case HttpStatusCode.NOT_IMPLEMENTED:
|
|
226
230
|
return new NotImplementedError(message);
|
|
227
231
|
default:
|
|
228
232
|
return new Error(message);
|
|
229
233
|
}
|
|
230
234
|
}
|
|
231
|
-
exports.toError = toError;
|
|
232
235
|
//# sourceMappingURL=errors.js.map
|
package/err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,UAAU,OAAO,CACrB,IAA6B,EAC7B,OAAgB;IAEhB,QAAQ,IAAI,EAAE;QACZ,KAAK,cAAc,CAAC,SAAS;YAC3B,OAAO,IAAI,aAAa,CAAC,OAAO,CAAC,CAAC;QACpC,KAAK,cAAc,CAAC,SAAS;YAC3B,OAAO,IAAI,cAAc,CAAC,OAAO,CAAC,CAAC;QACrC,KAAK,cAAc,CAAC,WAAW;YAC7B,OAAO,IAAI,eAAe,CAAC,OAAO,CAAC,CAAC;QACtC,KAAK,cAAc,CAAC,qBAAqB;YACvC,OAAO,IAAI,mBAAmB,CAAC,OAAO,CAAC,CAAC;QAC1C,KAAK,cAAc,CAAC,QAAQ;YAC1B,OAAO,IAAI,aAAa,CAAC,OAAO,CAAC,CAAC;QACpC,KAAK,cAAc,CAAC,sBAAsB;YACxC,OAAO,IAAI,yBAAyB,CAAC,OAAO,CAAC,CAAC;QAChD,KAAK,cAAc,CAAC,eAAe;YACjC,OAAO,IAAI,mBAAmB,CAAC,OAAO,CAAC,CAAC;QAC1C;YACE,OAAO,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC;KAC7B;AACH,CAAC","sourcesContent":["import {HttpStatusCode} from '../http';\nimport {isError, isObject} from '../lang';\nexport {isError} from '../lang';\n\n/**\n * An extended version of Error that includes an HttpStatusCode.\n * This can be useful in middleware error handlers to determine http status codes to return to the client.\n */\nexport interface HttpError extends Error {\n /**\n * The HTTP status code.\n */\n statusCode: HttpStatusCode | number;\n}\n\n/**\n * Checks if the given parameter is an HttpError.\n *\n * @param e The parameter to check\n */\nexport function isHttpError(e?: unknown): e is HttpError {\n return isObject(e) && !!(e && e.stack && e.statusCode && e.message && e.name);\n}\n\n/**\n * Thrown when a resource cannot be found.\n */\nexport class NotFoundError extends Error implements HttpError {\n readonly statusCode = HttpStatusCode.NOT_FOUND;\n /**\n * The max-age value to set in the Cache-Control header if used in a middleware.\n */\n readonly maxAge?: number;\n constructor(message?: string, maxAge?: number) {\n message = message ?? 'Not found';\n super(message);\n this.name = 'NotFoundError';\n this.maxAge = maxAge;\n }\n}\n\n/**\n * Checks if the given parameter is a NotFoundError.\n *\n * @param e The parameter to check\n */\nexport function isNotFoundError(e?: unknown): e is NotFoundError {\n return isHttpError(e) && e.name === 'NotFoundError';\n}\n\n/**\n * Thrown when a request is missing authentication credentials.\n */\nexport class UnauthorizedError extends Error implements HttpError {\n readonly statusCode = HttpStatusCode.UNAUTHORIZED;\n constructor(message?: string) {\n message = message ?? 'Unauthorized';\n super(message);\n this.name = 'UnauthorizedError';\n }\n}\n\n/**\n * Checks if the given parameter is a UnauthorizedError.\n *\n * @param e The parameter to check\n */\nexport function isUnauthorizedError(e?: unknown): e is UnauthorizedError {\n return isHttpError(e) && e.name === 'UnauthorizedError';\n}\n\n/**\n * Thrown when credentials are present, but the requested operations is not allowed.\n */\nexport class ForbiddenError extends Error implements HttpError {\n readonly statusCode = HttpStatusCode.FORBIDDEN;\n constructor(message?: string) {\n message = message ?? 'Forbidden';\n super(message);\n this.name = 'ForbiddenError';\n }\n}\n\n/**\n * Checks if the given parameter is a ForbiddenError.\n *\n * @param e The parameter to check\n */\nexport function isForbiddenError(e?: unknown): e is ForbiddenError {\n return isHttpError(e) && e.name === 'ForbiddenError';\n}\n\n/**\n * Thrown when a validation error occurs.\n */\nexport class ValidationError extends Error implements HttpError {\n readonly statusCode = HttpStatusCode.BAD_REQUEST;\n constructor(message?: string) {\n message = message ?? 'Validation error';\n super(message);\n this.name = 'ValidationError';\n }\n}\n\n/**\n * Checks if the given variable is a ValidationError.\n *\n * @param e The variable to check\n */\nexport function isValidationError(e?: unknown): e is ValidationError {\n return isHttpError(e) && e.name === 'ValidationError';\n}\n\n/**\n * Thrown when a bad request is made.\n */\nexport class BadRequestError extends Error implements HttpError {\n readonly statusCode = HttpStatusCode.BAD_REQUEST;\n constructor(message?: string) {\n message = message ?? 'Bad request';\n super(message ?? 'Bad request');\n this.name = 'BadRequestError';\n }\n}\n\n/**\n * Checks if the given parameter is a BadRequestError.\n *\n * @param e The parameter to check\n */\nexport function isBadRequestError(e?: unknown): e is BadRequestError {\n return isHttpError(e) && e.name === 'BadRequestError';\n}\n\n/**\n * Throws when an internal server error occurs.\n */\nexport class InternalServerError extends Error implements HttpError {\n readonly statusCode = HttpStatusCode.INTERNAL_SERVER_ERROR;\n constructor(message?: string) {\n message = message ?? 'Internal server error';\n super(message);\n this.name = 'InternalServerError';\n }\n}\n\n/**\n * Checks if the given parameter is a InternalServerError.\n *\n * @param e The parameter to check\n */\nexport function isInternalServerError(e?: unknown): e is InternalServerError {\n return isHttpError(e) && e.name === 'InternalServerError';\n}\n\n/**\n * Thrown when a conflict occurs.\n */\nexport class ConflictError extends Error implements HttpError {\n readonly statusCode = HttpStatusCode.CONFLICT;\n constructor(message?: string) {\n message = message ?? 'Conflict';\n super(message);\n this.name = 'ConflictError';\n }\n}\n\n/**\n * Checks if the given parameter is a ConflictError.\n *\n * @param e The parameter to check\n */\nexport function isConflictError(e?: unknown): e is ConflictError {\n return isHttpError(e) && e.name === 'ConflictError';\n}\n\n/**\n * Thrown when a unsupported media type is used.\n */\nexport class UnsupportedMediaTypeError extends Error implements HttpError {\n readonly statusCode = HttpStatusCode.UNSUPPORTED_MEDIA_TYPE;\n constructor(message?: string) {\n message = message ?? 'Unsupported media type';\n super(message);\n this.name = 'UnsupportedMediaTypeError';\n }\n}\n\n/**\n * Checks if the given parameter is a UnsupportedMediaTypeError.\n *\n * @param e The parameter to check\n */\nexport function isUnsupportedMediaTypeError(\n e?: unknown\n): e is UnsupportedMediaTypeError {\n return isHttpError(e) && e.name === 'UnsupportedMediaTypeError';\n}\n\n/**\n * Thrown when a requested operation is not implemented.\n */\nexport class NotImplementedError extends Error implements HttpError {\n readonly statusCode = HttpStatusCode.NOT_IMPLEMENTED;\n readonly expose = true;\n constructor(message?: string) {\n message = message ?? 'Not implemented';\n super(message);\n this.name = 'NotImplementedError';\n }\n}\n\n/**\n * Checks if the given parameter is a NotImplementedError.\n *\n * @param e The parameter to check\n */\nexport function isNotImplementedError(e?: unknown): e is NotImplementedError {\n return isHttpError(e) && e.name === 'NotImplementedError';\n}\n\n/**\n * Thrown when an illegal argument is passed to a function.\n */\nexport class IllegalArgumentError extends Error {\n readonly argName: string;\n constructor(argName: string, message?: string) {\n message = message ?? `Illegal argument ${argName}`;\n super(message);\n this.argName = argName;\n this.name = 'IllegalArgumentError';\n }\n}\n\n/**\n * Checks if the given parameter is a IllegalArgumentError.\n *\n * @param e The parameter to check\n */\nexport function isIllegalArgumentError(e?: unknown): e is IllegalArgumentError {\n return isError(e) && e.name === 'IllegalArgumentError';\n}\n\n/**\n * Converts the given parameter to an HttpError.\n *\n * @param code The HTTP status code\n * @param message The error message\n */\nexport function toError(\n code: number | HttpStatusCode,\n message?: string\n): Error {\n switch (code) {\n case HttpStatusCode.NOT_FOUND:\n return new NotFoundError(message);\n case HttpStatusCode.FORBIDDEN:\n return new ForbiddenError(message);\n case HttpStatusCode.BAD_REQUEST:\n return new BadRequestError(message);\n case HttpStatusCode.INTERNAL_SERVER_ERROR:\n return new InternalServerError(message);\n case HttpStatusCode.CONFLICT:\n return new ConflictError(message);\n case HttpStatusCode.UNSUPPORTED_MEDIA_TYPE:\n return new UnsupportedMediaTypeError(message);\n case HttpStatusCode.NOT_IMPLEMENTED:\n return new NotImplementedError(message);\n default:\n return new Error(message);\n }\n}\n"]}
|
package/errors/index.d.ts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/errors/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC"}
|
package/errors/index.js
CHANGED
|
@@ -1,18 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./errors"), exports);
|
|
1
|
+
export * from './errors';
|
|
18
2
|
//# sourceMappingURL=index.js.map
|
package/errors/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/errors/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC","sourcesContent":["export * from './errors';\n"]}
|
package/http/http-method.d.ts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http-method.d.ts","sourceRoot":"","sources":["../../src/http/http-method.ts"],"names":[],"mappings":"AAAA,oBAAY,UAAU;IACpB,GAAG,QAAQ;IACX,IAAI,SAAS;IACb,GAAG,QAAQ;IACX,KAAK,UAAU;IACf,MAAM,WAAW;IACjB,IAAI,SAAS;IACb,OAAO,YAAY;CACpB"}
|
package/http/http-method.js
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.HttpMethod = void 0;
|
|
4
|
-
var HttpMethod;
|
|
1
|
+
export var HttpMethod;
|
|
5
2
|
(function (HttpMethod) {
|
|
6
3
|
HttpMethod["GET"] = "GET";
|
|
7
4
|
HttpMethod["POST"] = "POST";
|
|
@@ -10,5 +7,5 @@ var HttpMethod;
|
|
|
10
7
|
HttpMethod["DELETE"] = "DELETE";
|
|
11
8
|
HttpMethod["HEAD"] = "HEAD";
|
|
12
9
|
HttpMethod["OPTIONS"] = "OPTIONS";
|
|
13
|
-
})(HttpMethod || (
|
|
10
|
+
})(HttpMethod || (HttpMethod = {}));
|
|
14
11
|
//# sourceMappingURL=http-method.js.map
|
package/http/http-method.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http-method.js","sourceRoot":"","sources":["http-method.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"http-method.js","sourceRoot":"","sources":["../../src/http/http-method.ts"],"names":[],"mappings":"AAAA,MAAM,CAAN,IAAY,UAQX;AARD,WAAY,UAAU;IACpB,yBAAW,CAAA;IACX,2BAAa,CAAA;IACb,yBAAW,CAAA;IACX,6BAAe,CAAA;IACf,+BAAiB,CAAA;IACjB,2BAAa,CAAA;IACb,iCAAmB,CAAA;AACrB,CAAC,EARW,UAAU,KAAV,UAAU,QAQrB","sourcesContent":["export enum HttpMethod {\n GET = 'GET',\n POST = 'POST',\n PUT = 'PUT',\n PATCH = 'PATCH',\n DELETE = 'DELETE',\n HEAD = 'HEAD',\n OPTIONS = 'OPTIONS',\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http-status-code.d.ts","sourceRoot":"","sources":["../../src/http/http-status-code.ts"],"names":[],"mappings":"AAAA,oBAAY,cAAc;IACxB,QAAQ,MAAM;IACd,mBAAmB,MAAM;IACzB,EAAE,MAAM;IACR,OAAO,MAAM;IACb,QAAQ,MAAM;IACd,6BAA6B,MAAM;IACnC,UAAU,MAAM;IAChB,aAAa,MAAM;IACnB,eAAe,MAAM;IACrB,gBAAgB,MAAM;IACtB,kBAAkB,MAAM;IACxB,KAAK,MAAM;IACX,SAAS,MAAM;IACf,YAAY,MAAM;IAClB,SAAS,MAAM;IACf,kBAAkB,MAAM;IACxB,WAAW,MAAM;IACjB,YAAY,MAAM;IAClB,gBAAgB,MAAM;IACtB,SAAS,MAAM;IACf,SAAS,MAAM;IACf,kBAAkB,MAAM;IACxB,cAAc,MAAM;IACpB,6BAA6B,MAAM;IACnC,eAAe,MAAM;IACrB,QAAQ,MAAM;IACd,IAAI,MAAM;IACV,eAAe,MAAM;IACrB,mBAAmB,MAAM;IACzB,wBAAwB,MAAM;IAC9B,oBAAoB,MAAM;IAC1B,sBAAsB,MAAM;IAC5B,qBAAqB,MAAM;IAC3B,kBAAkB,MAAM;IACxB,qBAAqB,MAAM;IAC3B,eAAe,MAAM;IACrB,WAAW,MAAM;IACjB,mBAAmB,MAAM;IACzB,eAAe,MAAM;IACrB,0BAA0B,MAAM;CACjC"}
|
package/http/http-status-code.js
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.HttpStatusCode = void 0;
|
|
4
|
-
var HttpStatusCode;
|
|
1
|
+
export var HttpStatusCode;
|
|
5
2
|
(function (HttpStatusCode) {
|
|
6
3
|
HttpStatusCode[HttpStatusCode["CONTINUE"] = 100] = "CONTINUE";
|
|
7
4
|
HttpStatusCode[HttpStatusCode["SWITCHING_PROTOCOLS"] = 101] = "SWITCHING_PROTOCOLS";
|
|
@@ -43,5 +40,5 @@ var HttpStatusCode;
|
|
|
43
40
|
HttpStatusCode[HttpStatusCode["SERVICE_UNAVAILABLE"] = 503] = "SERVICE_UNAVAILABLE";
|
|
44
41
|
HttpStatusCode[HttpStatusCode["GATEWAY_TIMEOUT"] = 504] = "GATEWAY_TIMEOUT";
|
|
45
42
|
HttpStatusCode[HttpStatusCode["HTTP_VERSION_NOT_SUPPORTED"] = 505] = "HTTP_VERSION_NOT_SUPPORTED";
|
|
46
|
-
})(HttpStatusCode || (
|
|
43
|
+
})(HttpStatusCode || (HttpStatusCode = {}));
|
|
47
44
|
//# sourceMappingURL=http-status-code.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http-status-code.js","sourceRoot":"","sources":["http-status-code.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"http-status-code.js","sourceRoot":"","sources":["../../src/http/http-status-code.ts"],"names":[],"mappings":"AAAA,MAAM,CAAN,IAAY,cAyCX;AAzCD,WAAY,cAAc;IACxB,6DAAc,CAAA;IACd,mFAAyB,CAAA;IACzB,iDAAQ,CAAA;IACR,2DAAa,CAAA;IACb,6DAAc,CAAA;IACd,uGAAmC,CAAA;IACnC,iEAAgB,CAAA;IAChB,uEAAmB,CAAA;IACnB,2EAAqB,CAAA;IACrB,6EAAsB,CAAA;IACtB,iFAAwB,CAAA;IACxB,uDAAW,CAAA;IACX,+DAAe,CAAA;IACf,qEAAkB,CAAA;IAClB,+DAAe,CAAA;IACf,iFAAwB,CAAA;IACxB,mEAAiB,CAAA;IACjB,qEAAkB,CAAA;IAClB,6EAAsB,CAAA;IACtB,+DAAe,CAAA;IACf,+DAAe,CAAA;IACf,iFAAwB,CAAA;IACxB,yEAAoB,CAAA;IACpB,uGAAmC,CAAA;IACnC,2EAAqB,CAAA;IACrB,6DAAc,CAAA;IACd,qDAAU,CAAA;IACV,2EAAqB,CAAA;IACrB,mFAAyB,CAAA;IACzB,6FAA8B,CAAA;IAC9B,qFAA0B,CAAA;IAC1B,yFAA4B,CAAA;IAC5B,uFAA2B,CAAA;IAC3B,iFAAwB,CAAA;IACxB,uFAA2B,CAAA;IAC3B,2EAAqB,CAAA;IACrB,mEAAiB,CAAA;IACjB,mFAAyB,CAAA;IACzB,2EAAqB,CAAA;IACrB,iGAAgC,CAAA;AAClC,CAAC,EAzCW,cAAc,KAAd,cAAc,QAyCzB","sourcesContent":["export enum HttpStatusCode {\n CONTINUE = 100,\n SWITCHING_PROTOCOLS = 101,\n OK = 200,\n CREATED = 201,\n ACCEPTED = 202,\n NON_AUTHORITATIVE_INFORMATION = 203,\n NO_CONTENT = 204,\n RESET_CONTENT = 205,\n PARTIAL_CONTENT = 206,\n MULTIPLE_CHOICES = 300,\n PERMANENT_REDIRECT = 301,\n FOUND = 302,\n SEE_OTHER = 303,\n NOT_MODIFIED = 304,\n USE_PROXY = 305,\n TEMPORARY_REDIRECT = 307,\n BAD_REQUEST = 400,\n UNAUTHORIZED = 401,\n PAYMENT_REQUIRED = 402,\n FORBIDDEN = 403,\n NOT_FOUND = 404,\n METHOD_NOT_ALLOWED = 405,\n NOT_ACCEPTABLE = 406,\n PROXY_AUTHENTICATION_REQUIRED = 407,\n REQUEST_TIMEOUT = 408,\n CONFLICT = 409,\n GONE = 410,\n LENGTH_REQUIRED = 411,\n PRECONDITION_FAILED = 412,\n REQUEST_ENTITY_TOO_LARGE = 413,\n REQUEST_URI_TOO_LONG = 414,\n UNSUPPORTED_MEDIA_TYPE = 415,\n RANGE_NOT_SATISFIABLE = 416,\n EXPECTATION_FAILED = 417,\n INTERNAL_SERVER_ERROR = 500,\n NOT_IMPLEMENTED = 501,\n BAD_GATEWAY = 502,\n SERVICE_UNAVAILABLE = 503,\n GATEWAY_TIMEOUT = 504,\n HTTP_VERSION_NOT_SUPPORTED = 505,\n}\n"]}
|
package/http/index.d.ts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/http/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,eAAe,CAAC"}
|
package/http/index.js
CHANGED
|
@@ -1,19 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./http-status-code"), exports);
|
|
18
|
-
__exportStar(require("./http-method"), exports);
|
|
1
|
+
export * from './http-status-code';
|
|
2
|
+
export * from './http-method';
|
|
19
3
|
//# sourceMappingURL=index.js.map
|
package/http/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/http/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,eAAe,CAAC","sourcesContent":["export * from './http-status-code';\nexport * from './http-method';\n"]}
|
package/lang/index.d.ts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/lang/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,SAAS,CAAC"}
|
package/lang/index.js
CHANGED
|
@@ -1,18 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./type-functions"), exports);
|
|
1
|
+
export * from './type-functions';
|
|
2
|
+
export * from './sleep';
|
|
18
3
|
//# sourceMappingURL=index.js.map
|
package/lang/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/lang/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,SAAS,CAAC","sourcesContent":["export * from './type-functions';\nexport * from './sleep';\n"]}
|
package/lang/sleep.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sleep.d.ts","sourceRoot":"","sources":["../../src/lang/sleep.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,wBAAgB,KAAK,CAAC,EAAE,EAAE,MAAM,oBAE/B"}
|
package/lang/sleep.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sleep.js","sourceRoot":"","sources":["../../src/lang/sleep.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,UAAU,KAAK,CAAC,EAAU;IAC9B,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC;AACzD,CAAC","sourcesContent":["/**\n * Sleep for a given amount of time\n *\n * @param ms the number of milliseconds to sleep\n */\nexport function sleep(ms: number) {\n return new Promise(resolve => setTimeout(resolve, ms));\n}\n"]}
|
package/lang/type-functions.d.ts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type-functions.d.ts","sourceRoot":"","sources":["../../src/lang/type-functions.ts"],"names":[],"mappings":"AAAA,wBAAgB,QAAQ,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAIvE;AAED,wBAAgB,QAAQ,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,IAAI,MAAM,CAEtD;AAED,wBAAgB,OAAO,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,IAAI,KAAK,CAEpD"}
|
package/lang/type-functions.js
CHANGED
|
@@ -1,16 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isError = exports.isString = exports.isObject = void 0;
|
|
4
|
-
function isObject(item) {
|
|
1
|
+
export function isObject(item) {
|
|
5
2
|
return (item !== null && typeof item === 'object' && Array.isArray(item) === false);
|
|
6
3
|
}
|
|
7
|
-
|
|
8
|
-
function isString(item) {
|
|
4
|
+
export function isString(item) {
|
|
9
5
|
return typeof item === 'string';
|
|
10
6
|
}
|
|
11
|
-
|
|
12
|
-
function isError(item) {
|
|
7
|
+
export function isError(item) {
|
|
13
8
|
return item instanceof Error;
|
|
14
9
|
}
|
|
15
|
-
exports.isError = isError;
|
|
16
10
|
//# sourceMappingURL=type-functions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"type-functions.js","sourceRoot":"","sources":["type-functions.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"type-functions.js","sourceRoot":"","sources":["../../src/lang/type-functions.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,QAAQ,CAAC,IAAa;IACpC,OAAO,CACL,IAAI,KAAK,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,KAAK,CAC3E,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,QAAQ,CAAC,IAAa;IACpC,OAAO,OAAO,IAAI,KAAK,QAAQ,CAAC;AAClC,CAAC;AAED,MAAM,UAAU,OAAO,CAAC,IAAa;IACnC,OAAO,IAAI,YAAY,KAAK,CAAC;AAC/B,CAAC","sourcesContent":["export function isObject(item: unknown): item is Record<string, unknown> {\n return (\n item !== null && typeof item === 'object' && Array.isArray(item) === false\n );\n}\n\nexport function isString(item: unknown): item is string {\n return typeof item === 'string';\n}\n\nexport function isError(item: unknown): item is Error {\n return item instanceof Error;\n}\n"]}
|