{"ast":null,"code":"const SemVer = require('../classes/semver');\nconst parse = require('./parse');\nconst {\n safeRe: re,\n t\n} = require('../internal/re');\nconst coerce = (version, options) => {\n if (version instanceof SemVer) {\n return version;\n }\n if (typeof version === 'number') {\n version = String(version);\n }\n if (typeof version !== 'string') {\n return null;\n }\n options = options || {};\n let match = null;\n if (!options.rtl) {\n match = version.match(options.includePrerelease ? re[t.COERCEFULL] : re[t.COERCE]);\n } else {\n // Find the right-most coercible string that does not share\n // a terminus with a more left-ward coercible string.\n // Eg, '1.2.3.4' wants to coerce '2.3.4', not '3.4' or '4'\n // With includePrerelease option set, '1.2.3.4-rc' wants to coerce '2.3.4-rc', not '2.3.4'\n //\n // Walk through the string checking with a /g regexp\n // Manually set the index so as to pick up overlapping matches.\n // Stop when we get a match that ends at the string end, since no\n // coercible string can be more right-ward without the same terminus.\n const coerceRtlRegex = options.includePrerelease ? re[t.COERCERTLFULL] : re[t.COERCERTL];\n let next;\n while ((next = coerceRtlRegex.exec(version)) && (!match || match.index + match[0].length !== version.length)) {\n if (!match || next.index + next[0].length !== match.index + match[0].length) {\n match = next;\n }\n coerceRtlRegex.lastIndex = next.index + next[1].length + next[2].length;\n }\n // leave it in a clean state\n coerceRtlRegex.lastIndex = -1;\n }\n if (match === null) {\n return null;\n }\n const major = match[2];\n const minor = match[3] || '0';\n const patch = match[4] || '0';\n const prerelease = options.includePrerelease && match[5] ? `-${match[5]}` : '';\n const build = options.includePrerelease && match[6] ? `+${match[6]}` : '';\n return parse(`${major}.${minor}.${patch}${prerelease}${build}`, options);\n};\nmodule.exports = coerce;","map":{"version":3,"names":["SemVer","require","parse","safeRe","re","t","coerce","version","options","String","match","rtl","includePrerelease","COERCEFULL","COERCE","coerceRtlRegex","COERCERTLFULL","COERCERTL","next","exec","index","length","lastIndex","major","minor","patch","prerelease","build","module","exports"],"sources":["F:/workspace/202226701027/huinongbao-app/node_modules/semver/functions/coerce.js"],"sourcesContent":["const SemVer = require('../classes/semver')\nconst parse = require('./parse')\nconst { safeRe: re, t } = require('../internal/re')\n\nconst coerce = (version, options) => {\n if (version instanceof SemVer) {\n return version\n }\n\n if (typeof version === 'number') {\n version = String(version)\n }\n\n if (typeof version !== 'string') {\n return null\n }\n\n options = options || {}\n\n let match = null\n if (!options.rtl) {\n match = version.match(options.includePrerelease ? re[t.COERCEFULL] : re[t.COERCE])\n } else {\n // Find the right-most coercible string that does not share\n // a terminus with a more left-ward coercible string.\n // Eg, '1.2.3.4' wants to coerce '2.3.4', not '3.4' or '4'\n // With includePrerelease option set, '1.2.3.4-rc' wants to coerce '2.3.4-rc', not '2.3.4'\n //\n // Walk through the string checking with a /g regexp\n // Manually set the index so as to pick up overlapping matches.\n // Stop when we get a match that ends at the string end, since no\n // coercible string can be more right-ward without the same terminus.\n const coerceRtlRegex = options.includePrerelease ? re[t.COERCERTLFULL] : re[t.COERCERTL]\n let next\n while ((next = coerceRtlRegex.exec(version)) &&\n (!match || match.index + match[0].length !== version.length)\n ) {\n if (!match ||\n next.index + next[0].length !== match.index + match[0].length) {\n match = next\n }\n coerceRtlRegex.lastIndex = next.index + next[1].length + next[2].length\n }\n // leave it in a clean state\n coerceRtlRegex.lastIndex = -1\n }\n\n if (match === null) {\n return null\n }\n\n const major = match[2]\n const minor = match[3] || '0'\n const patch = match[4] || '0'\n const prerelease = options.includePrerelease && match[5] ? `-${match[5]}` : ''\n const build = options.includePrerelease && match[6] ? `+${match[6]}` : ''\n\n return parse(`${major}.${minor}.${patch}${prerelease}${build}`, options)\n}\nmodule.exports = coerce\n"],"mappings":"AAAA,MAAMA,MAAM,GAAGC,OAAO,CAAC,mBAAmB,CAAC;AAC3C,MAAMC,KAAK,GAAGD,OAAO,CAAC,SAAS,CAAC;AAChC,MAAM;EAAEE,MAAM,EAAEC,EAAE;EAAEC;AAAE,CAAC,GAAGJ,OAAO,CAAC,gBAAgB,CAAC;AAEnD,MAAMK,MAAM,GAAGA,CAACC,OAAO,EAAEC,OAAO,KAAK;EACnC,IAAID,OAAO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