UNPKG

haw-utils

Version:

一个基于业务场景的工具方法库

51 lines (49 loc) 1.18 kB
(function (global, factory) { if (typeof define === "function" && define.amd) { define(["exports"], factory); } else if (typeof exports !== "undefined") { factory(exports); } else { var mod = { exports: {} }; factory(mod.exports); global.isIPv4 = mod.exports; } })(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports) { "use strict"; Object.defineProperty(_exports, "__esModule", { value: true }); _exports["default"] = void 0; // ipv4正则 var reg = /^((\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.){3}(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])$/; /** * 检测值是否为ipv4 * * @static * @alias module:Validator.isIPv4 * @since 1.1.0 * @param {String} value 要检测的值 * @returns {Boolean} 值是否为ipv4 * @example * * isIPv4('192.168.1.1'); * // => true * * isIPv4('255.255.255.255'); * // => true * * isIPv4('256.256.256.256'); * // => false * * isIPv4('0.0'); * // => false * */ function isIPv4(value) { return reg.test(value); } var _default = isIPv4; _exports["default"] = _default; });