1 line
24 KiB
JSON
1 line
24 KiB
JSON
|
{"ast":null,"code":"import _objectSpread from \"@babel/runtime/helpers/esm/objectSpread2\";\nimport _typeof from \"@babel/runtime/helpers/esm/typeof\";\nimport _createClass from \"@babel/runtime/helpers/esm/createClass\";\nimport _classCallCheck from \"@babel/runtime/helpers/esm/classCallCheck\";\nimport _assertThisInitialized from \"@babel/runtime/helpers/esm/assertThisInitialized\";\nimport _inherits from \"@babel/runtime/helpers/esm/inherits\";\nimport _createSuper from \"@babel/runtime/helpers/esm/createSuper\";\nimport _wrapNativeSuper from \"@babel/runtime/helpers/esm/wrapNativeSuper\";\nimport _defineProperty from \"@babel/runtime/helpers/esm/defineProperty\";\nimport _toConsumableArray from \"@babel/runtime/helpers/esm/toConsumableArray\";\n/* eslint no-console:0 */\n\nvar formatRegExp = /%[sdj%]/g;\nexport var warning = function warning() {};\n\n// don't print warning message when in production env or node runtime\nif (typeof process !== 'undefined' && process.env && process.env.NODE_ENV !== 'production' && typeof window !== 'undefined' && typeof document !== 'undefined') {\n warning = function warning(type, errors) {\n if (typeof console !== 'undefined' && console.warn && typeof ASYNC_VALIDATOR_NO_WARNING === 'undefined') {\n if (errors.every(function (e) {\n return typeof e === 'string';\n })) {\n console.warn(type, errors);\n }\n }\n };\n}\nexport function convertFieldsError(errors) {\n if (!errors || !errors.length) return null;\n var fields = {};\n errors.forEach(function (error) {\n var field = error.field;\n fields[field] = fields[field] || [];\n fields[field].push(error);\n });\n return fields;\n}\nexport function format(template) {\n for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {\n args[_key - 1] = arguments[_key];\n }\n var i = 0;\n var len = args.length;\n if (typeof template === 'function') {\n // eslint-disable-next-line prefer-spread\n return template.apply(null, args);\n }\n if (typeof template === 'string') {\n var str = template.replace(formatRegExp, function (x) {\n if (x === '%%') {\n return '%';\n }\n if (i >= len) {\n return x;\n }\n switch (x) {\n case '%s':\n return String(args[i++]);\n case '%d':\n return Number(args[i++]);\n case '%j':\n try {\n return JSON.stringify(args[i++]);\n } catch (_) {\n return '[Circular]';\n }\n break;\n default:\n return x;\n }\n });\n return str;\n }\n return template;\n}\nfunction isNativeStringType(type) {\n return type === 'string' || type === 'url' || type === 'hex' || type === 'email' || type === 'date' || type === 'pattern';\n}\nexport function isEmptyValue(value, type) {\n if (value === undefined || value === null) {\n return true;\n }\n if (type === 'array' && Array.isArray(value) && !value.length) {\n return true;\n }\n if (isNativeStringType(type) && typeof value === 'string' && !value) {\n return true;\n }\n return false;\n}\nexport function isEmptyObject(obj) {\n return Object.keys(obj).length === 0;\n}\nfunction asyncParallelArray(arr, func, callback) {\n var results = [];\n var total = 0;\n var arrLength = arr.length;\n function count(errors) {\n results.push.apply(results, _toConsumableArray(errors || []));\n total++;\n if (total === arrLength) {\n callback(results);\n }\n }\n arr.forEach(function (a) {\n func(a, count);\n });\n}\nfunction asyncSerialArray(arr, func, callback) {\n var index = 0;\n var arrLength = arr.length;\n function next(errors) {\n if (errors && errors.length) {\n callback(errors);\n return;\n }\n var original = index;\n index = index + 1;\n if (original < arrLength) {\n func(arr[original], next);\n } else {\n callback([]);\n }\n }\n next([]);\n}\nfunction flattenObjArr(objArr) {\n var ret = [];\n Object.keys(objArr).forEach(function (k)
|