@knighttower/utility
Advanced tools
Comparing version 7.20.0 to 7.21.0
@@ -1,1 +0,1 @@ | ||
(()=>{"use strict";var r={d:(t,n)=>{for(var e in n){r.o(n,e)&&!r.o(t,e)&&Object.defineProperty(t,e,{enumerable:!0,get:n[e]})}},o:(r,t)=>Object.prototype.hasOwnProperty.call(r,t),r:r=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(r,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(r,"__esModule",{value:!0})}},t={};function n(r,t){var n="undefined"!=typeof Symbol&&r[Symbol.iterator]||r["@@iterator"];if(!n){if(Array.isArray(r)||(n=function(r,t){if(r){if("string"==typeof r){return e(r,t)}var n={}.toString.call(r).slice(8,-1);return"Object"===n&&r.constructor&&(n=r.constructor.name),"Map"===n||"Set"===n?Array.from(r):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?e(r,t):void 0}}(r))||t&&r&&"number"==typeof r.length){n&&(r=n);var o=0,i=function(){};return{s:i,n:function(){return o>=r.length?{done:!0}:{done:!1,value:r[o++]}},e:function(r){throw r},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,u=!0,c=!1;return{s:function(){n=n.call(r)},n:function(){var r=n.next();return u=r.done,r},e:function(r){c=!0,a=r},f:function(){try{u||null==n.return||n.return()}finally{if(c){throw a}}}}}function e(r,t){(null==t||t>r.length)&&(t=r.length);for(var n=0,e=Array(t);n<t;n++){e[n]=r[n]}return e}function o(r){return o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(r){return typeof r}:function(r){return r&&"function"==typeof Symbol&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},o(r)}function i(r){switch(o(r)){case"boolean":return r;case"string":return"false"!==r&&"0"!==r;case"number":return 0!==r;default:return Boolean(r)}}function a(r){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return null!==s(r)||"boolean"==typeof r?r:f(r)?t:r}r.r(t),r.d(t,{addQuotes:()=>m,cleanStr:()=>p,convertKeysToSymbols:()=>h,findAndReplaceInArray:()=>S,findNested:()=>w,fixQuotes:()=>A,getArrObjFromString:()=>O,getChunks:()=>x,getDirectivesFromString:()=>E,getMatchBlock:()=>_,getMatchInBetween:()=>k,getObjectFromPath:()=>j,removeQuotes:()=>I,setExpString:()=>P,setLookUpExp:()=>T,setWildCardString:()=>$,startAndEndWith:()=>M,wildCardStringSearch:()=>N});var u=function(){var r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:20;r=r||40;for(var t="",n=0;n<r/3+1;n++){t+=Math.random().toString(36).substring(2,15)}return t.substring(0,r)};function c(){return"id__"+u(8)+"__"+(new Date).getTime()}var l=c;function f(r){return null==r||("string"==typeof r||Array.isArray(r)?0===r.length:r instanceof Map||r instanceof Set?0===r.size:ArrayBuffer.isView(r)?0===r.byteLength:"object"===o(r)&&0===Object.keys(r).length)}function s(r){var t=o(r);switch(r){case null:case void 0:case"":return null;case"0":case 0:return 0;default:if(!("number"!==t&&"string"!==t||"number"!=typeof r&&Number.isNaN(Number(r)))){return+r}}return null}function y(r,t){if(null===r){return t?null===t||"null"===t:"null"}var e;switch(o(r)){case"number":case"string":case"boolean":case"undefined":case"bigint":case"symbol":case"function":e=o(r);break;case"object":e=Array.isArray(r)?"array":"object";break;default:e="unknown"}if(t){if(t.includes("|")){var i,a=n(t.split("|"));try{for(a.s();!(i=a.n()).done;){var u=i.value;if(e===u){return u}}}catch(r){a.e(r)}finally{a.f()}return!1}return t===e}return e}function v(r,t){return function(r){if(Array.isArray(r)){return r}}(r)||function(r,t){var n=null==r?null:"undefined"!=typeof Symbol&&r[Symbol.iterator]||r["@@iterator"];if(null!=n){var e,o,i,a,u=[],c=!0,l=!1;try{if(i=(n=n.call(r)).next,0===t){if(Object(n)!==n){return}c=!1}else{for(;!(c=(e=i.call(n)).done)&&(u.push(e.value),u.length!==t);c=!0){}}}catch(r){l=!0,o=r}finally{try{if(!c&&null!=n.return&&(a=n.return(),Object(a)!==a)){return}}finally{if(l){throw o}}}return u}}(r,t)||function(r,t){if(r){if("string"==typeof r){return g(r,t)}var n={}.toString.call(r).slice(8,-1);return"Object"===n&&r.constructor&&(n=r.constructor.name),"Map"===n||"Set"===n?Array.from(r):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?g(r,t):void 0}}(r,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function g(r,t){(null==t||t>r.length)&&(t=r.length);for(var n=0,e=Array(t);n<t;n++){e[n]=r[n]}return e}function d(r,t,n){return(t=function(r){var t=function(r,t){if("object"!=b(r)||!r){return r}var n=r[Symbol.toPrimitive];if(void 0!==n){var e=n.call(r,t||"default");if("object"!=b(e)){return e}throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(r)}(r,"string");return"symbol"==b(t)?t:t+""}(t))in r?Object.defineProperty(r,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):r[t]=n,r}function b(r){return b="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(r){return typeof r}:function(r){return r&&"function"==typeof Symbol&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},b(r)}function m(r){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:'"';return"".concat(t).concat(r).concat(t)}function p(r){if(r){if("string"!=typeof r){return r}for(var t=arguments.length,n=new Array(t>1?t-1:0),e=1;e<t;e++){n[e-1]=arguments[e]}return n.reduce((function(r,t){var n=t instanceof RegExp?t:new RegExp(P(t));return r.replace(n,"")}),r).trim()}}function h(r){if(null===a(r,null)){return{}}var t={},n={};for(var e in r){var o=Symbol(e);t[o]=r[e],n[e]=o}return t.keyToSymbolMap=n,t}function S(r,t,n){var e=!1,o=r.map((function(r){if(Array.isArray(r)){var o=S(r,t,n);return o?(e=!0,o):r}return r===t?(e=!0,Array.isArray(n)?n.map((function(r){return Array.isArray(r)?r:r.trim()})):n):r}));return e?o:null}function w(r){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"[",n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"]";if("string"!=typeof r){return r}var e=r.lastIndexOf(t);if(-1===e){return null}var o=r.substring(e),i=o.indexOf(n);return-1===i?null:o.substring(0,i+1)}function A(r){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:'"';return"string"!=typeof r?r:r.replace(/`|'|"/g,t)}function j(r){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:window;return r.split(".").reduce((function(r,t){return r&&r[t]}),t)}function O(r){if(y(r,"object")||y(r,"array")){return r}var t=M(r,"{","}"),n=M(r,"[","]");if(!t&&!n){return r}var e=t?{}:[],o={},i=function(r){var t=r.match(/^(\[|\{)(.*?)(\]|\})$/);return t?t[2].trim():r}(r),u=function(){for(var r=arguments.length>0&&void 0!==arguments[0]&&arguments[0];;){var t=r?w(i,"{","}"):w(i);if(!t){break}var n="__".concat(l(),"__");o[n]=t,i=i.replace(t,n)}};return u(),u(!0),x(i).forEach((function(r,n){var i,u,c=r.includes(":")&&t,l=c?x(r,":"):[],f=I(a(l[0],n));(r=c?l[1]:r)in o&&(r=O(o[r])),i=I(r),r=null!==(u=s(i))?u:i,t?e[f]=r:e.push(r)})),e}function E(r){var t=r;if(!a(t)){return null}var n=function(){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return{type:arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,directive:r}},e=/([a-zA-Z]+)\[((.|\n)*?)\]\(((.|\n)*?)\)/gm,o=b(t);if("object"===o||"array"===o){return n(o,t)}switch(!0){case!!t.match(/^\[((.|\n)*?)\]$/gm):o="array";break;case!!t.match(/^\{((.|\n)*?)\:((.|\n)*?)\}/gm):o="object";break;case!!t.match(/^([a-zA-Z]+)(\()(\.|\#)(.*)(\))/g):return n("idOrClassWithDirective",d({},t.split("(")[0].trim(),k(t,"(",")")));case!!t.match(/([a-zA-Z]+)\.(.*?)\(((.|\n)*?)\)/gm):case!!t.match(e):o="dotObject";break;default:return n("string",t)}if("array"===o||"object"===o){var i=A(t);try{return n(o,JSON.parse(i))}catch(r){}return n(o,O(i))}if("dotObject"===o){var u,c,l,f={};return x(t,"&&").forEach((function(r){if(r.match(e)){u=k(r,"](",")"),c=k(r,"[","]"),l=r.split("[")[0].trim()}else{u=k(r,"(",")");var t=v(x(r=r.replace(_(r,"(",")"),""),"."),2);l=t[0],c=t[1]}u=O(u),f[l]||(f[l]={}),x(c,"|").forEach((function(r){f[l][r]=u}))})),n("dotObject",f)}}function _(r,t,n){var e=arguments.length>3&&void 0!==arguments[3]&&arguments[3];if("string"!=typeof r){return r}t=P(t),n=P(n);var o=new RegExp(T(t,n),"gm"),i=r.match(o);return i?e?i:i[0]:null}function x(r){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:",";if("string"!=typeof r){return r}if(f(r)){return[]}var n=(r=p(r)).split(t).map((function(r){return p(r)}));return 1===n.length&&""===n[0]?[r]:n}function k(r,t,n){var e,o=arguments.length>3&&void 0!==arguments[3]&&arguments[3];if("string"!=typeof r){return r}var i=null!==(e=_(r,t,n,o))&&void 0!==e?e:o?[]:r;return o?i.map((function(r){return p(r,t,n)})):p(i,t,n)}function I(r){return"string"!=typeof r?r:r.replace(/`|'|"/g,"")}function M(r){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;return(!t||r.startsWith(t))&&(!n||r.endsWith(n))}function P(r){return r instanceof RegExp?r:r.split("").map((function(r){return["$","^",".","*","+","?","(",")","[","]","{","}","|","\\"].includes(r)?"\\".concat(r):r})).join("")}function T(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}if(t.length<2){throw new Error("You need to pass at least two arguments")}var e="";return t.forEach((function(r,t){r instanceof RegExp&&(r=r.source),0===t?e=r:e+="((.|\n)*?)".concat(r)})),e}function $(r){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if("string"!=typeof r){return r}if(!r){return null}t=i(t),n=i(n);var e=r.replace(/([.+?^${}()|\[\]\/\\])/g,"\\$&"),o=t?"^":"",a=n?"$":"";return e=e.replace(/\*\*/g,"[_g_]").replace(/\*/g,"(.*?)").replace(/\[_g_\]/g,".*"),"".concat(o).concat(e).concat(a)}function N(r,t){if(!r||!t){return null}var n=new RegExp($(r,arguments.length>2&&void 0!==arguments[2]&&arguments[2],arguments.length>3&&void 0!==arguments[3]&&arguments[3]));if("string"==typeof t){return a(t.match(n))}return a(t.filter((function(r){return n.test(r)})))}window.powerHelper=t})(); | ||
(()=>{"use strict";var r={d:(t,n)=>{for(var e in n){r.o(n,e)&&!r.o(t,e)&&Object.defineProperty(t,e,{enumerable:!0,get:n[e]})}},o:(r,t)=>Object.prototype.hasOwnProperty.call(r,t),r:r=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(r,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(r,"__esModule",{value:!0})}},t={};function n(r,t){var n="undefined"!=typeof Symbol&&r[Symbol.iterator]||r["@@iterator"];if(!n){if(Array.isArray(r)||(n=function(r,t){if(r){if("string"==typeof r){return e(r,t)}var n={}.toString.call(r).slice(8,-1);return"Object"===n&&r.constructor&&(n=r.constructor.name),"Map"===n||"Set"===n?Array.from(r):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?e(r,t):void 0}}(r))||t&&r&&"number"==typeof r.length){n&&(r=n);var o=0,i=function(){};return{s:i,n:function(){return o>=r.length?{done:!0}:{done:!1,value:r[o++]}},e:function(r){throw r},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var u,a=!0,c=!1;return{s:function(){n=n.call(r)},n:function(){var r=n.next();return a=r.done,r},e:function(r){c=!0,u=r},f:function(){try{a||null==n.return||n.return()}finally{if(c){throw u}}}}}function e(r,t){(null==t||t>r.length)&&(t=r.length);for(var n=0,e=Array(t);n<t;n++){e[n]=r[n]}return e}function o(r){return o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(r){return typeof r}:function(r){return r&&"function"==typeof Symbol&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},o(r)}function i(r){switch(o(r)){case"boolean":return r;case"string":return"false"!==r&&"0"!==r;case"number":return 0!==r;default:return Boolean(r)}}function u(r){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return null!==s(r)||"boolean"==typeof r?r:f(r)?t:r}r.r(t),r.d(t,{addQuotes:()=>S,cleanStr:()=>w,convertKeysToSymbols:()=>A,findAndReplaceInArray:()=>j,findNested:()=>O,fixQuotes:()=>E,getArrObjFromString:()=>x,getChunks:()=>T,getDirectivesFromString:()=>P,getMatchBlock:()=>k,getMatchInBetween:()=>I,getObjectFromPath:()=>_,getObjectValue:()=>h,removeQuotes:()=>M,setExpString:()=>N,setLookUpExp:()=>R,setWildCardString:()=>C,startAndEndWith:()=>$,wildCardStringSearch:()=>B});var a=function(){var r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:20;r=r||40;for(var t="",n=0;n<r/3+1;n++){t+=Math.random().toString(36).substring(2,15)}return t.substring(0,r)};function c(){return"id__"+a(8)+"__"+(new Date).getTime()}var l=c;function f(r){return null==r||("string"==typeof r||Array.isArray(r)?0===r.length:r instanceof Map||r instanceof Set?0===r.size:ArrayBuffer.isView(r)?0===r.byteLength:"object"===o(r)&&0===Object.keys(r).length)}function s(r){var t=o(r);switch(r){case null:case void 0:case"":return null;case"0":case 0:return 0;default:if(!("number"!==t&&"string"!==t||"number"!=typeof r&&Number.isNaN(Number(r)))){return+r}}return null}function y(r,t){if(null===r){return t?null===t||"null"===t:"null"}var e;switch(o(r)){case"number":case"string":case"boolean":case"undefined":case"bigint":case"symbol":case"function":e=o(r);break;case"object":e=Array.isArray(r)?"array":"object";break;default:e="unknown"}if(t){if(t.includes("|")){var i,u=n(t.split("|"));try{for(u.s();!(i=u.n()).done;){var a=i.value;if(e===a){return a}}}catch(r){u.e(r)}finally{u.f()}return!1}return t===e}return e}function v(r){return v="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(r){return typeof r}:function(r){return r&&"function"==typeof Symbol&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},v(r)}var m=function(r){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if("function"!=typeof r&&"object"!==v(r)){throw new Error("doPoll: The first argument must be a function or Promise.")}var n,e,o,i,u=function(r){return r instanceof Promise},a=t.interval,c=void 0===a?200:a,l=t.timeout,f=void 0===l?1e3:l,s=t.timeoutMsg,y=void 0===s?"===> doPoll: cancelled or timed out.":s,m=!1,g=!1,d=function(){b(),i(console.info(y))},p=function(r){b(),o(r)};function b(){m=!0,clearTimeout(n),clearInterval(e)}var h=new Promise((function(t,a){o=t,i=a;var l=function(){if(!m&&!g){var t=u(r)?r:r();u(t)?(g=!0,t.then((function(r){g=!1,r&&p(r)})).catch(i)):(Boolean(t)||t)&&p(t)}};e=setInterval(l,c),l(),n=setTimeout((function(){m||d()}),f)}));return h.catch((function(){d()})),{promise:h,stop:d}};function g(r,t){return function(r){if(Array.isArray(r)){return r}}(r)||function(r,t){var n=null==r?null:"undefined"!=typeof Symbol&&r[Symbol.iterator]||r["@@iterator"];if(null!=n){var e,o,i,u,a=[],c=!0,l=!1;try{if(i=(n=n.call(r)).next,0===t){if(Object(n)!==n){return}c=!1}else{for(;!(c=(e=i.call(n)).done)&&(a.push(e.value),a.length!==t);c=!0){}}}catch(r){l=!0,o=r}finally{try{if(!c&&null!=n.return&&(u=n.return(),Object(u)!==u)){return}}finally{if(l){throw o}}}return a}}(r,t)||function(r,t){if(r){if("string"==typeof r){return d(r,t)}var n={}.toString.call(r).slice(8,-1);return"Object"===n&&r.constructor&&(n=r.constructor.name),"Map"===n||"Set"===n?Array.from(r):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?d(r,t):void 0}}(r,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function d(r,t){(null==t||t>r.length)&&(t=r.length);for(var n=0,e=Array(t);n<t;n++){e[n]=r[n]}return e}function p(r,t,n){return(t=function(r){var t=function(r,t){if("object"!=b(r)||!r){return r}var n=r[Symbol.toPrimitive];if(void 0!==n){var e=n.call(r,t||"default");if("object"!=b(e)){return e}throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(r)}(r,"string");return"symbol"==b(t)?t:t+""}(t))in r?Object.defineProperty(r,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):r[t]=n,r}function b(r){return b="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(r){return typeof r}:function(r){return r&&"function"==typeof Symbol&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},b(r)}function h(r,t,n,e){var o=e||{},i=o.queryTime,u=void 0===i?15e3:i,a=o.isFalsy,c=void 0!==a&&a;if("function"==typeof n&&m((function(){var e=h(r,t);return c&&!1===e||e?n(e):void 0}),{timeout:u,interval:100,timeoutMsg:"Object prop no found:"+t}),!r){return!1}for(var l in r){if(l===t){return r[l]}if("object"===b(r[l])){var f=h(r[l],t);return f||!1}}return!1}function S(r){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:'"';return"".concat(t).concat(r).concat(t)}function w(r){if(r){if("string"!=typeof r){return r}for(var t=arguments.length,n=new Array(t>1?t-1:0),e=1;e<t;e++){n[e-1]=arguments[e]}return n.reduce((function(r,t){var n=t instanceof RegExp?t:new RegExp(N(t));return r.replace(n,"")}),r).trim()}}function A(r){if(null===u(r,null)){return{}}var t={},n={};for(var e in r){var o=Symbol(e);t[o]=r[e],n[e]=o}return t.keyToSymbolMap=n,t}function j(r,t,n){var e=!1,o=r.map((function(r){if(Array.isArray(r)){var o=j(r,t,n);return o?(e=!0,o):r}return r===t?(e=!0,Array.isArray(n)?n.map((function(r){return Array.isArray(r)?r:r.trim()})):n):r}));return e?o:null}function O(r){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"[",n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"]";if("string"!=typeof r){return r}var e=r.lastIndexOf(t);if(-1===e){return null}var o=r.substring(e),i=o.indexOf(n);return-1===i?null:o.substring(0,i+1)}function E(r){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:'"';return"string"!=typeof r?r:r.replace(/`|'|"/g,t)}function _(r){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:window;return r.split(".").reduce((function(r,t){return r&&r[t]}),t)}function x(r){if(y(r,"object")||y(r,"array")){return r}var t=$(r,"{","}"),n=$(r,"[","]");if(!t&&!n){return r}var e=t?{}:[],o={},i=function(r){var t=r.match(/^(\[|\{)(.*?)(\]|\})$/);return t?t[2].trim():r}(r),a=function(){for(var r=arguments.length>0&&void 0!==arguments[0]&&arguments[0];;){var t=r?O(i,"{","}"):O(i);if(!t){break}var n="__".concat(l(),"__");o[n]=t,i=i.replace(t,n)}};return a(),a(!0),T(i).forEach((function(r,n){var i,a,c=r.includes(":")&&t,l=c?T(r,":"):[],f=M(u(l[0],n));(r=c?l[1]:r)in o&&(r=x(o[r])),i=M(r),r=null!==(a=s(i))?a:i,t?e[f]=r:e.push(r)})),e}function P(r){var t=r;if(!u(t)){return null}var n=function(){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return{type:arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,directive:r}},e=/([a-zA-Z]+)\[((.|\n)*?)\]\(((.|\n)*?)\)/gm,o=b(t);if("object"===o||"array"===o){return n(o,t)}switch(!0){case!!t.match(/^\[((.|\n)*?)\]$/gm):o="array";break;case!!t.match(/^\{((.|\n)*?)\:((.|\n)*?)\}/gm):o="object";break;case!!t.match(/^([a-zA-Z]+)(\()(\.|\#)(.*)(\))/g):return n("idOrClassWithDirective",p({},t.split("(")[0].trim(),I(t,"(",")")));case!!t.match(/([a-zA-Z]+)\.(.*?)\(((.|\n)*?)\)/gm):case!!t.match(e):o="dotObject";break;default:return n("string",t)}if("array"===o||"object"===o){var i=E(t);try{return n(o,JSON.parse(i))}catch(r){}return n(o,x(i))}if("dotObject"===o){var a,c,l,f={};return T(t,"&&").forEach((function(r){if(r.match(e)){a=I(r,"](",")"),c=I(r,"[","]"),l=r.split("[")[0].trim()}else{a=I(r,"(",")");var t=g(T(r=r.replace(k(r,"(",")"),""),"."),2);l=t[0],c=t[1]}a=x(a),f[l]||(f[l]={}),T(c,"|").forEach((function(r){f[l][r]=a}))})),n("dotObject",f)}}function k(r,t,n){var e=arguments.length>3&&void 0!==arguments[3]&&arguments[3];if("string"!=typeof r){return r}t=N(t),n=N(n);var o=new RegExp(R(t,n),"gm"),i=r.match(o);return i?e?i:i[0]:null}function T(r){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:",";if("string"!=typeof r){return r}if(f(r)){return[]}var n=(r=w(r)).split(t).map((function(r){return w(r)}));return 1===n.length&&""===n[0]?[r]:n}function I(r,t,n){var e,o=arguments.length>3&&void 0!==arguments[3]&&arguments[3];if("string"!=typeof r){return r}var i=null!==(e=k(r,t,n,o))&&void 0!==e?e:o?[]:r;return o?i.map((function(r){return w(r,t,n)})):w(i,t,n)}function M(r){return"string"!=typeof r?r:r.replace(/`|'|"/g,"")}function $(r){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;return(!t||r.startsWith(t))&&(!n||r.endsWith(n))}function N(r){return r instanceof RegExp?r:r.split("").map((function(r){return["$","^",".","*","+","?","(",")","[","]","{","}","|","\\"].includes(r)?"\\".concat(r):r})).join("")}function R(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}if(t.length<2){throw new Error("You need to pass at least two arguments")}var e="";return t.forEach((function(r,t){r instanceof RegExp&&(r=r.source),0===t?e=r:e+="((.|\n)*?)".concat(r)})),e}function C(r){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if("string"!=typeof r){return r}if(!r){return null}t=i(t),n=i(n);var e=r.replace(/([.+?^${}()|\[\]\/\\])/g,"\\$&"),o=t?"^":"",u=n?"$":"";return e=e.replace(/\*\*/g,"[_g_]").replace(/\*/g,"(.*?)").replace(/\[_g_\]/g,".*"),"".concat(o).concat(e).concat(u)}function B(r,t){if(!r||!t){return null}var n=new RegExp(C(r,arguments.length>2&&void 0!==arguments[2]&&arguments[2],arguments.length>3&&void 0!==arguments[3]&&arguments[3]));if("string"==typeof t){return u(t.match(n))}return u(t.filter((function(r){return n.test(r)})))}window.powerHelper=t})(); |
@@ -283,2 +283,100 @@ // // ----------------------------------------- | ||
// ========================================= | ||
// --> doPoll | ||
// -------------------------- | ||
/** | ||
* Creates a poll function that continuously calls a given function until it returns true or a promise resolves. | ||
* @param {Function} fn - The function to be polled. It can return a promise or a boolean. | ||
* @param {Object} options - Configuration options for polling. | ||
* @param {number} [options.interval=200] - The interval in milliseconds between each poll. | ||
* @param {number} [options.timeout=1000] - The maximum time in milliseconds to continue polling. | ||
* @returns {Object} { promise, stop } - An object containing the polling promise and a cancel function. | ||
* @fails returns 'failed' if the polling times out or is cancelled. | ||
* @options: {} | ||
* - interval: The interval in milliseconds between each poll. | ||
* - timeout: The maximum time in milliseconds to continue polling. | ||
* @example | ||
* const { promise, stop } = doPoll(() => { | ||
* // Polling logic here | ||
* return true; // or return a promise | ||
* } | ||
*/ | ||
const doPoll = (fn, options = {}) => { | ||
if (typeof fn !== 'function') { | ||
if (typeof fn !== 'object') { | ||
throw new Error('doPoll: The first argument must be a function or Promise.'); | ||
} | ||
} | ||
const isPromise = (promise) => promise instanceof Promise; | ||
const { | ||
interval = 200, | ||
timeout = 1000, | ||
timeoutMsg = '===> doPoll: cancelled or timed out.', | ||
} = options; | ||
let timeoutId, intervalId; | ||
let resolvePromise, rejectPromise; | ||
let stopped = false; | ||
let promiseRunning = false; | ||
const stop = () => { | ||
clearTimers(); | ||
rejectPromise(console.info(timeoutMsg)); | ||
}; | ||
const done = (result) => { | ||
clearTimers(); | ||
resolvePromise(result); | ||
}; | ||
function clearTimers() { | ||
stopped = true; | ||
clearTimeout(timeoutId); | ||
clearInterval(intervalId); | ||
} | ||
const promise = new Promise((resolve, reject) => { | ||
resolvePromise = resolve; | ||
rejectPromise = reject; | ||
const poll = () => { | ||
if (stopped || promiseRunning) { | ||
return; | ||
} | ||
const pollThis = isPromise(fn) ? fn : fn(); | ||
// double test if the pollThis returns a promise | ||
if (isPromise(pollThis)) { | ||
promiseRunning = true; | ||
pollThis | ||
.then((resolvedValue) => { | ||
promiseRunning = false; | ||
if (resolvedValue) { | ||
done(resolvedValue); | ||
} | ||
}) | ||
.catch(rejectPromise); | ||
} else { | ||
if (Boolean(pollThis) || pollThis) { | ||
done(pollThis); | ||
} | ||
} | ||
}; | ||
intervalId = setInterval(poll, interval); | ||
poll(); // Initial call to handle any immediate resolution | ||
timeoutId = setTimeout(() => { | ||
if (!stopped) { | ||
stop(); | ||
} | ||
}, timeout); | ||
}); | ||
promise.catch(() => { | ||
stop(); | ||
}); | ||
return { promise, stop }; | ||
}; | ||
// Author Knighttower | ||
@@ -289,2 +387,53 @@ // MIT License | ||
/** | ||
* Get the value of an object property by name or wait for it to be available | ||
* | ||
* @param {Object} obj | ||
* @param {String} name | ||
* @param {Function} callback | ||
* @param {Object} options | ||
* @param {Number} options.queryTime - time to wait for the object to be available. default 15000 ms | ||
* @param {Boolean} options.isFalsy - if the value is falsy | ||
* @return Object/Boolean | ||
*/ | ||
function getObjectValue(obj, name, callback, options) { | ||
const { queryTime = 15000, isFalsy = false } = options || {}; | ||
if (typeof callback === 'function') { | ||
doPoll( | ||
() => { | ||
const value = getObjectValue(obj, name); | ||
if (isFalsy && value === false) { | ||
return callback(value); | ||
} else if (value) { | ||
return callback(value); | ||
} | ||
}, | ||
{ | ||
timeout: queryTime, // 15 seconds | ||
interval: 100, | ||
timeoutMsg: 'Object prop no found:' + name, | ||
} | ||
); | ||
} | ||
if (!obj) { | ||
return false; | ||
} | ||
for (const key in obj) { | ||
if (key === name) { | ||
return obj[key]; | ||
} else if (typeof obj[key] === 'object') { | ||
let result = getObjectValue(obj[key], name); | ||
if (result) { | ||
return result; | ||
} | ||
return false; | ||
} | ||
} | ||
return false; | ||
} | ||
// @private | ||
@@ -491,3 +640,3 @@ function _removeBrackets(strExp) { | ||
// ignore eslint comment | ||
while (true) { | ||
@@ -563,5 +712,5 @@ //find any nested arrays or objects | ||
// comment eslint to ignore | ||
const matchObjectTypes = /^\{((.|\n)*?)\:((.|\n)*?)\}/gm; | ||
const matchFunctionString = /^([a-zA-Z]+)(\()(\.|\#)(.*)(\))/g; | ||
@@ -592,3 +741,3 @@ const regexDotObjectString = /([a-zA-Z]+)\.(.*?)\(((.|\n)*?)\)/gm; | ||
// regexFunctionString | ||
const directive = str.split('(')[0].trim(); | ||
@@ -828,3 +977,3 @@ return results('idOrClassWithDirective', { | ||
matchEnd = convertToBool(matchEnd); | ||
let regexStr = str.replace(/([.+?^${}()|\[\]\/\\])/g, '\\$&'); // escape all regex special chars | ||
@@ -891,2 +1040,2 @@ let regStart = matchStart ? '^' : ''; | ||
export { addQuotes, cleanStr, convertKeysToSymbols, findAndReplaceInArray, findNested, fixQuotes, getArrObjFromString, getChunks, getDirectivesFromString, getMatchBlock, getMatchInBetween, getObjectFromPath, removeQuotes, setExpString, setLookUpExp, setWildCardString, startAndEndWith, wildCardStringSearch }; | ||
export { addQuotes, cleanStr, convertKeysToSymbols, findAndReplaceInArray, findNested, fixQuotes, getArrObjFromString, getChunks, getDirectivesFromString, getMatchBlock, getMatchInBetween, getObjectFromPath, getObjectValue, removeQuotes, setExpString, setLookUpExp, setWildCardString, startAndEndWith, wildCardStringSearch }; |
@@ -1,1 +0,1 @@ | ||
var r,t;r=this,t=()=>(()=>{"use strict";var r={d:(t,n)=>{for(var e in n){r.o(n,e)&&!r.o(t,e)&&Object.defineProperty(t,e,{enumerable:!0,get:n[e]})}},o:(r,t)=>Object.prototype.hasOwnProperty.call(r,t),r:r=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(r,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(r,"__esModule",{value:!0})}},t={};function n(r,t){var n="undefined"!=typeof Symbol&&r[Symbol.iterator]||r["@@iterator"];if(!n){if(Array.isArray(r)||(n=function(r,t){if(r){if("string"==typeof r){return e(r,t)}var n={}.toString.call(r).slice(8,-1);return"Object"===n&&r.constructor&&(n=r.constructor.name),"Map"===n||"Set"===n?Array.from(r):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?e(r,t):void 0}}(r))||t&&r&&"number"==typeof r.length){n&&(r=n);var o=0,i=function(){};return{s:i,n:function(){return o>=r.length?{done:!0}:{done:!1,value:r[o++]}},e:function(r){throw r},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,u=!0,c=!1;return{s:function(){n=n.call(r)},n:function(){var r=n.next();return u=r.done,r},e:function(r){c=!0,a=r},f:function(){try{u||null==n.return||n.return()}finally{if(c){throw a}}}}}function e(r,t){(null==t||t>r.length)&&(t=r.length);for(var n=0,e=Array(t);n<t;n++){e[n]=r[n]}return e}function o(r){return o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(r){return typeof r}:function(r){return r&&"function"==typeof Symbol&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},o(r)}function i(r){switch(o(r)){case"boolean":return r;case"string":return"false"!==r&&"0"!==r;case"number":return 0!==r;default:return Boolean(r)}}function a(r){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return null!==s(r)||"boolean"==typeof r?r:f(r)?t:r}r.r(t),r.d(t,{addQuotes:()=>b,cleanStr:()=>m,convertKeysToSymbols:()=>h,findAndReplaceInArray:()=>S,findNested:()=>w,fixQuotes:()=>A,getArrObjFromString:()=>O,getChunks:()=>_,getDirectivesFromString:()=>x,getMatchBlock:()=>E,getMatchInBetween:()=>k,getObjectFromPath:()=>j,removeQuotes:()=>I,setExpString:()=>P,setLookUpExp:()=>T,setWildCardString:()=>$,startAndEndWith:()=>M,wildCardStringSearch:()=>N});var u=function(){var r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:20;r=r||40;for(var t="",n=0;n<r/3+1;n++){t+=Math.random().toString(36).substring(2,15)}return t.substring(0,r)};function c(){return"id__"+u(8)+"__"+(new Date).getTime()}var l=c;function f(r){return null==r||("string"==typeof r||Array.isArray(r)?0===r.length:r instanceof Map||r instanceof Set?0===r.size:ArrayBuffer.isView(r)?0===r.byteLength:"object"===o(r)&&0===Object.keys(r).length)}function s(r){var t=o(r);switch(r){case null:case void 0:case"":return null;case"0":case 0:return 0;default:if(!("number"!==t&&"string"!==t||"number"!=typeof r&&Number.isNaN(Number(r)))){return+r}}return null}function y(r,t){if(null===r){return t?null===t||"null"===t:"null"}var e;switch(o(r)){case"number":case"string":case"boolean":case"undefined":case"bigint":case"symbol":case"function":e=o(r);break;case"object":e=Array.isArray(r)?"array":"object";break;default:e="unknown"}if(t){if(t.includes("|")){var i,a=n(t.split("|"));try{for(a.s();!(i=a.n()).done;){var u=i.value;if(e===u){return u}}}catch(r){a.e(r)}finally{a.f()}return!1}return t===e}return e}function v(r,t){return function(r){if(Array.isArray(r)){return r}}(r)||function(r,t){var n=null==r?null:"undefined"!=typeof Symbol&&r[Symbol.iterator]||r["@@iterator"];if(null!=n){var e,o,i,a,u=[],c=!0,l=!1;try{if(i=(n=n.call(r)).next,0===t){if(Object(n)!==n){return}c=!1}else{for(;!(c=(e=i.call(n)).done)&&(u.push(e.value),u.length!==t);c=!0){}}}catch(r){l=!0,o=r}finally{try{if(!c&&null!=n.return&&(a=n.return(),Object(a)!==a)){return}}finally{if(l){throw o}}}return u}}(r,t)||function(r,t){if(r){if("string"==typeof r){return g(r,t)}var n={}.toString.call(r).slice(8,-1);return"Object"===n&&r.constructor&&(n=r.constructor.name),"Map"===n||"Set"===n?Array.from(r):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?g(r,t):void 0}}(r,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function g(r,t){(null==t||t>r.length)&&(t=r.length);for(var n=0,e=Array(t);n<t;n++){e[n]=r[n]}return e}function p(r,t,n){return(t=function(r){var t=function(r,t){if("object"!=d(r)||!r){return r}var n=r[Symbol.toPrimitive];if(void 0!==n){var e=n.call(r,t||"default");if("object"!=d(e)){return e}throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(r)}(r,"string");return"symbol"==d(t)?t:t+""}(t))in r?Object.defineProperty(r,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):r[t]=n,r}function d(r){return d="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(r){return typeof r}:function(r){return r&&"function"==typeof Symbol&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},d(r)}function b(r){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:'"';return"".concat(t).concat(r).concat(t)}function m(r){if(r){if("string"!=typeof r){return r}for(var t=arguments.length,n=new Array(t>1?t-1:0),e=1;e<t;e++){n[e-1]=arguments[e]}return n.reduce((function(r,t){var n=t instanceof RegExp?t:new RegExp(P(t));return r.replace(n,"")}),r).trim()}}function h(r){if(null===a(r,null)){return{}}var t={},n={};for(var e in r){var o=Symbol(e);t[o]=r[e],n[e]=o}return t.keyToSymbolMap=n,t}function S(r,t,n){var e=!1,o=r.map((function(r){if(Array.isArray(r)){var o=S(r,t,n);return o?(e=!0,o):r}return r===t?(e=!0,Array.isArray(n)?n.map((function(r){return Array.isArray(r)?r:r.trim()})):n):r}));return e?o:null}function w(r){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"[",n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"]";if("string"!=typeof r){return r}var e=r.lastIndexOf(t);if(-1===e){return null}var o=r.substring(e),i=o.indexOf(n);return-1===i?null:o.substring(0,i+1)}function A(r){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:'"';return"string"!=typeof r?r:r.replace(/`|'|"/g,t)}function j(r){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:window;return r.split(".").reduce((function(r,t){return r&&r[t]}),t)}function O(r){if(y(r,"object")||y(r,"array")){return r}var t=M(r,"{","}"),n=M(r,"[","]");if(!t&&!n){return r}var e=t?{}:[],o={},i=function(r){var t=r.match(/^(\[|\{)(.*?)(\]|\})$/);return t?t[2].trim():r}(r),u=function(){for(var r=arguments.length>0&&void 0!==arguments[0]&&arguments[0];;){var t=r?w(i,"{","}"):w(i);if(!t){break}var n="__".concat(l(),"__");o[n]=t,i=i.replace(t,n)}};return u(),u(!0),_(i).forEach((function(r,n){var i,u,c=r.includes(":")&&t,l=c?_(r,":"):[],f=I(a(l[0],n));(r=c?l[1]:r)in o&&(r=O(o[r])),i=I(r),r=null!==(u=s(i))?u:i,t?e[f]=r:e.push(r)})),e}function x(r){var t=r;if(!a(t)){return null}var n=function(){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return{type:arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,directive:r}},e=/([a-zA-Z]+)\[((.|\n)*?)\]\(((.|\n)*?)\)/gm,o=d(t);if("object"===o||"array"===o){return n(o,t)}switch(!0){case!!t.match(/^\[((.|\n)*?)\]$/gm):o="array";break;case!!t.match(/^\{((.|\n)*?)\:((.|\n)*?)\}/gm):o="object";break;case!!t.match(/^([a-zA-Z]+)(\()(\.|\#)(.*)(\))/g):return n("idOrClassWithDirective",p({},t.split("(")[0].trim(),k(t,"(",")")));case!!t.match(/([a-zA-Z]+)\.(.*?)\(((.|\n)*?)\)/gm):case!!t.match(e):o="dotObject";break;default:return n("string",t)}if("array"===o||"object"===o){var i=A(t);try{return n(o,JSON.parse(i))}catch(r){}return n(o,O(i))}if("dotObject"===o){var u,c,l,f={};return _(t,"&&").forEach((function(r){if(r.match(e)){u=k(r,"](",")"),c=k(r,"[","]"),l=r.split("[")[0].trim()}else{u=k(r,"(",")");var t=v(_(r=r.replace(E(r,"(",")"),""),"."),2);l=t[0],c=t[1]}u=O(u),f[l]||(f[l]={}),_(c,"|").forEach((function(r){f[l][r]=u}))})),n("dotObject",f)}}function E(r,t,n){var e=arguments.length>3&&void 0!==arguments[3]&&arguments[3];if("string"!=typeof r){return r}t=P(t),n=P(n);var o=new RegExp(T(t,n),"gm"),i=r.match(o);return i?e?i:i[0]:null}function _(r){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:",";if("string"!=typeof r){return r}if(f(r)){return[]}var n=(r=m(r)).split(t).map((function(r){return m(r)}));return 1===n.length&&""===n[0]?[r]:n}function k(r,t,n){var e,o=arguments.length>3&&void 0!==arguments[3]&&arguments[3];if("string"!=typeof r){return r}var i=null!==(e=E(r,t,n,o))&&void 0!==e?e:o?[]:r;return o?i.map((function(r){return m(r,t,n)})):m(i,t,n)}function I(r){return"string"!=typeof r?r:r.replace(/`|'|"/g,"")}function M(r){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;return(!t||r.startsWith(t))&&(!n||r.endsWith(n))}function P(r){return r instanceof RegExp?r:r.split("").map((function(r){return["$","^",".","*","+","?","(",")","[","]","{","}","|","\\"].includes(r)?"\\".concat(r):r})).join("")}function T(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}if(t.length<2){throw new Error("You need to pass at least two arguments")}var e="";return t.forEach((function(r,t){r instanceof RegExp&&(r=r.source),0===t?e=r:e+="((.|\n)*?)".concat(r)})),e}function $(r){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if("string"!=typeof r){return r}if(!r){return null}t=i(t),n=i(n);var e=r.replace(/([.+?^${}()|\[\]\/\\])/g,"\\$&"),o=t?"^":"",a=n?"$":"";return e=e.replace(/\*\*/g,"[_g_]").replace(/\*/g,"(.*?)").replace(/\[_g_\]/g,".*"),"".concat(o).concat(e).concat(a)}function N(r,t){if(!r||!t){return null}var n=new RegExp($(r,arguments.length>2&&void 0!==arguments[2]&&arguments[2],arguments.length>3&&void 0!==arguments[3]&&arguments[3]));return a("string"==typeof t?t.match(n):t.filter((function(r){return n.test(r)})))}return t})(),"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("powerHelper",[],t):"object"==typeof exports?exports.powerHelper=t():r.powerHelper=t(); | ||
var r,t;r=this,t=()=>(()=>{"use strict";var r={d:(t,n)=>{for(var e in n){r.o(n,e)&&!r.o(t,e)&&Object.defineProperty(t,e,{enumerable:!0,get:n[e]})}},o:(r,t)=>Object.prototype.hasOwnProperty.call(r,t),r:r=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(r,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(r,"__esModule",{value:!0})}},t={};function n(r,t){var n="undefined"!=typeof Symbol&&r[Symbol.iterator]||r["@@iterator"];if(!n){if(Array.isArray(r)||(n=function(r,t){if(r){if("string"==typeof r){return e(r,t)}var n={}.toString.call(r).slice(8,-1);return"Object"===n&&r.constructor&&(n=r.constructor.name),"Map"===n||"Set"===n?Array.from(r):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?e(r,t):void 0}}(r))||t&&r&&"number"==typeof r.length){n&&(r=n);var o=0,i=function(){};return{s:i,n:function(){return o>=r.length?{done:!0}:{done:!1,value:r[o++]}},e:function(r){throw r},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var u,a=!0,c=!1;return{s:function(){n=n.call(r)},n:function(){var r=n.next();return a=r.done,r},e:function(r){c=!0,u=r},f:function(){try{a||null==n.return||n.return()}finally{if(c){throw u}}}}}function e(r,t){(null==t||t>r.length)&&(t=r.length);for(var n=0,e=Array(t);n<t;n++){e[n]=r[n]}return e}function o(r){return o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(r){return typeof r}:function(r){return r&&"function"==typeof Symbol&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},o(r)}function i(r){switch(o(r)){case"boolean":return r;case"string":return"false"!==r&&"0"!==r;case"number":return 0!==r;default:return Boolean(r)}}function u(r){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return null!==s(r)||"boolean"==typeof r?r:f(r)?t:r}r.r(t),r.d(t,{addQuotes:()=>S,cleanStr:()=>w,convertKeysToSymbols:()=>j,findAndReplaceInArray:()=>A,findNested:()=>O,fixQuotes:()=>E,getArrObjFromString:()=>_,getChunks:()=>T,getDirectivesFromString:()=>P,getMatchBlock:()=>k,getMatchInBetween:()=>I,getObjectFromPath:()=>x,getObjectValue:()=>h,removeQuotes:()=>M,setExpString:()=>N,setLookUpExp:()=>R,setWildCardString:()=>C,startAndEndWith:()=>$,wildCardStringSearch:()=>B});var a=function(){var r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:20;r=r||40;for(var t="",n=0;n<r/3+1;n++){t+=Math.random().toString(36).substring(2,15)}return t.substring(0,r)};function c(){return"id__"+a(8)+"__"+(new Date).getTime()}var l=c;function f(r){return null==r||("string"==typeof r||Array.isArray(r)?0===r.length:r instanceof Map||r instanceof Set?0===r.size:ArrayBuffer.isView(r)?0===r.byteLength:"object"===o(r)&&0===Object.keys(r).length)}function s(r){var t=o(r);switch(r){case null:case void 0:case"":return null;case"0":case 0:return 0;default:if(!("number"!==t&&"string"!==t||"number"!=typeof r&&Number.isNaN(Number(r)))){return+r}}return null}function y(r,t){if(null===r){return t?null===t||"null"===t:"null"}var e;switch(o(r)){case"number":case"string":case"boolean":case"undefined":case"bigint":case"symbol":case"function":e=o(r);break;case"object":e=Array.isArray(r)?"array":"object";break;default:e="unknown"}if(t){if(t.includes("|")){var i,u=n(t.split("|"));try{for(u.s();!(i=u.n()).done;){var a=i.value;if(e===a){return a}}}catch(r){u.e(r)}finally{u.f()}return!1}return t===e}return e}function v(r){return v="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(r){return typeof r}:function(r){return r&&"function"==typeof Symbol&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},v(r)}var p=function(r){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if("function"!=typeof r&&"object"!==v(r)){throw new Error("doPoll: The first argument must be a function or Promise.")}var n,e,o,i,u=function(r){return r instanceof Promise},a=t.interval,c=void 0===a?200:a,l=t.timeout,f=void 0===l?1e3:l,s=t.timeoutMsg,y=void 0===s?"===> doPoll: cancelled or timed out.":s,p=!1,m=!1,d=function(){b(),i(console.info(y))},g=function(r){b(),o(r)};function b(){p=!0,clearTimeout(n),clearInterval(e)}var h=new Promise((function(t,a){o=t,i=a;var l=function(){if(!p&&!m){var t=u(r)?r:r();u(t)?(m=!0,t.then((function(r){m=!1,r&&g(r)})).catch(i)):(Boolean(t)||t)&&g(t)}};e=setInterval(l,c),l(),n=setTimeout((function(){p||d()}),f)}));return h.catch((function(){d()})),{promise:h,stop:d}};function m(r,t){return function(r){if(Array.isArray(r)){return r}}(r)||function(r,t){var n=null==r?null:"undefined"!=typeof Symbol&&r[Symbol.iterator]||r["@@iterator"];if(null!=n){var e,o,i,u,a=[],c=!0,l=!1;try{if(i=(n=n.call(r)).next,0===t){if(Object(n)!==n){return}c=!1}else{for(;!(c=(e=i.call(n)).done)&&(a.push(e.value),a.length!==t);c=!0){}}}catch(r){l=!0,o=r}finally{try{if(!c&&null!=n.return&&(u=n.return(),Object(u)!==u)){return}}finally{if(l){throw o}}}return a}}(r,t)||function(r,t){if(r){if("string"==typeof r){return d(r,t)}var n={}.toString.call(r).slice(8,-1);return"Object"===n&&r.constructor&&(n=r.constructor.name),"Map"===n||"Set"===n?Array.from(r):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?d(r,t):void 0}}(r,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function d(r,t){(null==t||t>r.length)&&(t=r.length);for(var n=0,e=Array(t);n<t;n++){e[n]=r[n]}return e}function g(r,t,n){return(t=function(r){var t=function(r,t){if("object"!=b(r)||!r){return r}var n=r[Symbol.toPrimitive];if(void 0!==n){var e=n.call(r,t||"default");if("object"!=b(e)){return e}throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(r)}(r,"string");return"symbol"==b(t)?t:t+""}(t))in r?Object.defineProperty(r,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):r[t]=n,r}function b(r){return b="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(r){return typeof r}:function(r){return r&&"function"==typeof Symbol&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},b(r)}function h(r,t,n,e){var o=e||{},i=o.queryTime,u=void 0===i?15e3:i,a=o.isFalsy,c=void 0!==a&&a;if("function"==typeof n&&p((function(){var e=h(r,t);return c&&!1===e||e?n(e):void 0}),{timeout:u,interval:100,timeoutMsg:"Object prop no found:"+t}),!r){return!1}for(var l in r){if(l===t){return r[l]}if("object"===b(r[l])){var f=h(r[l],t);return f||!1}}return!1}function S(r){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:'"';return"".concat(t).concat(r).concat(t)}function w(r){if(r){if("string"!=typeof r){return r}for(var t=arguments.length,n=new Array(t>1?t-1:0),e=1;e<t;e++){n[e-1]=arguments[e]}return n.reduce((function(r,t){var n=t instanceof RegExp?t:new RegExp(N(t));return r.replace(n,"")}),r).trim()}}function j(r){if(null===u(r,null)){return{}}var t={},n={};for(var e in r){var o=Symbol(e);t[o]=r[e],n[e]=o}return t.keyToSymbolMap=n,t}function A(r,t,n){var e=!1,o=r.map((function(r){if(Array.isArray(r)){var o=A(r,t,n);return o?(e=!0,o):r}return r===t?(e=!0,Array.isArray(n)?n.map((function(r){return Array.isArray(r)?r:r.trim()})):n):r}));return e?o:null}function O(r){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"[",n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"]";if("string"!=typeof r){return r}var e=r.lastIndexOf(t);if(-1===e){return null}var o=r.substring(e),i=o.indexOf(n);return-1===i?null:o.substring(0,i+1)}function E(r){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:'"';return"string"!=typeof r?r:r.replace(/`|'|"/g,t)}function x(r){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:window;return r.split(".").reduce((function(r,t){return r&&r[t]}),t)}function _(r){if(y(r,"object")||y(r,"array")){return r}var t=$(r,"{","}"),n=$(r,"[","]");if(!t&&!n){return r}var e=t?{}:[],o={},i=function(r){var t=r.match(/^(\[|\{)(.*?)(\]|\})$/);return t?t[2].trim():r}(r),a=function(){for(var r=arguments.length>0&&void 0!==arguments[0]&&arguments[0];;){var t=r?O(i,"{","}"):O(i);if(!t){break}var n="__".concat(l(),"__");o[n]=t,i=i.replace(t,n)}};return a(),a(!0),T(i).forEach((function(r,n){var i,a,c=r.includes(":")&&t,l=c?T(r,":"):[],f=M(u(l[0],n));(r=c?l[1]:r)in o&&(r=_(o[r])),i=M(r),r=null!==(a=s(i))?a:i,t?e[f]=r:e.push(r)})),e}function P(r){var t=r;if(!u(t)){return null}var n=function(){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return{type:arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,directive:r}},e=/([a-zA-Z]+)\[((.|\n)*?)\]\(((.|\n)*?)\)/gm,o=b(t);if("object"===o||"array"===o){return n(o,t)}switch(!0){case!!t.match(/^\[((.|\n)*?)\]$/gm):o="array";break;case!!t.match(/^\{((.|\n)*?)\:((.|\n)*?)\}/gm):o="object";break;case!!t.match(/^([a-zA-Z]+)(\()(\.|\#)(.*)(\))/g):return n("idOrClassWithDirective",g({},t.split("(")[0].trim(),I(t,"(",")")));case!!t.match(/([a-zA-Z]+)\.(.*?)\(((.|\n)*?)\)/gm):case!!t.match(e):o="dotObject";break;default:return n("string",t)}if("array"===o||"object"===o){var i=E(t);try{return n(o,JSON.parse(i))}catch(r){}return n(o,_(i))}if("dotObject"===o){var a,c,l,f={};return T(t,"&&").forEach((function(r){if(r.match(e)){a=I(r,"](",")"),c=I(r,"[","]"),l=r.split("[")[0].trim()}else{a=I(r,"(",")");var t=m(T(r=r.replace(k(r,"(",")"),""),"."),2);l=t[0],c=t[1]}a=_(a),f[l]||(f[l]={}),T(c,"|").forEach((function(r){f[l][r]=a}))})),n("dotObject",f)}}function k(r,t,n){var e=arguments.length>3&&void 0!==arguments[3]&&arguments[3];if("string"!=typeof r){return r}t=N(t),n=N(n);var o=new RegExp(R(t,n),"gm"),i=r.match(o);return i?e?i:i[0]:null}function T(r){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:",";if("string"!=typeof r){return r}if(f(r)){return[]}var n=(r=w(r)).split(t).map((function(r){return w(r)}));return 1===n.length&&""===n[0]?[r]:n}function I(r,t,n){var e,o=arguments.length>3&&void 0!==arguments[3]&&arguments[3];if("string"!=typeof r){return r}var i=null!==(e=k(r,t,n,o))&&void 0!==e?e:o?[]:r;return o?i.map((function(r){return w(r,t,n)})):w(i,t,n)}function M(r){return"string"!=typeof r?r:r.replace(/`|'|"/g,"")}function $(r){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;return(!t||r.startsWith(t))&&(!n||r.endsWith(n))}function N(r){return r instanceof RegExp?r:r.split("").map((function(r){return["$","^",".","*","+","?","(",")","[","]","{","}","|","\\"].includes(r)?"\\".concat(r):r})).join("")}function R(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}if(t.length<2){throw new Error("You need to pass at least two arguments")}var e="";return t.forEach((function(r,t){r instanceof RegExp&&(r=r.source),0===t?e=r:e+="((.|\n)*?)".concat(r)})),e}function C(r){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if("string"!=typeof r){return r}if(!r){return null}t=i(t),n=i(n);var e=r.replace(/([.+?^${}()|\[\]\/\\])/g,"\\$&"),o=t?"^":"",u=n?"$":"";return e=e.replace(/\*\*/g,"[_g_]").replace(/\*/g,"(.*?)").replace(/\[_g_\]/g,".*"),"".concat(o).concat(e).concat(u)}function B(r,t){if(!r||!t){return null}var n=new RegExp(C(r,arguments.length>2&&void 0!==arguments[2]&&arguments[2],arguments.length>3&&void 0!==arguments[3]&&arguments[3]));return u("string"==typeof t?t.match(n):t.filter((function(r){return n.test(r)})))}return t})(),"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("powerHelper",[],t):"object"==typeof exports?exports.powerHelper=t():r.powerHelper=t(); |
@@ -35,6 +35,7 @@ // Single Modules and Aliases from: utility | ||
import proxyObject from './src/proxyObject.js'; | ||
// Single Modules and Aliases from: promiseQueue | ||
import { promiseQueue, doPoll, promisePool, doTimeout, doAsync } from './src/promiseQueue.js'; | ||
// Single Modules and Aliases from: promises | ||
import { promiseQueue, doPoll, promisePool, doTimeout, doAsync } from './src/promises.js'; | ||
// Single Modules and Aliases from: powerHelper | ||
import { | ||
getObjectValue, | ||
addQuotes, | ||
@@ -104,2 +105,3 @@ cleanStr, | ||
doAsync, | ||
getObjectValue, | ||
addQuotes, | ||
@@ -106,0 +108,0 @@ cleanStr, |
{ | ||
"name": "@knighttower/utility", | ||
"version": "7.20.0", | ||
"version": "7.21.0", | ||
"main": "index.cjs", | ||
@@ -43,6 +43,14 @@ "module": "index.js", | ||
}, | ||
"./helpers": { | ||
"import": "./dist/esm/powerHelper.js", | ||
"require": "./dist/cjs/powerHelper.cjs" | ||
}, | ||
"./promiseQueue": { | ||
"import": "./dist/esm/promiseQueue.js", | ||
"require": "./dist/cjs/promiseQueue.cjs" | ||
"import": "./dist/esm/promises.js", | ||
"require": "./dist/cjs/promises.cjs" | ||
}, | ||
"./promises": { | ||
"import": "./dist/esm/promises.js", | ||
"require": "./dist/cjs/promises.cjs" | ||
}, | ||
"./EventBus": { | ||
@@ -49,0 +57,0 @@ "import": "./dist/esm/EventBus.js", |
@@ -53,2 +53,3 @@ # JS utility Library Documentation | ||
promiseQueue, | ||
promises, | ||
proxyClass, | ||
@@ -90,3 +91,3 @@ proxyObject, | ||
- `@knighttower/utility/powerHelpers` (default export) | ||
- `@knighttower/utility/promiseQueue` (default export) | ||
- `@knighttower/utility/promises` (default export) | ||
- `@knighttower/utility/EventBus` (default export) | ||
@@ -130,3 +131,3 @@ - `@knighttower/utility/event-bus` (default export) | ||
- [promiseQueue](https://github.com/knighttower/JsUtility/blob/development/packages/utility/src/promiseQueue.js): A class for managing promises in a queue and polling | ||
- [promises](https://github.com/knighttower/JsUtility/blob/development/packages/utility/src/promises.js): A class for managing promises in a queue and polling | ||
@@ -138,3 +139,3 @@ @imports | ||
promisePool, | ||
promiseQueue, | ||
promises, | ||
@@ -141,0 +142,0 @@ <br/> |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
521350
57
8938
312