From 23b60dc1975db38c280d8a123aff97544d1673e0 Mon Sep 17 00:00:00 2001 From: HelenHuang <LinHuang@pollex.com.tw> Date: 星期四, 09 六月 2022 15:34:21 +0800 Subject: [PATCH] TODO#139890 FAQ 常見問題 1-文案調整 --- PAMapp/node_modules/core-js/modules/es.string.replace.js | 31 +++++++++++++++++++------------ 1 files changed, 19 insertions(+), 12 deletions(-) diff --git a/PAMapp/node_modules/core-js/modules/es.string.replace.js b/PAMapp/node_modules/core-js/modules/es.string.replace.js index 4e310b0..5a1d3d4 100644 --- a/PAMapp/node_modules/core-js/modules/es.string.replace.js +++ b/PAMapp/node_modules/core-js/modules/es.string.replace.js @@ -1,4 +1,7 @@ 'use strict'; +var apply = require('../internals/function-apply'); +var call = require('../internals/function-call'); +var uncurryThis = require('../internals/function-uncurry-this'); var fixRegExpWellKnownSymbolLogic = require('../internals/fix-regexp-well-known-symbol-logic'); var fails = require('../internals/fails'); var anObject = require('../internals/an-object'); @@ -16,6 +19,10 @@ var REPLACE = wellKnownSymbol('replace'); var max = Math.max; var min = Math.min; +var concat = uncurryThis([].concat); +var push = uncurryThis([].push); +var stringIndexOf = uncurryThis(''.indexOf); +var stringSlice = uncurryThis(''.slice); var maybeToString = function (it) { return it === undefined ? it : String(it); @@ -58,8 +65,8 @@ var O = requireObjectCoercible(this); var replacer = searchValue == undefined ? undefined : getMethod(searchValue, REPLACE); return replacer - ? replacer.call(searchValue, O, replaceValue) - : nativeReplace.call(toString(O), searchValue, replaceValue); + ? call(replacer, searchValue, O, replaceValue) + : call(nativeReplace, toString(O), searchValue, replaceValue); }, // `RegExp.prototype[@@replace]` method // https://tc39.es/ecma262/#sec-regexp.prototype-@@replace @@ -68,9 +75,9 @@ var S = toString(string); if ( - typeof replaceValue === 'string' && - replaceValue.indexOf(UNSAFE_SUBSTITUTE) === -1 && - replaceValue.indexOf('$<') === -1 + typeof replaceValue == 'string' && + stringIndexOf(replaceValue, UNSAFE_SUBSTITUTE) === -1 && + stringIndexOf(replaceValue, '$<') === -1 ) { var res = maybeCallNative(nativeReplace, rx, S, replaceValue); if (res.done) return res.value; @@ -89,7 +96,7 @@ var result = regExpExec(rx, S); if (result === null) break; - results.push(result); + push(results, result); if (!global) break; var matchStr = toString(result[0]); @@ -109,21 +116,21 @@ // but for some reason `nativeSlice.call(result, 1, result.length)` (called in // the slice polyfill when slicing native arrays) "doesn't work" in safari 9 and // causes a crash (https://pastebin.com/N21QzeQA) when trying to debug it. - for (var j = 1; j < result.length; j++) captures.push(maybeToString(result[j])); + for (var j = 1; j < result.length; j++) push(captures, maybeToString(result[j])); var namedCaptures = result.groups; if (functionalReplace) { - var replacerArgs = [matched].concat(captures, position, S); - if (namedCaptures !== undefined) replacerArgs.push(namedCaptures); - var replacement = toString(replaceValue.apply(undefined, replacerArgs)); + var replacerArgs = concat([matched], captures, position, S); + if (namedCaptures !== undefined) push(replacerArgs, namedCaptures); + var replacement = toString(apply(replaceValue, undefined, replacerArgs)); } else { replacement = getSubstitution(matched, S, position, captures, namedCaptures, replaceValue); } if (position >= nextSourcePosition) { - accumulatedResult += S.slice(nextSourcePosition, position) + replacement; + accumulatedResult += stringSlice(S, nextSourcePosition, position) + replacement; nextSourcePosition = position + matched.length; } } - return accumulatedResult + S.slice(nextSourcePosition); + return accumulatedResult + stringSlice(S, nextSourcePosition); } ]; }, !REPLACE_SUPPORTS_NAMED_GROUPS || !REPLACE_KEEPS_$0 || REGEXP_REPLACE_SUBSTITUTES_UNDEFINED_CAPTURE); -- Gitblit v1.8.0