"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.isIp = exports.isValidIP = exports.isHaveRealValue = exports.isEmpty = void 0; /** * 判断对象是否为空 * * @param obj * isEmpty(null) * // => true * * isEmpty(undefined) * // => true * * isEmpty("") * // => true * * isEmpty(NaN) * // => true * * isEmpty(0) * // => false * * isEmpty([1]) * // => false * * isEmpty({name:"123"}) * // => false */ const isEmpty = (obj) => { if (typeof (obj) !== "number" && (obj === null || obj === "" || obj === undefined)) return true; else { if (typeof (obj) === "number" && isNaN(obj)) { return true; } return false; } }; exports.isEmpty = isEmpty; /** * 判断是否有值 * 这个函数的结果就是对isEmpty取非 */ const isHaveRealValue = (value) => { let bool = false; if (value || value === 0 || typeof value === 'boolean') { bool = true; } return bool; }; exports.isHaveRealValue = isHaveRealValue; /* IP正则验证 */ const isValidIP = (ip) => { var reg = /^(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])$/; return reg.test(ip); }; exports.isValidIP = isValidIP; /* IP正则验证 */ exports.isIp = exports.isValidIP; // export const isLocalhost = Boolean( // window.location.hostname === 'localhost' || // // [::1] is the IPv6 localhost address. // window.location.hostname === '[::1]' || // // 127.0.0.1/8 is considered localhost for IPv4. // window.location.hostname.match( // /^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/ // ) // );