summaryrefslogtreecommitdiff
path: root/node_modules/@babel/runtime/helpers/esm/wrapRegExp.js
diff options
context:
space:
mode:
authorlittleblack111 <littleblack11111@gmail.com>2023-10-14 15:31:11 +0800
committerlittleblack111 <littleblack11111@gmail.com>2023-10-14 15:31:11 +0800
commitaa773172311dcada759dfbaac485f4bc6e00bc21 (patch)
treeca6d9a5eff3ab8f689f9acb4f0df791d9486813d /node_modules/@babel/runtime/helpers/esm/wrapRegExp.js
parentc5a5384e846f242e901e859fe600d695d8990a9a (diff)
added babel
Diffstat (limited to 'node_modules/@babel/runtime/helpers/esm/wrapRegExp.js')
-rw-r--r--node_modules/@babel/runtime/helpers/esm/wrapRegExp.js50
1 files changed, 50 insertions, 0 deletions
diff --git a/node_modules/@babel/runtime/helpers/esm/wrapRegExp.js b/node_modules/@babel/runtime/helpers/esm/wrapRegExp.js
new file mode 100644
index 00000000..f4cff77e
--- /dev/null
+++ b/node_modules/@babel/runtime/helpers/esm/wrapRegExp.js
@@ -0,0 +1,50 @@
+import _typeof from "./typeof.js";
+import setPrototypeOf from "./setPrototypeOf.js";
+import inherits from "./inherits.js";
+export default function _wrapRegExp() {
+ _wrapRegExp = function _wrapRegExp(e, r) {
+ return new BabelRegExp(e, void 0, r);
+ };
+ var e = RegExp.prototype,
+ r = new WeakMap();
+ function BabelRegExp(e, t, p) {
+ var o = new RegExp(e, t);
+ return r.set(o, p || r.get(e)), setPrototypeOf(o, BabelRegExp.prototype);
+ }
+ function buildGroups(e, t) {
+ var p = r.get(t);
+ return Object.keys(p).reduce(function (r, t) {
+ var o = p[t];
+ if ("number" == typeof o) r[t] = e[o];else {
+ for (var i = 0; void 0 === e[o[i]] && i + 1 < o.length;) i++;
+ r[t] = e[o[i]];
+ }
+ return r;
+ }, Object.create(null));
+ }
+ return inherits(BabelRegExp, RegExp), BabelRegExp.prototype.exec = function (r) {
+ var t = e.exec.call(this, r);
+ if (t) {
+ t.groups = buildGroups(t, this);
+ var p = t.indices;
+ p && (p.groups = buildGroups(p, this));
+ }
+ return t;
+ }, BabelRegExp.prototype[Symbol.replace] = function (t, p) {
+ if ("string" == typeof p) {
+ var o = r.get(this);
+ return e[Symbol.replace].call(this, t, p.replace(/\$<([^>]+)>/g, function (e, r) {
+ var t = o[r];
+ return "$" + (Array.isArray(t) ? t.join("$") : t);
+ }));
+ }
+ if ("function" == typeof p) {
+ var i = this;
+ return e[Symbol.replace].call(this, t, function () {
+ var e = arguments;
+ return "object" != _typeof(e[e.length - 1]) && (e = [].slice.call(e)).push(buildGroups(e, i)), p.apply(this, e);
+ });
+ }
+ return e[Symbol.replace].call(this, t, p);
+ }, _wrapRegExp.apply(this, arguments);
+} \ No newline at end of file