mirror of
https://github.com/react/react-native-devtools-frontend.git
synced 2026-09-30 17:27:22 +08:00
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>
54 lines
2.0 KiB
JavaScript
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);
|