@rickosborne/guard 2024.12.36 → 2025.1.10
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/README.md +33 -1
- package/error-from-message.cjs +41 -0
- package/error-from-message.cjs.map +6 -0
- package/error-from-message.d.ts.map +1 -0
- package/error-from-message.mjs +22 -0
- package/error-from-message.mjs.map +6 -0
- package/has-array.cjs +31 -0
- package/has-array.cjs.map +6 -0
- package/has-array.d.ts.map +1 -0
- package/has-array.mjs +12 -0
- package/has-array.mjs.map +6 -0
- package/has-number.cjs +29 -0
- package/has-number.cjs.map +6 -0
- package/has-number.d.ts.map +1 -0
- package/has-number.mjs +10 -0
- package/has-number.mjs.map +6 -0
- package/has-object.cjs +34 -0
- package/has-object.cjs.map +6 -0
- package/has-object.d.ts.map +1 -0
- package/has-object.mjs +15 -0
- package/has-object.mjs.map +6 -0
- package/has-own.cjs +33 -0
- package/has-own.cjs.map +6 -0
- package/has-own.d.ts.map +1 -0
- package/has-own.mjs +14 -0
- package/has-own.mjs.map +6 -0
- package/index.cjs +29 -0
- package/index.cjs.map +6 -0
- package/index.d.ts +12 -0
- package/index.d.ts.map +1 -0
- package/index.mjs +12 -0
- package/index.mjs.map +6 -0
- package/is-defined.cjs +40 -0
- package/is-defined.cjs.map +6 -0
- package/{types/ts/is-defined.d.ts → is-defined.d.ts} +1 -1
- package/is-defined.d.ts.map +1 -0
- package/is-defined.mjs +21 -0
- package/is-defined.mjs.map +6 -0
- package/is-int.cjs +53 -0
- package/is-int.cjs.map +6 -0
- package/{types/ts/is-int.d.ts → is-int.d.ts} +1 -1
- package/is-int.d.ts.map +1 -0
- package/is-int.mjs +34 -0
- package/is-int.mjs.map +6 -0
- package/is-list-of.cjs +28 -0
- package/is-list-of.cjs.map +6 -0
- package/is-list-of.d.ts.map +1 -0
- package/is-list-of.mjs +9 -0
- package/is-list-of.mjs.map +6 -0
- package/is-object.cjs +41 -0
- package/is-object.cjs.map +6 -0
- package/{types/ts/is-object.d.ts → is-object.d.ts} +5 -0
- package/is-object.d.ts.map +1 -0
- package/is-object.mjs +22 -0
- package/is-object.mjs.map +6 -0
- package/is-predicate.cjs +28 -0
- package/is-predicate.cjs.map +6 -0
- package/is-predicate.d.ts.map +1 -0
- package/is-predicate.mjs +9 -0
- package/is-predicate.mjs.map +6 -0
- package/package.json +92 -11
- package/scrub-stack-trace.cjs +63 -0
- package/scrub-stack-trace.cjs.map +6 -0
- package/{types/ts/scrub-stack-trace.d.ts → scrub-stack-trace.d.ts} +6 -1
- package/scrub-stack-trace.d.ts.map +1 -0
- package/scrub-stack-trace.mjs +44 -0
- package/scrub-stack-trace.mjs.map +6 -0
- package/cjs/index.js +0 -28
- package/cjs/index.js.map +0 -1
- package/cjs/package.json +0 -6
- package/cjs/ts/error-from-message.js +0 -27
- package/cjs/ts/error-from-message.js.map +0 -1
- package/cjs/ts/has-array.js +0 -12
- package/cjs/ts/has-array.js.map +0 -1
- package/cjs/ts/has-number.js +0 -13
- package/cjs/ts/has-number.js.map +0 -1
- package/cjs/ts/has-object.js +0 -22
- package/cjs/ts/has-object.js.map +0 -1
- package/cjs/ts/has-own.js +0 -15
- package/cjs/ts/has-own.js.map +0 -1
- package/cjs/ts/is-defined.js +0 -30
- package/cjs/ts/is-defined.js.map +0 -1
- package/cjs/ts/is-int.js +0 -54
- package/cjs/ts/is-int.js.map +0 -1
- package/cjs/ts/is-list-of.js +0 -12
- package/cjs/ts/is-list-of.js.map +0 -1
- package/cjs/ts/is-object.js +0 -24
- package/cjs/ts/is-object.js.map +0 -1
- package/cjs/ts/is-predicate.js +0 -14
- package/cjs/ts/is-predicate.js.map +0 -1
- package/cjs/ts/scrub-stack-trace.js +0 -48
- package/cjs/ts/scrub-stack-trace.js.map +0 -1
- package/cjs/tsconfig.cjs.tsbuildinfo +0 -1
- package/esm/index.js +0 -12
- package/esm/index.js.map +0 -1
- package/esm/package.json +0 -6
- package/esm/ts/error-from-message.js +0 -23
- package/esm/ts/error-from-message.js.map +0 -1
- package/esm/ts/has-array.js +0 -9
- package/esm/ts/has-array.js.map +0 -1
- package/esm/ts/has-number.js +0 -9
- package/esm/ts/has-number.js.map +0 -1
- package/esm/ts/has-object.js +0 -17
- package/esm/ts/has-object.js.map +0 -1
- package/esm/ts/has-own.js +0 -12
- package/esm/ts/has-own.js.map +0 -1
- package/esm/ts/is-defined.js +0 -24
- package/esm/ts/is-defined.js.map +0 -1
- package/esm/ts/is-int.js +0 -47
- package/esm/ts/is-int.js.map +0 -1
- package/esm/ts/is-list-of.js +0 -8
- package/esm/ts/is-list-of.js.map +0 -1
- package/esm/ts/is-object.js +0 -19
- package/esm/ts/is-object.js.map +0 -1
- package/esm/ts/is-predicate.js +0 -10
- package/esm/ts/is-predicate.js.map +0 -1
- package/esm/ts/scrub-stack-trace.js +0 -46
- package/esm/ts/scrub-stack-trace.js.map +0 -1
- package/esm/tsconfig.module.tsbuildinfo +0 -1
- package/tsdoc-metadata.json +0 -11
- package/types/index.d.ts +0 -12
- package/types/index.d.ts.map +0 -1
- package/types/index.js +0 -28
- package/types/index.js.map +0 -1
- package/types/ts/error-from-message.d.ts.map +0 -1
- package/types/ts/error-from-message.js +0 -27
- package/types/ts/error-from-message.js.map +0 -1
- package/types/ts/has-array.d.ts.map +0 -1
- package/types/ts/has-array.js +0 -12
- package/types/ts/has-array.js.map +0 -1
- package/types/ts/has-number.d.ts.map +0 -1
- package/types/ts/has-number.js +0 -13
- package/types/ts/has-number.js.map +0 -1
- package/types/ts/has-object.d.ts.map +0 -1
- package/types/ts/has-object.js +0 -22
- package/types/ts/has-object.js.map +0 -1
- package/types/ts/has-own.d.ts.map +0 -1
- package/types/ts/has-own.js +0 -15
- package/types/ts/has-own.js.map +0 -1
- package/types/ts/is-defined.d.ts.map +0 -1
- package/types/ts/is-defined.js +0 -30
- package/types/ts/is-defined.js.map +0 -1
- package/types/ts/is-int.d.ts.map +0 -1
- package/types/ts/is-int.js +0 -54
- package/types/ts/is-int.js.map +0 -1
- package/types/ts/is-list-of.d.ts.map +0 -1
- package/types/ts/is-list-of.js +0 -12
- package/types/ts/is-list-of.js.map +0 -1
- package/types/ts/is-object.d.ts.map +0 -1
- package/types/ts/is-object.js +0 -24
- package/types/ts/is-object.js.map +0 -1
- package/types/ts/is-predicate.d.ts.map +0 -1
- package/types/ts/is-predicate.js +0 -14
- package/types/ts/is-predicate.js.map +0 -1
- package/types/ts/scrub-stack-trace.d.ts.map +0 -1
- package/types/ts/scrub-stack-trace.js +0 -50
- package/types/ts/scrub-stack-trace.js.map +0 -1
- package/types/tsconfig.types.tsbuildinfo +0 -1
- /package/{types/ts/error-from-message.d.ts → error-from-message.d.ts} +0 -0
- /package/{types/ts/has-array.d.ts → has-array.d.ts} +0 -0
- /package/{types/ts/has-number.d.ts → has-number.d.ts} +0 -0
- /package/{types/ts/has-object.d.ts → has-object.d.ts} +0 -0
- /package/{types/ts/has-own.d.ts → has-own.d.ts} +0 -0
- /package/{types/ts/is-list-of.d.ts → is-list-of.d.ts} +0 -0
- /package/{types/ts/is-predicate.d.ts → is-predicate.d.ts} +0 -0
package/README.md
CHANGED
|
@@ -230,13 +230,21 @@ Convert to an integer, if it seems like it could be done safely. See [decimal se
|
|
|
230
230
|
<a id="api-scrubstacktrace"></a>
|
|
231
231
|
|
|
232
232
|
```typescript
|
|
233
|
-
scrubStackTrace
|
|
233
|
+
function scrubStackTrace<E extends Error>(err: E, removeIf?: StackRemoveIf | undefined): E;
|
|
234
234
|
```
|
|
235
235
|
|
|
236
236
|
Wrap an Error in a proxy which cleans up the stack trace to be more human-readable. It filters out lines from third-party code, so you can quickly see your own code in the call stack. May optionally include some way of indicating additional lines which should be removed, so a guard function could make itself transparent, making it seem like the caller threw the error.
|
|
237
237
|
|
|
238
238
|
|
|
239
239
|
|
|
240
|
+
#### scrubStackTrace
|
|
241
|
+
|
|
242
|
+
<a id="api-scrubstacktrace"></a>
|
|
243
|
+
|
|
244
|
+
```typescript
|
|
245
|
+
function scrubStackTrace(stack: string | undefined, removeIf?: StackRemoveIf | undefined): string | undefined;
|
|
246
|
+
```
|
|
247
|
+
|
|
240
248
|
### TypeAliases
|
|
241
249
|
|
|
242
250
|
#### MessageOrError
|
|
@@ -250,3 +258,27 @@ type MessageOrError = string | Error | (() => (string | Error));
|
|
|
250
258
|
A message, an error, or something which can generate one of those.
|
|
251
259
|
|
|
252
260
|
|
|
261
|
+
#### StackRemoveIf
|
|
262
|
+
|
|
263
|
+
<a id="api-stackremoveif"></a>
|
|
264
|
+
|
|
265
|
+
```typescript
|
|
266
|
+
type StackRemoveIf = Predicate<string> | RegExp | string;
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
Specifier for which lines of a stack trace should be removed.
|
|
270
|
+
|
|
271
|
+
|
|
272
|
+
### Variables
|
|
273
|
+
|
|
274
|
+
#### notPlainObject
|
|
275
|
+
|
|
276
|
+
<a id="api-notplainobject"></a>
|
|
277
|
+
|
|
278
|
+
```typescript
|
|
279
|
+
notPlainObject: unique symbol
|
|
280
|
+
```
|
|
281
|
+
|
|
282
|
+
A symbol which can be exposed when you want [isPlainObject](#api-isplainobject) to be false for an object. It doesn't matter what the value is.
|
|
283
|
+
|
|
284
|
+
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
+
var error_from_message_exports = {};
|
|
21
|
+
__export(error_from_message_exports, {
|
|
22
|
+
errorFromMessageOrError: () => errorFromMessageOrError
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(error_from_message_exports);
|
|
25
|
+
var import_scrub_stack_trace = require("./scrub-stack-trace.cjs");
|
|
26
|
+
const errorFromMessageOrError = /* @__PURE__ */ __name((messageOrError, defaultConstructor = Error) => {
|
|
27
|
+
let stringOrError;
|
|
28
|
+
if (typeof messageOrError === "function") {
|
|
29
|
+
stringOrError = messageOrError();
|
|
30
|
+
} else {
|
|
31
|
+
stringOrError = messageOrError;
|
|
32
|
+
}
|
|
33
|
+
let error;
|
|
34
|
+
if (typeof stringOrError === "string") {
|
|
35
|
+
error = new defaultConstructor(`Missing: ${stringOrError}`);
|
|
36
|
+
} else {
|
|
37
|
+
error = stringOrError;
|
|
38
|
+
}
|
|
39
|
+
return (0, import_scrub_stack_trace.scrubStackTrace)(error, " at errorFromMessageOrError ");
|
|
40
|
+
}, "errorFromMessageOrError");
|
|
41
|
+
//# sourceMappingURL=error-from-message.cjs.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/packages/guard/error-from-message.ts"],
|
|
4
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,+BAAgC;AAWzB,MAAM,0BAA0B,wBACtC,gBACA,qBAAuD,UAC5C;AACX,MAAI;AACJ,MAAI,OAAO,mBAAmB,YAAY;AACzC,oBAAgB,eAAe;AAAA,EAChC,OAAO;AACN,oBAAgB;AAAA,EACjB;AACA,MAAI;AACJ,MAAI,OAAO,kBAAkB,UAAU;AACtC,YAAQ,IAAI,mBAAmB,YAAa,aAAc,EAAE;AAAA,EAC7D,OAAO;AACN,YAAQ;AAAA,EACT;AACA,aAAO,0CAAgB,OAAO,8BAA8B;AAC7D,GAjBuC;",
|
|
5
|
+
"names": []
|
|
6
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error-from-message.d.ts","sourceRoot":"","sources":["../../../src/packages/guard/error-from-message.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG,MAAM,GAAG,KAAK,GAAG,CAAC,MAAM,CAAC,MAAM,GAAG,KAAK,CAAC,CAAC,CAAC;AAEvE;;;GAGG;AACH,eAAO,MAAM,uBAAuB,mBACnB,cAAc,uBACV,CAAC,KAAK,OAAO,EAAE,MAAM,KAAK,KAAK,CAAC,KAClD,KAcF,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
import { scrubStackTrace } from "./scrub-stack-trace.mjs";
|
|
4
|
+
const errorFromMessageOrError = /* @__PURE__ */ __name((messageOrError, defaultConstructor = Error) => {
|
|
5
|
+
let stringOrError;
|
|
6
|
+
if (typeof messageOrError === "function") {
|
|
7
|
+
stringOrError = messageOrError();
|
|
8
|
+
} else {
|
|
9
|
+
stringOrError = messageOrError;
|
|
10
|
+
}
|
|
11
|
+
let error;
|
|
12
|
+
if (typeof stringOrError === "string") {
|
|
13
|
+
error = new defaultConstructor(`Missing: ${stringOrError}`);
|
|
14
|
+
} else {
|
|
15
|
+
error = stringOrError;
|
|
16
|
+
}
|
|
17
|
+
return scrubStackTrace(error, " at errorFromMessageOrError ");
|
|
18
|
+
}, "errorFromMessageOrError");
|
|
19
|
+
export {
|
|
20
|
+
errorFromMessageOrError
|
|
21
|
+
};
|
|
22
|
+
//# sourceMappingURL=error-from-message.mjs.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/packages/guard/error-from-message.ts"],
|
|
4
|
+
"mappings": ";;AAAA,SAAS,uBAAuB;AAWzB,MAAM,0BAA0B,wBACtC,gBACA,qBAAuD,UAC5C;AACX,MAAI;AACJ,MAAI,OAAO,mBAAmB,YAAY;AACzC,oBAAgB,eAAe;AAAA,EAChC,OAAO;AACN,oBAAgB;AAAA,EACjB;AACA,MAAI;AACJ,MAAI,OAAO,kBAAkB,UAAU;AACtC,YAAQ,IAAI,mBAAmB,YAAa,aAAc,EAAE;AAAA,EAC7D,OAAO;AACN,YAAQ;AAAA,EACT;AACA,SAAO,gBAAgB,OAAO,8BAA8B;AAC7D,GAjBuC;",
|
|
5
|
+
"names": []
|
|
6
|
+
}
|
package/has-array.cjs
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
+
var has_array_exports = {};
|
|
21
|
+
__export(has_array_exports, {
|
|
22
|
+
hasArray: () => hasArray
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(has_array_exports);
|
|
25
|
+
var import_has_own = require("./has-own.cjs");
|
|
26
|
+
var import_is_list_of = require("./is-list-of.cjs");
|
|
27
|
+
function hasArray(obj, name, predicate) {
|
|
28
|
+
return (0, import_has_own.hasOwn)(obj, name) && Array.isArray(obj[name]) && (predicate == null || (0, import_is_list_of.isListOf)(obj[name], predicate));
|
|
29
|
+
}
|
|
30
|
+
__name(hasArray, "hasArray");
|
|
31
|
+
//# sourceMappingURL=has-array.cjs.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/packages/guard/has-array.ts"],
|
|
4
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAAuB;AACvB,wBAAyB;AAelB,SAAS,SAAoC,KAAc,MAAY,WAA8G;AAC3L,aAAO,uBAAO,KAAK,IAAI,KAAK,MAAM,QAAQ,IAAI,IAAI,CAAC,MAAM,aAAa,YAAQ,4BAAS,IAAI,IAAI,GAAG,SAAS;AAC5G;AAFgB;",
|
|
5
|
+
"names": []
|
|
6
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"has-array.d.ts","sourceRoot":"","sources":["../../../src/packages/guard/has-array.ts"],"names":[],"mappings":"AAGA;;;GAGG;AACH,wBAAgB,QAAQ,CAAC,IAAI,SAAS,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,SAAS,CAAC,EAAE,SAAS,GAAG,GAAG,IAAI;KAAG,CAAC,IAAI,IAAI,GAAG,OAAO,EAAE;CAAE,CAAC;AAClI;;;GAGG;AACH,wBAAgB,QAAQ,CAAC,IAAI,SAAS,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,SAAS,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,IAAI,IAAI,IAAI,GAAG,GAAG,IAAI;KAAG,CAAC,IAAI,IAAI,GAAG,IAAI,EAAE;CAAE,CAAC"}
|
package/has-array.mjs
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
import { hasOwn } from "./has-own.mjs";
|
|
4
|
+
import { isListOf } from "./is-list-of.mjs";
|
|
5
|
+
function hasArray(obj, name, predicate) {
|
|
6
|
+
return hasOwn(obj, name) && Array.isArray(obj[name]) && (predicate == null || isListOf(obj[name], predicate));
|
|
7
|
+
}
|
|
8
|
+
__name(hasArray, "hasArray");
|
|
9
|
+
export {
|
|
10
|
+
hasArray
|
|
11
|
+
};
|
|
12
|
+
//# sourceMappingURL=has-array.mjs.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/packages/guard/has-array.ts"],
|
|
4
|
+
"mappings": ";;AAAA,SAAS,cAAc;AACvB,SAAS,gBAAgB;AAelB,SAAS,SAAoC,KAAc,MAAY,WAA8G;AAC3L,SAAO,OAAO,KAAK,IAAI,KAAK,MAAM,QAAQ,IAAI,IAAI,CAAC,MAAM,aAAa,QAAQ,SAAS,IAAI,IAAI,GAAG,SAAS;AAC5G;AAFgB;",
|
|
5
|
+
"names": []
|
|
6
|
+
}
|
package/has-number.cjs
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
+
var has_number_exports = {};
|
|
21
|
+
__export(has_number_exports, {
|
|
22
|
+
hasNumber: () => hasNumber
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(has_number_exports);
|
|
25
|
+
var import_has_own = require("./has-own.cjs");
|
|
26
|
+
const hasNumber = /* @__PURE__ */ __name((obj, name) => {
|
|
27
|
+
return (0, import_has_own.hasOwn)(obj, name) && typeof obj[name] === "number";
|
|
28
|
+
}, "hasNumber");
|
|
29
|
+
//# sourceMappingURL=has-number.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"has-number.d.ts","sourceRoot":"","sources":["../../../src/packages/guard/has-number.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,eAAO,MAAM,SAAS,GAAI,IAAI,SAAS,MAAM,OAAO,OAAO,QAAQ,IAAI,KAAG,GAAG,IAAI,GAAG,CAAC,IAAI,IAAI,GAAG,MAAM,GAErG,CAAC"}
|
package/has-number.mjs
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
import { hasOwn } from "./has-own.mjs";
|
|
4
|
+
const hasNumber = /* @__PURE__ */ __name((obj, name) => {
|
|
5
|
+
return hasOwn(obj, name) && typeof obj[name] === "number";
|
|
6
|
+
}, "hasNumber");
|
|
7
|
+
export {
|
|
8
|
+
hasNumber
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=has-number.mjs.map
|
package/has-object.cjs
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
+
var has_object_exports = {};
|
|
21
|
+
__export(has_object_exports, {
|
|
22
|
+
hasObject: () => hasObject,
|
|
23
|
+
hasPlainObject: () => hasPlainObject
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(has_object_exports);
|
|
26
|
+
var import_has_own = require("./has-own.cjs");
|
|
27
|
+
var import_is_object = require("./is-object.cjs");
|
|
28
|
+
const hasObject = /* @__PURE__ */ __name((obj, name) => {
|
|
29
|
+
return (0, import_has_own.hasOwn)(obj, name) && (0, import_is_object.isObject)(obj[name]);
|
|
30
|
+
}, "hasObject");
|
|
31
|
+
const hasPlainObject = /* @__PURE__ */ __name((obj, name) => {
|
|
32
|
+
return (0, import_has_own.hasOwn)(obj, name) && (0, import_is_object.isPlainObject)(obj[name]);
|
|
33
|
+
}, "hasPlainObject");
|
|
34
|
+
//# sourceMappingURL=has-object.cjs.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/packages/guard/has-object.ts"],
|
|
4
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAAuB;AACvB,uBAAwC;AAMjC,MAAM,YAAY,wBAAsB,KAAc,SAA+C;AAC3G,aAAO,uBAAO,KAAK,IAAI,SAAK,2BAAS,IAAK,IAAK,CAAC;AACjD,GAFyB;AAQlB,MAAM,iBAAiB,wBAAsB,KAAc,SAA6D;AAC9H,aAAO,uBAAO,KAAK,IAAI,SAAK,gCAAc,IAAK,IAAK,CAAC;AACtD,GAF8B;",
|
|
5
|
+
"names": []
|
|
6
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"has-object.d.ts","sourceRoot":"","sources":["../../../src/packages/guard/has-object.ts"],"names":[],"mappings":"AAGA;;;GAGG;AACH,eAAO,MAAM,SAAS,GAAI,IAAI,SAAS,MAAM,OAAO,OAAO,QAAQ,IAAI,KAAG,GAAG,IAAI,GAAG,CAAC,IAAI,IAAI,GAAG,MAAM,GAErG,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,cAAc,GAAI,IAAI,SAAS,MAAM,OAAO,OAAO,QAAQ,IAAI,KAAG,GAAG,IAAI,GAAG,CAAC,IAAI,IAAI,GAAG,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,GAExH,CAAC"}
|
package/has-object.mjs
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
import { hasOwn } from "./has-own.mjs";
|
|
4
|
+
import { isObject, isPlainObject } from "./is-object.mjs";
|
|
5
|
+
const hasObject = /* @__PURE__ */ __name((obj, name) => {
|
|
6
|
+
return hasOwn(obj, name) && isObject(obj[name]);
|
|
7
|
+
}, "hasObject");
|
|
8
|
+
const hasPlainObject = /* @__PURE__ */ __name((obj, name) => {
|
|
9
|
+
return hasOwn(obj, name) && isPlainObject(obj[name]);
|
|
10
|
+
}, "hasPlainObject");
|
|
11
|
+
export {
|
|
12
|
+
hasObject,
|
|
13
|
+
hasPlainObject
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=has-object.mjs.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/packages/guard/has-object.ts"],
|
|
4
|
+
"mappings": ";;AAAA,SAAS,cAAc;AACvB,SAAS,UAAU,qBAAqB;AAMjC,MAAM,YAAY,wBAAsB,KAAc,SAA+C;AAC3G,SAAO,OAAO,KAAK,IAAI,KAAK,SAAS,IAAK,IAAK,CAAC;AACjD,GAFyB;AAQlB,MAAM,iBAAiB,wBAAsB,KAAc,SAA6D;AAC9H,SAAO,OAAO,KAAK,IAAI,KAAK,cAAc,IAAK,IAAK,CAAC;AACtD,GAF8B;",
|
|
5
|
+
"names": []
|
|
6
|
+
}
|
package/has-own.cjs
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
+
var has_own_exports = {};
|
|
21
|
+
__export(has_own_exports, {
|
|
22
|
+
hasOwn: () => hasOwn
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(has_own_exports);
|
|
25
|
+
var import_is_object = require("./is-object.cjs");
|
|
26
|
+
function hasOwn(obj, name, predicate) {
|
|
27
|
+
if (!(0, import_is_object.isObject)(obj) || !Object.hasOwn(obj, name)) {
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
30
|
+
return predicate == null || predicate(obj[name]);
|
|
31
|
+
}
|
|
32
|
+
__name(hasOwn, "hasOwn");
|
|
33
|
+
//# sourceMappingURL=has-own.cjs.map
|
package/has-own.cjs.map
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/packages/guard/has-own.ts"],
|
|
4
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uBAAyB;AAkBlB,SAAS,OAA+B,KAAc,MAAY,WAAuE;AAC/I,MAAI,KAAC,2BAAS,GAAG,KAAK,CAAC,OAAO,OAAO,KAAK,IAAI,GAAG;AAChD,WAAO;AAAA,EACR;AACA,SAAO,aAAa,QAAQ,UAAU,IAAK,IAAyB,CAAC;AACtE;AALgB;",
|
|
5
|
+
"names": []
|
|
6
|
+
}
|
package/has-own.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"has-own.d.ts","sourceRoot":"","sources":["../../../src/packages/guard/has-own.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,wBAAgB,MAAM,CAAC,IAAI,SAAS,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,GAAG,GAAG,IAAI;KAAG,CAAC,IAAI,IAAI,GAAG,OAAO;CAAE,CAAC;AACvG;;;;GAIG;AACH,wBAAgB,MAAM,CAAC,IAAI,SAAS,MAAM,EAAE,CAAC,EAAE,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,KAAK,IAAI,CAAC,GAAG,GAAG,IAAI;KAAG,CAAC,IAAI,IAAI,GAAG,CAAC;CAAE,CAAC"}
|
package/has-own.mjs
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
import { isObject } from "./is-object.mjs";
|
|
4
|
+
function hasOwn(obj, name, predicate) {
|
|
5
|
+
if (!isObject(obj) || !Object.hasOwn(obj, name)) {
|
|
6
|
+
return false;
|
|
7
|
+
}
|
|
8
|
+
return predicate == null || predicate(obj[name]);
|
|
9
|
+
}
|
|
10
|
+
__name(hasOwn, "hasOwn");
|
|
11
|
+
export {
|
|
12
|
+
hasOwn
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=has-own.mjs.map
|
package/has-own.mjs.map
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/packages/guard/has-own.ts"],
|
|
4
|
+
"mappings": ";;AAAA,SAAS,gBAAgB;AAkBlB,SAAS,OAA+B,KAAc,MAAY,WAAuE;AAC/I,MAAI,CAAC,SAAS,GAAG,KAAK,CAAC,OAAO,OAAO,KAAK,IAAI,GAAG;AAChD,WAAO;AAAA,EACR;AACA,SAAO,aAAa,QAAQ,UAAU,IAAK,IAAyB,CAAC;AACtE;AALgB;",
|
|
5
|
+
"names": []
|
|
6
|
+
}
|
package/index.cjs
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
15
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
16
|
+
var index_exports = {};
|
|
17
|
+
module.exports = __toCommonJS(index_exports);
|
|
18
|
+
__reExport(index_exports, require("./error-from-message.cjs"), module.exports);
|
|
19
|
+
__reExport(index_exports, require("./has-array.cjs"), module.exports);
|
|
20
|
+
__reExport(index_exports, require("./has-number.cjs"), module.exports);
|
|
21
|
+
__reExport(index_exports, require("./has-object.cjs"), module.exports);
|
|
22
|
+
__reExport(index_exports, require("./has-own.cjs"), module.exports);
|
|
23
|
+
__reExport(index_exports, require("./is-defined.cjs"), module.exports);
|
|
24
|
+
__reExport(index_exports, require("./is-int.cjs"), module.exports);
|
|
25
|
+
__reExport(index_exports, require("./is-list-of.cjs"), module.exports);
|
|
26
|
+
__reExport(index_exports, require("./is-object.cjs"), module.exports);
|
|
27
|
+
__reExport(index_exports, require("./is-predicate.cjs"), module.exports);
|
|
28
|
+
__reExport(index_exports, require("./scrub-stack-trace.cjs"), module.exports);
|
|
29
|
+
//# sourceMappingURL=index.cjs.map
|
package/index.cjs.map
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/packages/guard/index.ts"],
|
|
4
|
+
"mappings": ";;;;;;;;;;;;;;;AAAA;AAAA;AAAA,0BAAc,oCAAd;AACA,0BAAc,2BADd;AAEA,0BAAc,4BAFd;AAGA,0BAAc,4BAHd;AAIA,0BAAc,yBAJd;AAKA,0BAAc,4BALd;AAMA,0BAAc,wBANd;AAOA,0BAAc,4BAPd;AAQA,0BAAc,2BARd;AASA,0BAAc,8BATd;AAUA,0BAAc,mCAVd;",
|
|
5
|
+
"names": []
|
|
6
|
+
}
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export * from "./error-from-message";
|
|
2
|
+
export * from "./has-array";
|
|
3
|
+
export * from "./has-number";
|
|
4
|
+
export * from "./has-object";
|
|
5
|
+
export * from "./has-own";
|
|
6
|
+
export * from "./is-defined";
|
|
7
|
+
export * from "./is-int";
|
|
8
|
+
export * from "./is-list-of";
|
|
9
|
+
export * from "./is-object";
|
|
10
|
+
export * from "./is-predicate";
|
|
11
|
+
export * from "./scrub-stack-trace";
|
|
12
|
+
//# sourceMappingURL=index.d.ts.map
|
package/index.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/packages/guard/index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAC;AACxC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC;AAChC,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,mBAAmB,CAAC;AAClC,cAAc,wBAAwB,CAAC"}
|
package/index.mjs
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export * from "./error-from-message.mjs";
|
|
2
|
+
export * from "./has-array.mjs";
|
|
3
|
+
export * from "./has-number.mjs";
|
|
4
|
+
export * from "./has-object.mjs";
|
|
5
|
+
export * from "./has-own.mjs";
|
|
6
|
+
export * from "./is-defined.mjs";
|
|
7
|
+
export * from "./is-int.mjs";
|
|
8
|
+
export * from "./is-list-of.mjs";
|
|
9
|
+
export * from "./is-object.mjs";
|
|
10
|
+
export * from "./is-predicate.mjs";
|
|
11
|
+
export * from "./scrub-stack-trace.mjs";
|
|
12
|
+
//# sourceMappingURL=index.mjs.map
|
package/index.mjs.map
ADDED
package/is-defined.cjs
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
+
var is_defined_exports = {};
|
|
21
|
+
__export(is_defined_exports, {
|
|
22
|
+
assertDefined: () => assertDefined,
|
|
23
|
+
expectDefined: () => expectDefined,
|
|
24
|
+
isDefined: () => isDefined
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(is_defined_exports);
|
|
27
|
+
var import_error_from_message = require("./error-from-message.cjs");
|
|
28
|
+
function assertDefined(value, messageOrError) {
|
|
29
|
+
if (value != null) {
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
throw (0, import_error_from_message.errorFromMessageOrError)(messageOrError, RangeError);
|
|
33
|
+
}
|
|
34
|
+
__name(assertDefined, "assertDefined");
|
|
35
|
+
const isDefined = /* @__PURE__ */ __name((obj) => obj != null, "isDefined");
|
|
36
|
+
const expectDefined = /* @__PURE__ */ __name((obj, messageOrError) => {
|
|
37
|
+
assertDefined(obj, messageOrError);
|
|
38
|
+
return obj;
|
|
39
|
+
}, "expectDefined");
|
|
40
|
+
//# sourceMappingURL=is-defined.cjs.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/packages/guard/is-defined.ts"],
|
|
4
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,gCAAwC;AAMjC,SAAS,cACf,OACA,gBACkC;AAClC,MAAI,SAAS,MAAM;AAClB;AAAA,EACD;AACA,YAAM,mDAAwB,gBAAgB,UAAU;AACzD;AARgB;AAaT,MAAM,YAAY,wBAAI,QAAkC,OAAO,MAA7C;AAMlB,MAAM,gBAAgB,wBAC5B,KACA,mBACoB;AACpB,gBAAc,KAAK,cAAc;AACjC,SAAO;AACR,GAN6B;",
|
|
5
|
+
"names": []
|
|
6
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"is-defined.d.ts","sourceRoot":"","sources":["../../../src/packages/guard/is-defined.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAG9D;;;GAGG;AACH,wBAAgB,aAAa,CAAC,CAAC,EAC9B,KAAK,EAAE,CAAC,EACR,cAAc,EAAE,cAAc,GAC5B,OAAO,CAAC,KAAK,IAAI,WAAW,CAAC,CAAC,CAAC,CAKjC;AAED;;GAEG;AACH,eAAO,MAAM,SAAS,GAAI,CAAC,OAAO,CAAC,KAAG,GAAG,IAAI,WAAW,CAAC,CAAC,CAAgB,CAAC;AAE3E;;;GAGG;AACH,eAAO,MAAM,aAAa,GAAI,CAAC,OACzB,CAAC,kBACU,cAAc,KAC5B,WAAW,CAAC,CAAC,CAGf,CAAC"}
|
package/is-defined.mjs
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
import { errorFromMessageOrError } from "./error-from-message.mjs";
|
|
4
|
+
function assertDefined(value, messageOrError) {
|
|
5
|
+
if (value != null) {
|
|
6
|
+
return;
|
|
7
|
+
}
|
|
8
|
+
throw errorFromMessageOrError(messageOrError, RangeError);
|
|
9
|
+
}
|
|
10
|
+
__name(assertDefined, "assertDefined");
|
|
11
|
+
const isDefined = /* @__PURE__ */ __name((obj) => obj != null, "isDefined");
|
|
12
|
+
const expectDefined = /* @__PURE__ */ __name((obj, messageOrError) => {
|
|
13
|
+
assertDefined(obj, messageOrError);
|
|
14
|
+
return obj;
|
|
15
|
+
}, "expectDefined");
|
|
16
|
+
export {
|
|
17
|
+
assertDefined,
|
|
18
|
+
expectDefined,
|
|
19
|
+
isDefined
|
|
20
|
+
};
|
|
21
|
+
//# sourceMappingURL=is-defined.mjs.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/packages/guard/is-defined.ts"],
|
|
4
|
+
"mappings": ";;AACA,SAAS,+BAA+B;AAMjC,SAAS,cACf,OACA,gBACkC;AAClC,MAAI,SAAS,MAAM;AAClB;AAAA,EACD;AACA,QAAM,wBAAwB,gBAAgB,UAAU;AACzD;AARgB;AAaT,MAAM,YAAY,wBAAI,QAAkC,OAAO,MAA7C;AAMlB,MAAM,gBAAgB,wBAC5B,KACA,mBACoB;AACpB,gBAAc,KAAK,cAAc;AACjC,SAAO;AACR,GAN6B;",
|
|
5
|
+
"names": []
|
|
6
|
+
}
|
package/is-int.cjs
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
+
var is_int_exports = {};
|
|
21
|
+
__export(is_int_exports, {
|
|
22
|
+
assertInt: () => assertInt,
|
|
23
|
+
expectInt: () => expectInt,
|
|
24
|
+
isInt: () => isInt,
|
|
25
|
+
maybeInt: () => maybeInt
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(is_int_exports);
|
|
28
|
+
var import_error_from_message = require("./error-from-message.cjs");
|
|
29
|
+
const isInt = /* @__PURE__ */ __name((obj) => typeof obj === "number" && !isNaN(obj) && Math.trunc(obj) === obj && obj !== Infinity && obj !== -Infinity, "isInt");
|
|
30
|
+
function assertInt(value, messageOrError) {
|
|
31
|
+
if (!isInt(value)) {
|
|
32
|
+
throw (0, import_error_from_message.errorFromMessageOrError)(messageOrError, TypeError);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
__name(assertInt, "assertInt");
|
|
36
|
+
const expectInt = /* @__PURE__ */ __name((obj, messageOrError) => {
|
|
37
|
+
assertInt(obj, messageOrError);
|
|
38
|
+
return obj;
|
|
39
|
+
}, "expectInt");
|
|
40
|
+
const maybeInt = /* @__PURE__ */ __name((text) => {
|
|
41
|
+
let sign = 1;
|
|
42
|
+
let clean = text.trim();
|
|
43
|
+
if (text.startsWith("-")) {
|
|
44
|
+
sign = -1;
|
|
45
|
+
clean = clean.substring(1);
|
|
46
|
+
}
|
|
47
|
+
clean = clean.replace(/(?<=\d)[_ ](?=\d)/g, "").replace(/^0+[,'.·]0*$/, "0").replace(/^(\d+(?:,\d+)+)[.·]0*$/, (_all, digits) => digits.replace(/[^-0-9]/g, "")).replace(/^(\d+(?:'\d+)+)[.,]0*$/, (_all, digits) => digits.replace(/[^-0-9]/g, "")).replace(/^(\d+(?:\.\d+)+)[,']0*$/, (_all, digits) => digits.replace(/[^-0-9]/g, "")).replace(/^(\d{4,})[,'.·]0*$/, (_all, digits) => digits.replace(/[^-0-9]/g, ""));
|
|
48
|
+
if (/^-?(0|[1-9][0-9]*)$/.test(clean)) {
|
|
49
|
+
return parseInt(clean, 10) * sign;
|
|
50
|
+
}
|
|
51
|
+
return void 0;
|
|
52
|
+
}, "maybeInt");
|
|
53
|
+
//# sourceMappingURL=is-int.cjs.map
|
package/is-int.cjs.map
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/packages/guard/is-int.ts"],
|
|
4
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,gCAAwC;AAMjC,MAAM,QAAQ,wBAAC,QAAgC,OAAO,QAAQ,YAAY,CAAC,MAAM,GAAG,KAAK,KAAK,MAAM,GAAG,MAAM,OAAO,QAAQ,YAAY,QAAQ,WAAlI;AAKd,SAAS,UAAU,OAAgB,gBAAyD;AAClG,MAAI,CAAC,MAAM,KAAK,GAAG;AAClB,cAAM,mDAAwB,gBAAgB,SAAS;AAAA,EACxD;AACD;AAJgB;AAST,MAAM,YAAY,wBACxB,KACA,mBACY;AACZ,YAAU,KAAK,cAAc;AAC7B,SAAO;AACR,GANyB;AAalB,MAAM,WAAW,wBACvB,SACwB;AACxB,MAAI,OAAO;AACX,MAAI,QAAQ,KAAK,KAAK;AAEtB,MAAI,KAAK,WAAW,GAAG,GAAG;AACzB,WAAO;AACP,YAAQ,MAAM,UAAU,CAAC;AAAA,EAC1B;AACA,UAAQ,MACN,QAAQ,uBAAuB,EAAE,EACjC,QAAQ,gBAAgB,GAAG,EAC3B,QAAQ,0BAA0B,CAAC,MAAM,WAAmB,OAAO,QAAQ,YAAY,EAAE,CAAC,EAC1F,QAAQ,0BAA0B,CAAC,MAAM,WAAmB,OAAO,QAAQ,YAAY,EAAE,CAAC,EAC1F,QAAQ,2BAA2B,CAAC,MAAM,WAAmB,OAAO,QAAQ,YAAY,EAAE,CAAC,EAC3F,QAAQ,sBAAsB,CAAC,MAAM,WAAmB,OAAO,QAAQ,YAAY,EAAE,CAAC;AAExF,MAAI,sBAAsB,KAAK,KAAK,GAAG;AACtC,WAAO,SAAS,OAAO,EAAE,IAAI;AAAA,EAC9B;AACA,SAAO;AACR,GAtBwB;",
|
|
5
|
+
"names": []
|
|
6
|
+
}
|