Files
react-native-devtools-frontend/node_modules/core-js/modules/esnext.string.replace-all.js
T
Lorne Mitchell db3885dd80 Revert "Updates node_modules and update script"
This reverts commit 4df552c652.

Reason for revert: Breaks esprima.

Original change's description:
> Updates node_modules and update script
> 
> Change-Id: I3fcf49bc416301a030d298cfc48c448bfeba4335
> Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/1878808
> Reviewed-by: Tim van der Lippe <tvanderlippe@chromium.org>
> Reviewed-by: Yang Guo <yangguo@chromium.org>
> Commit-Queue: Paul Lewis <aerotwist@chromium.org>

TBR=yangguo@chromium.org,aerotwist@chromium.org,tvanderlippe@chromium.org

Change-Id: Iad2bcdf98a486476715d1e829cdce450c5f218af
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/1880098
Reviewed-by: Lorne Mitchell <lomitch@microsoft.com>
Commit-Queue: Lorne Mitchell <lomitch@microsoft.com>
2019-10-24 21:53:24 +00:00

54 lines
2.0 KiB
JavaScript

'use strict';
var $ = require('../internals/export');
var hide = require('../internals/hide');
var requireObjectCoercible = require('../internals/require-object-coercible');
var anObject = require('../internals/an-object');
var isRegExp = require('../internals/is-regexp');
var getRegExpFlags = require('../internals/regexp-flags');
var speciesConstructor = require('../internals/species-constructor');
var wellKnownSymbol = require('../internals/well-known-symbol');
var IS_PURE = require('../internals/is-pure');
var REPLACE_ALL = wellKnownSymbol('replaceAll');
var RegExpPrototype = RegExp.prototype;
var $replaceAll = function (string, replaceValue) {
var rx = anObject(this);
var flags = String('flags' in RegExpPrototype ? rx.flags : getRegExpFlags.call(rx));
if (!~flags.indexOf('g')) {
rx = new (speciesConstructor(rx, RegExp))(rx.source, flags + 'g');
}
return String(string).replace(rx, replaceValue);
};
// `String.prototype.replaceAll` method
// https://github.com/tc39/proposal-string-replace-all
$({ target: 'String', proto: true }, {
replaceAll: function replaceAll(searchValue, replaceValue) {
var O = requireObjectCoercible(this);
var replacer, string, searchString, template, result, index;
if (searchValue != null) {
replacer = searchValue[REPLACE_ALL];
if (replacer !== undefined) {
return replacer.call(searchValue, O, replaceValue);
} else if (IS_PURE && isRegExp(searchValue)) {
return $replaceAll.call(searchValue, O, replaceValue);
}
}
string = String(O);
searchString = String(searchValue);
template = string.split(searchString);
if (typeof replaceValue !== 'function') {
return template.join(String(replaceValue));
}
result = template[0];
for (index = 1; index < template.length; index++) {
result += String(replaceValue(searchString, index - 1, string));
result += template[index];
}
return result;
}
});
IS_PURE || REPLACE_ALL in RegExpPrototype || hide(RegExpPrototype, REPLACE_ALL, $replaceAll);