1 | var _typeof = require("./typeof.js")["default"];
|
2 | var _WeakMap = require("core-js/library/fn/weak-map.js");
|
3 | var _Object$keys = require("core-js/library/fn/object/keys.js");
|
4 | var _Object$create = require("core-js/library/fn/object/create.js");
|
5 | var _Symbol$replace = require("core-js/library/fn/symbol/replace.js");
|
6 | var _Array$isArray = require("core-js/library/fn/array/is-array.js");
|
7 | var setPrototypeOf = require("./setPrototypeOf.js");
|
8 | var inherits = require("./inherits.js");
|
9 | function _wrapRegExp() {
|
10 | module.exports = _wrapRegExp = function _wrapRegExp(e, r) {
|
11 | return new BabelRegExp(e, void 0, r);
|
12 | }, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
13 | var e = RegExp.prototype,
|
14 | r = new _WeakMap();
|
15 | function BabelRegExp(e, t, p) {
|
16 | var o = RegExp(e, t);
|
17 | return r.set(o, p || r.get(e)), setPrototypeOf(o, BabelRegExp.prototype);
|
18 | }
|
19 | function buildGroups(e, t) {
|
20 | var p = r.get(t);
|
21 | return _Object$keys(p).reduce(function (r, t) {
|
22 | var o = p[t];
|
23 | if ("number" == typeof o) r[t] = e[o];else {
|
24 | for (var i = 0; void 0 === e[o[i]] && i + 1 < o.length;) i++;
|
25 | r[t] = e[o[i]];
|
26 | }
|
27 | return r;
|
28 | }, _Object$create(null));
|
29 | }
|
30 | return inherits(BabelRegExp, RegExp), BabelRegExp.prototype.exec = function (r) {
|
31 | var t = e.exec.call(this, r);
|
32 | if (t) {
|
33 | t.groups = buildGroups(t, this);
|
34 | var p = t.indices;
|
35 | p && (p.groups = buildGroups(p, this));
|
36 | }
|
37 | return t;
|
38 | }, BabelRegExp.prototype[_Symbol$replace] = function (t, p) {
|
39 | if ("string" == typeof p) {
|
40 | var o = r.get(this);
|
41 | return e[_Symbol$replace].call(this, t, p.replace(/\$<([^>]+)>/g, function (e, r) {
|
42 | var t = o[r];
|
43 | return "$" + (_Array$isArray(t) ? t.join("$") : t);
|
44 | }));
|
45 | }
|
46 | if ("function" == typeof p) {
|
47 | var i = this;
|
48 | return e[_Symbol$replace].call(this, t, function () {
|
49 | var e = arguments;
|
50 | return "object" != _typeof(e[e.length - 1]) && (e = [].slice.call(e)).push(buildGroups(e, i)), p.apply(this, e);
|
51 | });
|
52 | }
|
53 | return e[_Symbol$replace].call(this, t, p);
|
54 | }, _wrapRegExp.apply(this, arguments);
|
55 | }
|
56 | module.exports = _wrapRegExp, module.exports.__esModule = true, module.exports["default"] = module.exports; |
\ | No newline at end of file |