12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
- /**
- * Converts any value to string.
- *
- * @param {*} value
- * @returns {String}
- */
- export function stringify(value) {
- var result = void 0;
- switch (typeof value === 'undefined' ? 'undefined' : _typeof(value)) {
- case 'string':
- case 'number':
- result = '' + value;
- break;
- case 'object':
- result = value === null ? '' : value.toString();
- break;
- case 'undefined':
- result = '';
- break;
- default:
- result = value.toString();
- break;
- }
- return result;
- }
- /**
- * Checks if given variable is defined.
- *
- * @param {*} variable Variable to check.
- * @returns {Boolean}
- */
- export function isDefined(variable) {
- return typeof variable !== 'undefined';
- }
- /**
- * Checks if given variable is undefined.
- *
- * @param {*} variable Variable to check.
- * @returns {Boolean}
- */
- export function isUndefined(variable) {
- return typeof variable === 'undefined';
- }
- /**
- * Check if given variable is null, empty string or undefined.
- *
- * @param {*} variable Variable to check.
- * @returns {Boolean}
- */
- export function isEmpty(variable) {
- return variable === null || variable === '' || isUndefined(variable);
- }
- /**
- * Check if given variable is a regular expression.
- *
- * @param {*} variable Variable to check.
- * @returns {Boolean}
- */
- export function isRegExp(variable) {
- return Object.prototype.toString.call(variable) === '[object RegExp]';
- }
|