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.unreachable = exports.nullToUndefined = exports.isStringArray = exports.isArray = exports.isUndefined = exports.isObject = 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 | function isObject(value) {
|
49 |
|
50 | return typeof value === 'object' && value !== null;
|
51 | }
|
52 | exports.isObject = isObject;
|
53 | function isUndefined(value) {
|
54 | return typeof value === 'undefined';
|
55 | }
|
56 | exports.isUndefined = isUndefined;
|
57 |
|
58 |
|
59 |
|
60 |
|
61 |
|
62 |
|
63 | function isArray(value, every, thisArg) {
|
64 | return Array.isArray(value) && (!isFunction(every) || value.every(every, thisArg));
|
65 | }
|
66 | exports.isArray = isArray;
|
67 | function isStringArray(value) {
|
68 | return isArray(value, isString);
|
69 | }
|
70 | exports.isStringArray = isStringArray;
|
71 |
|
72 |
|
73 |
|
74 | function nullToUndefined(nullable) {
|
75 | const undefinable = Object.assign({}, nullable);
|
76 | for (const key in nullable) {
|
77 |
|
78 | if (nullable[key] === null && Object.prototype.hasOwnProperty.call(nullable, key)) {
|
79 | undefinable[key] = undefined;
|
80 | }
|
81 | }
|
82 | return undefinable;
|
83 | }
|
84 | exports.nullToUndefined = nullToUndefined;
|
85 |
|
86 |
|
87 |
|
88 | function unreachable(_never, message = 'unhandled case') {
|
89 | throw new Error(message);
|
90 | }
|
91 | exports.unreachable = unreachable;
|
92 |
|
\ | No newline at end of file |