blob: 30149bf7ab16b60c68acf7b48945d1db8d1dfd31 [file] [log] [blame]
function e(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 n(e,t){return(n=Object.setPrototypeOf||function(e,n){return e.__proto__=n,e})(e,t)}function t(e,r,c){return(t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}()?Reflect.construct:function(e,t,r){var c=[null];c.push.apply(c,t);var u=new(Function.bind.apply(e,c));return r&&n(u,r.prototype),u}).apply(null,arguments)}function r(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")?"g":e.global?"g":"")+(n.includes("i")?"i":e.ignoreCase?"i":"")+(n.includes("m")?"m":e.multiline?"m":"")+(n.includes("u")?"u":e.sticky?"u":"")+(n.includes("y")?"y":e.sticky?"y":""))).lastIndex=t,e}var c=function(){function n(e,t,c){!function(e,n){if(!(e instanceof n))throw new TypeError("Cannot call a class as a function")}(this,n),this.regex=r("string"==typeof e?new RegExp(e):r(e),t||"",c)}var t,c,u;return t=n,(c=[{key:"forEach",value:function(e,n){for(var t,c,u=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,i=r(this.regex,"g"),l=0;null!==(t=i.exec(e));)c=t.splice(0,1),n.apply(u,t.concat(l++,c));return this}},{key:"some",value:function(e,n){for(var t,c,u=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,i=r(this.regex,"g"),l=0;null!==(t=i.exec(e));)if(c=t.splice(0,1),n.apply(u,t.concat(l++,c)))return!0;return!1}},{key:"every",value:function(e,n){for(var t,c,u=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,i=r(this.regex,"g"),l=0;null!==(t=i.exec(e));)if(c=t.splice(0,1),!n.apply(u,t.concat(l++,c)))return!1;return!0}},{key:"map",value:function(e,n){for(var t,c,u=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,i=[],l=r(this.regex,"g"),o=0;null!==(t=l.exec(e));)c=t.splice(0,1),i.push(n.apply(u,t.concat(o++,c)));return i}},{key:"filter",value:function(e,n){for(var t,c,u=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,i=0,l=[],o=r(this.regex,"g");null!==(t=o.exec(e));)c=t.splice(0,1),t=t.concat(i++,c),n.apply(u,t)&&l.push(c[0]);return l}},{key:"reduce",value:function(e,n,t){var c,u,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,l=0,o=r(this.regex,"g");for(t||null!==(c=o.exec(e))&&(u=c.splice(0,1),t=n.apply(i,[""].concat(c.concat(l++,u))));null!==(c=o.exec(e));)u=c.splice(0,1),t=n.apply(i,[t].concat(c.concat(l++,u)));return t}},{key:"reduceRight",value:function(e,n,t,c){var u,i,l,o=c,a=t,p=[],s=r(this.regex,"g");for(o=o||null;null!==(u=s.exec(e));)p.push(u);if(!(l=p.length)){if(arguments.length<3)throw new TypeError("reduce of empty matches array with no initial value");return a}return a||(u=p.splice(-1)[0],i=u.splice(0,1),a=n.apply(o,[""].concat(u.concat(l--,i)))),p.reduceRight((function(e,t){return i=t.splice(0,1),a=n.apply(o,[a].concat(t.concat(l--,i))),e}),p),a}},{key:"find",value:function(e,n){for(var t,c,u=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,i=0,l=r(this.regex,"g");null!==(t=l.exec(e));)if(c=t.splice(0,1),n.apply(u,t.concat(i++,c)))return c[0];return!1}},{key:"findIndex",value:function(e,n){for(var t,c=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,u=r(this.regex,"g"),i=0;null!==(t=u.exec(e));){var l=t.splice(0,1),o=n.apply(c,t.concat(i++,l));if(o)return i-1}return-1}},{key:"findExec",value:function(e,n){for(var t,c=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,u=r(this.regex,"g"),i=0;null!==(t=u.exec(e));){var l=t.splice(0,1),o=n.apply(c,t.concat(i++,l));if(o)return t}return!1}},{key:"filterExec",value:function(e,n){for(var t,c,u=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,i=0,l=[],o=r(this.regex,"g");null!==(t=o.exec(e));)c=t.splice(0,1),t.push(i++,c[0]),n.apply(u,t)&&l.push(t);return l}}])&&e(t.prototype,c),u&&e(t,u),n}(),u=c;(c=function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return t(u,n)}).prototype=u.prototype,c.mixinRegex=r,function(e){e.prototype.entries=regeneratorRuntime.mark((function n(t){var r,c,u;return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:c=0,u=e.mixinRegex(this.regex,"g");case 2:if(null===(r=u.exec(t))){n.next=7;break}return n.next=5,[c++,r];case 5:n.next=2;break;case 7:case"end":return n.stop()}}),n,this)})),e.prototype.values=regeneratorRuntime.mark((function n(t){var r,c;return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:c=e.mixinRegex(this.regex,"g");case 1:if(null===(r=c.exec(t))){n.next=6;break}return n.next=4,r;case 4:n.next=1;break;case 6:case"end":return n.stop()}}),n,this)})),e.prototype.keys=regeneratorRuntime.mark((function n(t){var r,c;return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:r=0,c=e.mixinRegex(this.regex,"g");case 2:if(null===c.exec(t)){n.next=7;break}return n.next=5,r++;case 5:n.next=2;break;case 7:case"end":return n.stop()}}),n,this)}))}(c);export{c as RegExtras,r as mixinRegex};