1 |
- !function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((e="undefined"!=typeof globalThis?globalThis:e||self).RegExtras={})}(this,(function(e){"use strict";function n(e,n){for(var t=0;t<n.length;t++){var r=n[t];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function t(e,n){return(t=Object.setPrototypeOf||function(e,n){return e.__proto__=n,e})(e,n)}function r(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}function u(e,n,c){return(u=r()?Reflect.construct:function(e,n,r){var u=[null];u.push.apply(u,n);var c=new(Function.bind.apply(e,u));return r&&t(c,r.prototype),c}).apply(null,arguments)}function c(e,n){var t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:e.lastIndex;return n=n||"",(e=new RegExp(e.source,(n.includes("g")||e.global?"g":"")+(n.includes("i")||e.ignoreCase?"i":"")+(n.includes("m")||e.multiline?"m":"")+(n.includes("u")||e.unicode?"u":"")+(n.includes("y")||e.sticky?"y":"")+(n.includes("s")||e.dotAll?"s":""))).lastIndex=t,e}e.RegExtras=function(){function e(n,t,r){!function(e,n){if(!(e instanceof n))throw new TypeError("Cannot call a class as a function")}(this,e),this.regex=c("string"==typeof n?new RegExp(n):c(n),t||"",r)}var t,r,u;return t=e,(r=[{key:"forEach",value:function(e,n){for(var t,r,u=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,i=c(this.regex,"g"),l=0;null!==(t=i.exec(e));)r=t.splice(0,1),n.apply(u,t.concat(l++,r));return this}},{key:"some",value:function(e,n){for(var t,r,u=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,i=c(this.regex,"g"),l=0;null!==(t=i.exec(e));)if(r=t.splice(0,1),n.apply(u,t.concat(l++,r)))return!0;return!1}},{key:"every",value:function(e,n){for(var t,r,u=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,i=c(this.regex,"g"),l=0;null!==(t=i.exec(e));)if(r=t.splice(0,1),!n.apply(u,t.concat(l++,r)))return!1;return!0}},{key:"map",value:function(e,n){for(var t,r,u=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,i=[],l=c(this.regex,"g"),o=0;null!==(t=l.exec(e));)r=t.splice(0,1),i.push(n.apply(u,t.concat(o++,r)));return i}},{key:"filter",value:function(e,n){for(var t,r,u=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,i=0,l=[],o=c(this.regex,"g");null!==(t=o.exec(e));)r=t.splice(0,1),t=t.concat(i++,r),n.apply(u,t)&&l.push(r[0]);return l}},{key:"reduce",value:function(e,n,t){var r,u,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,l=0,o=c(this.regex,"g");for(t||null!==(r=o.exec(e))&&(u=r.splice(0,1),t=n.apply(i,[""].concat(r.concat(l++,u))));null!==(r=o.exec(e));)u=r.splice(0,1),t=n.apply(i,[t].concat(r.concat(l++,u)));return t}},{key:"reduceRight",value:function(e,n,t,r){var u,i,l,o=r,a=t,s=[],f=c(this.regex,"g");for(o=o||null;null!==(u=f.exec(e));)s.push(u);if(!(l=s.length)){if(arguments.length<3)throw new TypeError("reduce of empty matches array with no initial value");return a}return a||(u=s.splice(-1)[0],i=u.splice(0,1),a=n.apply(o,[""].concat(u.concat(l--,i)))),s.reduceRight((function(e,t){return i=t.splice(0,1),a=n.apply(o,[a].concat(t.concat(l--,i))),e}),s),a}},{key:"find",value:function(e,n){for(var t,r,u=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,i=0,l=c(this.regex,"g");null!==(t=l.exec(e));)if(r=t.splice(0,1),n.apply(u,t.concat(i++,r)))return r[0];return!1}},{key:"findIndex",value:function(e,n){for(var t,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,u=c(this.regex,"g"),i=0;null!==(t=u.exec(e));){var l=t.splice(0,1),o=n.apply(r,t.concat(i++,l));if(o)return i-1}return-1}},{key:"findExec",value:function(e,n){for(var t,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,u=c(this.regex,"g"),i=0;null!==(t=u.exec(e));){var l=t.splice(0,1),o=n.apply(r,t.concat(i++,l));if(o)return t}return!1}},{key:"filterExec",value:function(e,n){for(var t,r,u=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,i=0,l=[],o=c(this.regex,"g");null!==(t=o.exec(e));)r=t.splice(0,1),t.push(i++,r[0]),n.apply(u,t)&&l.push(t);return l}}])&&n(t.prototype,r),u&&n(t,u),e}();var i,l=e.RegExtras;e.RegExtras=function(){for(var e=arguments.length,n=new Array(e),t=0;t<e;t++)n[t]=arguments[t];return u(l,n)},e.RegExtras.prototype=l.prototype,e.RegExtras.mixinRegex=c,(i=e.RegExtras).prototype.entries=regeneratorRuntime.mark((function e(n){var t,r,u;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=0,u=i.mixinRegex(this.regex,"g");case 2:if(null===(t=u.exec(n))){e.next=7;break}return e.next=5,[r++,t];case 5:e.next=2;break;case 7:case"end":return e.stop()}}),e,this)})),i.prototype.values=regeneratorRuntime.mark((function e(n){var t,r;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=i.mixinRegex(this.regex,"g");case 1:if(null===(t=r.exec(n))){e.next=6;break}return e.next=4,t;case 4:e.next=1;break;case 6:case"end":return e.stop()}}),e,this)})),i.prototype.keys=regeneratorRuntime.mark((function e(n){var t,r;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=0,r=i.mixinRegex(this.regex,"g");case 2:if(null===r.exec(n)){e.next=7;break}return e.next=5,t++;case 5:e.next=2;break;case 7:case"end":return e.stop()}}),e,this)})),e.mixinRegex=c,Object.defineProperty(e,"__esModule",{value:!0})}));
|