1 | "use strict";
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 | Object.defineProperty(exports, "__esModule", { value: true });
|
18 | exports.isUndefinedOrNull = exports.isDefined = exports.unreachable = exports.nullToUndefined = exports.isStringArray = exports.isArray = exports.isUndefined = exports.isObject = exports.isEmptyObject = exports.isFunction = exports.isErrorLike = exports.isError = exports.isNumber = exports.isString = exports.isBoolean = exports.Prioritizeable = exports.ArrayUtils = void 0;
|
19 | var array_utils_1 = require("./array-utils");
|
20 | Object.defineProperty(exports, "ArrayUtils", { enumerable: true, get: function () { return array_utils_1.ArrayUtils; } });
|
21 | var prioritizeable_1 = require("./prioritizeable");
|
22 | Object.defineProperty(exports, "Prioritizeable", { enumerable: true, get: function () { return prioritizeable_1.Prioritizeable; } });
|
23 | function isBoolean(value) {
|
24 | return value === true || value === false;
|
25 | }
|
26 | exports.isBoolean = isBoolean;
|
27 | function isString(value) {
|
28 | return typeof value === 'string' || value instanceof String;
|
29 | }
|
30 | exports.isString = isString;
|
31 | function isNumber(value) {
|
32 | return typeof value === 'number' || value instanceof Number;
|
33 | }
|
34 | exports.isNumber = isNumber;
|
35 | function isError(value) {
|
36 | return value instanceof Error;
|
37 | }
|
38 | exports.isError = isError;
|
39 | function isErrorLike(value) {
|
40 | return isObject(value) && isString(value.name) && isString(value.message) && (isUndefined(value.stack) || isString(value.stack));
|
41 | }
|
42 | exports.isErrorLike = isErrorLike;
|
43 |
|
44 | function isFunction(value) {
|
45 | return typeof value === 'function';
|
46 | }
|
47 | exports.isFunction = isFunction;
|
48 |
|
49 |
|
50 |
|
51 | function isEmptyObject(obj) {
|
52 | if (!isObject(obj)) {
|
53 | return false;
|
54 | }
|
55 | for (const key in obj) {
|
56 | if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
57 | return false;
|
58 | }
|
59 | }
|
60 | return true;
|
61 | }
|
62 | exports.isEmptyObject = isEmptyObject;
|
63 | function isObject(value) {
|
64 |
|
65 | return typeof value === 'object' && value !== null;
|
66 | }
|
67 | exports.isObject = isObject;
|
68 | function isUndefined(value) {
|
69 | return typeof value === 'undefined';
|
70 | }
|
71 | exports.isUndefined = isUndefined;
|
72 |
|
73 |
|
74 |
|
75 |
|
76 |
|
77 |
|
78 | function isArray(value, every, thisArg) {
|
79 | return Array.isArray(value) && (!isFunction(every) || value.every(every, thisArg));
|
80 | }
|
81 | exports.isArray = isArray;
|
82 | function isStringArray(value) {
|
83 | return isArray(value, isString);
|
84 | }
|
85 | exports.isStringArray = isStringArray;
|
86 |
|
87 |
|
88 |
|
89 | function nullToUndefined(nullable) {
|
90 | const undefinable = { ...nullable };
|
91 | for (const key in nullable) {
|
92 |
|
93 | if (nullable[key] === null && Object.prototype.hasOwnProperty.call(nullable, key)) {
|
94 | undefinable[key] = undefined;
|
95 | }
|
96 | }
|
97 | return undefinable;
|
98 | }
|
99 | exports.nullToUndefined = nullToUndefined;
|
100 |
|
101 |
|
102 |
|
103 | function unreachable(_never, message = 'unhandled case') {
|
104 | throw new Error(message);
|
105 | }
|
106 | exports.unreachable = unreachable;
|
107 |
|
108 |
|
109 |
|
110 |
|
111 |
|
112 |
|
113 |
|
114 |
|
115 | function isDefined(arg) {
|
116 | return !isUndefinedOrNull(arg);
|
117 | }
|
118 | exports.isDefined = isDefined;
|
119 |
|
120 |
|
121 |
|
122 | function isUndefinedOrNull(obj) {
|
123 |
|
124 | return (isUndefined(obj) || obj === null);
|
125 | }
|
126 | exports.isUndefinedOrNull = isUndefinedOrNull;
|
127 |
|
\ | No newline at end of file |