bigint-crypto-utils/node_modules/js2xmlparser/lib/utils.js

93 lines
2.5 KiB
JavaScript
Raw Normal View History

"use strict";
/**
* Copyright (C) 2016-2019 Michael Kourlas
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
Object.defineProperty(exports, "__esModule", { value: true });
/**
* @private
*/
function isUndefined(val) {
return Object.prototype.toString.call(val) === "[object Undefined]";
}
exports.isUndefined = isUndefined;
/**
* @private
*/
function isNull(val) {
return Object.prototype.toString.call(val) === "[object Null]";
}
exports.isNull = isNull;
/* tslint:disable:ban-types */
/**
* @private
*/
function isObject(val) {
return Object.prototype.toString.call(val) === "[object Object]";
}
exports.isObject = isObject;
/* tslint:enable:ban-types */
/**
* @private
*/
function isArray(val) {
return Object.prototype.toString.call(val) === "[object Array]";
}
exports.isArray = isArray;
/* tslint:disable:ban-types */
/**
* @private
*/
function isFunction(val) {
return Object.prototype.toString.call(val) === "[object Function]";
}
exports.isFunction = isFunction;
/* tslint:enable:ban-types */
/**
* @private
*/
function isSet(val) {
return Object.prototype.toString.call(val) === "[object Set]";
}
exports.isSet = isSet;
/**
* @private
*/
function isMap(val) {
return Object.prototype.toString.call(val) === "[object Map]";
}
exports.isMap = isMap;
/**
* Returns a string representation of the specified value, as given by the
* value's toString() method (if it has one) or the global String() function
* (if it does not).
*
* @param value The value to convert to a string.
*
* @returns A string representation of the specified value.
*
* @private
*/
// eslint-disable-next-line @typescript-eslint/no-explicit-any
function stringify(value) {
var _a;
if (!isUndefined(value) && !isNull(value)) {
if (!isFunction((_a = value) === null || _a === void 0 ? void 0 : _a.toString)) {
value = value.toString();
}
}
return String(value);
}
exports.stringify = stringify;