Created
June 12, 2017 12:07
-
-
Save helb/6c9edb53d73489f85390f82826c2b084 to your computer and use it in GitHub Desktop.
regex101 js worker
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// this is just unminified https://regex101.com/javascriptWorker.js | |
! function(e) { | |
function t(r) { | |
if (n[r]) return n[r].exports; | |
var o = n[r] = { | |
i: r, | |
l: !1, | |
exports: {} | |
}; | |
return e[r].call(o.exports, o, o.exports, t), o.l = !0, o.exports | |
} | |
var n = {}; | |
return t.m = e, t.c = n, t.i = function(e) { | |
return e | |
}, t.d = function(e, n, r) { | |
t.o(e, n) || Object.defineProperty(e, n, { | |
configurable: !1, | |
enumerable: !0, | |
get: r | |
}) | |
}, t.n = function(e) { | |
var n = e && e.__esModule ? function() { | |
return e.default | |
} : function() { | |
return e | |
}; | |
return t.d(n, "a", n), n | |
}, t.o = function(e, t) { | |
return Object.prototype.hasOwnProperty.call(e, t) | |
}, t.p = "/", t(t.s = 1312) | |
}({ | |
1312: function(e, t, n) { | |
e.exports = n(435) | |
}, | |
435: function(e, t) { | |
function n(e, t, n) { | |
for (var r = new RegExp(e, t), o = [], a = t.indexOf("g") !== -1, s = void 0; s = r.exec(n);) { | |
s.index === r.lastIndex && r.lastIndex++; | |
for (var i = [], u = 0; u < s.length; u++) { | |
var c = { | |
content: s[u], | |
groupNum: u, | |
isParticipating: void 0 !== s[u], | |
match: o.length | |
}; | |
0 === u && (c.start = s.index, c.end = s.index + s[0].length), i.push(c) | |
} | |
if (o.push(i), !a) break | |
} | |
return { | |
matchResult: o | |
} | |
} | |
self.onmessage = function(e) { | |
self.postMessage("onload"); | |
try { | |
var t = new Date, | |
r = n(e.data.regex, e.data.flags, e.data.testString); | |
r.time = new Date - t, self.postMessage(r) | |
} catch (e) { | |
self.postMessage({ | |
error: e.message | |
}) | |
} | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment