1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | exports.isString = exports.isFunction = exports.isError = exports.isArray = exports.isPlainObject = exports.isObject = exports.getTag = void 0;
|
4 | const getTag = (value) => {
|
5 | const toString = Object.prototype.toString;
|
6 | if (value == null) {
|
7 | return value === undefined ? "[object Undefined]" : "[object Null]";
|
8 | }
|
9 | return toString.call(value);
|
10 | };
|
11 | exports.getTag = getTag;
|
12 | const isObject = (value) => {
|
13 | return typeof value === "object" && value !== null;
|
14 | };
|
15 | exports.isObject = isObject;
|
16 | const isPlainObject = (value) => {
|
17 | if (!exports.isObject(value) || exports.getTag(value) != "[object Object]") {
|
18 | return false;
|
19 | }
|
20 | if (Object.getPrototypeOf(value) === null) {
|
21 | return true;
|
22 | }
|
23 | let proto = value;
|
24 | while (Object.getPrototypeOf(proto) !== null) {
|
25 | proto = Object.getPrototypeOf(proto);
|
26 | }
|
27 | return Object.getPrototypeOf(value) === proto;
|
28 | };
|
29 | exports.isPlainObject = isPlainObject;
|
30 | const isArray = (value) => {
|
31 | return value && Array.isArray(value);
|
32 | };
|
33 | exports.isArray = isArray;
|
34 | const isError = (value) => {
|
35 | if (!exports.isObject(value)) {
|
36 | return false;
|
37 | }
|
38 | const tag = exports.getTag(value);
|
39 | return tag == "[object Error]" || tag == "[object DOMException]" || (typeof value.message === "string" && typeof value.name === "string" && !exports.isPlainObject(value));
|
40 | };
|
41 | exports.isError = isError;
|
42 | const isFunction = (value) => {
|
43 | return typeof value === "function";
|
44 | };
|
45 | exports.isFunction = isFunction;
|
46 | const isString = (value) => {
|
47 | const type = typeof value;
|
48 | return type === "string" || (type === "object" && value != null && !Array.isArray(value) && exports.getTag(value) == "[object String]");
|
49 | };
|
50 | exports.isString = isString;
|