UNPKG

2.57 kBJavaScriptView Raw
1"use strict";
2/**
3 * Copyright (C) 2016-2019 Michael Kourlas
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17Object.defineProperty(exports, "__esModule", { value: true });
18/**
19 * @private
20 */
21function isUndefined(val) {
22 return Object.prototype.toString.call(val) === "[object Undefined]";
23}
24exports.isUndefined = isUndefined;
25/**
26 * @private
27 */
28function isNull(val) {
29 return Object.prototype.toString.call(val) === "[object Null]";
30}
31exports.isNull = isNull;
32/* tslint:disable:ban-types */
33/**
34 * @private
35 */
36function isObject(val) {
37 return Object.prototype.toString.call(val) === "[object Object]";
38}
39exports.isObject = isObject;
40/* tslint:enable:ban-types */
41/**
42 * @private
43 */
44function isArray(val) {
45 return Object.prototype.toString.call(val) === "[object Array]";
46}
47exports.isArray = isArray;
48/* tslint:disable:ban-types */
49/**
50 * @private
51 */
52function isFunction(val) {
53 return Object.prototype.toString.call(val) === "[object Function]";
54}
55exports.isFunction = isFunction;
56/* tslint:enable:ban-types */
57/**
58 * @private
59 */
60function isSet(val) {
61 return Object.prototype.toString.call(val) === "[object Set]";
62}
63exports.isSet = isSet;
64/**
65 * @private
66 */
67function isMap(val) {
68 return Object.prototype.toString.call(val) === "[object Map]";
69}
70exports.isMap = isMap;
71/**
72 * Returns a string representation of the specified value, as given by the
73 * value's toString() method (if it has one) or the global String() function
74 * (if it does not).
75 *
76 * @param value The value to convert to a string.
77 *
78 * @returns A string representation of the specified value.
79 *
80 * @private
81 */
82// eslint-disable-next-line @typescript-eslint/no-explicit-any
83function stringify(value) {
84 var _a;
85 if (!isUndefined(value) && !isNull(value)) {
86 if (!isFunction((_a = value) === null || _a === void 0 ? void 0 : _a.toString)) {
87 value = value.toString();
88 }
89 }
90 return String(value);
91}
92exports.stringify = stringify;