@knighttower/utility
Advanced tools
Comparing version 6.0.7 to 7.0.9
@@ -1,1 +0,1 @@ | ||
(()=>{"use strict";var e={d:(r,t)=>{for(var n in t){e.o(t,n)&&!e.o(r,n)&&Object.defineProperty(r,n,{enumerable:!0,get:t[n]})}},o:(e,r)=>Object.prototype.hasOwnProperty.call(e,r),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},r={};function t(e,r){var t="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!t){if(Array.isArray(e)||(t=function(e,r){if(!e){return}if("string"==typeof e){return n(e,r)}var t=Object.prototype.toString.call(e).slice(8,-1);"Object"===t&&e.constructor&&(t=e.constructor.name);if("Map"===t||"Set"===t){return Array.from(e)}if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)){return n(e,r)}}(e))||r&&e&&"number"==typeof e.length){t&&(e=t);var o=0,i=function(){};return{s:i,n:function(){return o>=e.length?{done:!0}:{done:!1,value:e[o++]}},e:function(e){throw e},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,f=!1;return{s:function(){t=t.call(e)},n:function(){var e=t.next();return u=e.done,e},e:function(e){f=!0,a=e},f:function(){try{u||null==t.return||t.return()}finally{if(f){throw a}}}}}function n(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,n=new Array(r);t<r;t++){n[t]=e[t]}return n}e.r(r),e.d(r,{DomObserver:()=>i,default:()=>i,domObserver:()=>i});var o={};!function(){if("undefined"!=typeof window){new MutationObserver((function(e){var r,n=t(e);try{for(n.s();!(r=n.n()).done;){if("childList"===r.value.type){for(var i in o){o[i]()}}}}catch(a){n.e(a)}finally{n.f()}})).observe(document.body,{childList:!0,subtree:!0})}}();var i={executeOnNodeChanged:o,addOnNodeChange:function(e,r){r&&(o[e]=r)},removeOnNodeChange:function(e){e&&delete o[e]},cleanup:function(){Object.keys(o).forEach((function(e){return delete o[e]}))}};window.DomObserver=r})(); | ||
(()=>{"use strict";var e={d:(n,t)=>{for(var r in t){e.o(t,r)&&!e.o(n,r)&&Object.defineProperty(n,r,{enumerable:!0,get:t[r]})}},o:(e,n)=>Object.prototype.hasOwnProperty.call(e,n)},n={};function t(e,n){var t="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!t){if(Array.isArray(e)||(t=function(e,n){if(!e){return}if("string"==typeof e){return r(e,n)}var t=Object.prototype.toString.call(e).slice(8,-1);"Object"===t&&e.constructor&&(t=e.constructor.name);if("Map"===t||"Set"===t){return Array.from(e)}if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)){return r(e,n)}}(e))||n&&e&&"number"==typeof e.length){t&&(e=t);var o=0,i=function(){};return{s:i,n:function(){return o>=e.length?{done:!0}:{done:!1,value:e[o++]}},e:function(e){throw e},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,f=!1;return{s:function(){t=t.call(e)},n:function(){var e=t.next();return u=e.done,e},e:function(e){f=!0,a=e},f:function(){try{u||null==t.return||t.return()}finally{if(f){throw a}}}}}function r(e,n){(null==n||n>e.length)&&(n=e.length);for(var t=0,r=new Array(n);t<n;t++){r[t]=e[t]}return r}e.d(n,{domObserver:()=>a});var o,i={},a={start:function(){if("undefined"!=typeof window&&!o){var e={childList:!0,subtree:!0};if(o=new MutationObserver((function(e){var n,r=t(e);try{for(r.s();!(n=r.n()).done;){if("childList"===n.value.type){for(var o in i){i[o]()}}}}catch(a){r.e(a)}finally{r.f()}})),document.body){return o.observe(document.body,e)}document.addEventListener("DOMContentLoaded",(function(n){return o.observe(document.body,e)}))}},addOnNodeChange:function(e,n){n&&(i[e]=n)},removeOnNodeChange:function(e){e&&delete i[e]},cleanup:function(){Object.keys(i).forEach((function(e){return delete i[e]}))}};window.domObserver=n.domObserver})(); |
@@ -1,1 +0,1 @@ | ||
(()=>{"use strict";var e={d:(t,n)=>{for(var r in n){e.o(n,r)&&!e.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:n[r]})}},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};function n(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(!e){return}if("string"==typeof e){return r(e,t)}var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n){return Array.from(e)}if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)){return r(e,t)}}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var o=0,i=function(){};return{s:i,n:function(){return o>=e.length?{done:!0}:{done:!1,value:e[o++]}},e:function(e){throw e},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,l=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return a=e.done,e},e:function(e){l=!0,u=e},f:function(){try{a||null==n.return||n.return()}finally{if(l){throw u}}}}}function r(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++){r[n]=e[n]}return r}e.r(t),e.d(t,{ElementHelper:()=>c,default:()=>c,elementHelper:()=>c,selectElement:()=>m});var o={};!function(){if("undefined"!=typeof window){new MutationObserver((function(e){var t,r=n(e);try{for(r.s();!(t=r.n()).done;){if("childList"===t.value.type){for(var i in o){o[i]()}}}}catch(u){r.e(u)}finally{r.f()}})).observe(document.body,{childList:!0,subtree:!0})}}();var i=function(e,t){t&&(o[e]=t)},u=function(e){e&&delete o[e]};function a(e){return a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},a(e)}function l(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,f(r.key),r)}}function f(e){var t=function(e,t){if("object"!=a(e)||!e){return e}var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=a(r)){return r}throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==a(t)?t:t+""}var c=function(){function e(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:document;!function(e,t){if(!(e instanceof t)){throw new TypeError("Cannot call a class as a function")}}(this,e),this.selector=t,"object"===a(t)?this.domElement=t:String(t).includes("//")?this.domElement=this.getElementByXpath(t):this.domElement=n.querySelector(t)}return t=e,(n=[{key:"isInDom",value:function(){var e;return Boolean(null===(e=this.domElement)||void 0===e?void 0:e.outerHTML)}},{key:"whenInDom",value:function(){var t=this,n=Date.now()+Math.floor(1e3*Math.random());return new Promise((function(r){t.isInDom()?r(t):i(n,(function(){var o=new e(t.selector);o.isInDom()&&(r(t=o),u(n))}))}))}},{key:"getElementByXpath",value:function(e){return document.evaluate(e,document,null,XPathResult.FIRST_ORDERED_NODE_TYPE,null).singleNodeValue}},{key:"getXpathTo",value:function(){var t=this.domElement;if(t.id){return"//*[@id='".concat(t.id,"']")}if(t===document.body){return"//"+t.tagName}for(var n=0,r=t.parentNode.childNodes,o=0;o<r.length;o++){var i=r[o];if(i===t){return new e(t.parentNode).getXpathTo()+"/"+t.tagName+"["+(n+1)+"]"}1===i.nodeType&&i.tagName===t.tagName&&n++}}},{key:"getAttribute",value:function(e){return this.domElement.getAttribute(e)||null}},{key:"getHash",value:function(){var e=String(this.getXpathTo()),t=0;if(0===e.length){return t}for(var n=0;n<e.length;n++){t=(t<<5)-t+e.charCodeAt(n),t|=0}return t}}])&&l(t.prototype,n),r&&l(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,n,r}(),m=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:document;return new c(e,t)};window.ElementHelper=t})(); | ||
(()=>{"use strict";var e={d:(t,n)=>{for(var r in n){e.o(n,r)&&!e.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:n[r]})}},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t)},t={};function n(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(!e){return}if("string"==typeof e){return r(e,t)}var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n){return Array.from(e)}if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)){return r(e,t)}}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var o=0,i=function(){};return{s:i,n:function(){return o>=e.length?{done:!0}:{done:!1,value:e[o++]}},e:function(e){throw e},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,l=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return a=e.done,e},e:function(e){l=!0,u=e},f:function(){try{a||null==n.return||n.return()}finally{if(l){throw u}}}}}function r(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++){r[n]=e[n]}return r}e.d(t,{elementHelper:()=>y});var o,i={},u=function(){if("undefined"!=typeof window&&!o){var e={childList:!0,subtree:!0};if(o=new MutationObserver((function(e){var t,r=n(e);try{for(r.s();!(t=r.n()).done;){if("childList"===t.value.type){for(var o in i){i[o]()}}}}catch(u){r.e(u)}finally{r.f()}})),document.body){return o.observe(document.body,e)}document.addEventListener("DOMContentLoaded",(function(t){return o.observe(document.body,e)}))}},a=function(e,t){t&&(i[e]=t)},l=function(e){e&&delete i[e]};function f(e){return f="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},f(e)}function c(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,m(r.key),r)}}function m(e){var t=function(e,t){if("object"!=f(e)||!e){return e}var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=f(r)){return r}throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==f(t)?t:t+""}var d=function(){function e(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:document;!function(e,t){if(!(e instanceof t)){throw new TypeError("Cannot call a class as a function")}}(this,e),u(),this.selector=t,"object"===f(t)?this.domElement=t:String(t).includes("//")?this.domElement=this.getElementByXpath(t):this.domElement=n.querySelector(t)}return t=e,(n=[{key:"isInDom",value:function(){var e;return Boolean(null===(e=this.domElement)||void 0===e?void 0:e.outerHTML)}},{key:"whenInDom",value:function(){var t=this,n=Date.now()+Math.floor(1e3*Math.random());return new Promise((function(r){t.isInDom()?r(t):a(n,(function(){var o=new e(t.selector);o.isInDom()&&(r(t=o),l(n))}))}))}},{key:"getElementByXpath",value:function(e){return document.evaluate(e,document,null,XPathResult.FIRST_ORDERED_NODE_TYPE,null).singleNodeValue}},{key:"getXpathTo",value:function(){var t=this.domElement;if(t.id){return"//*[@id='".concat(t.id,"']")}if(t===document.body){return"//"+t.tagName}for(var n=0,r=t.parentNode.childNodes,o=0;o<r.length;o++){var i=r[o];if(i===t){return new e(t.parentNode).getXpathTo()+"/"+t.tagName+"["+(n+1)+"]"}1===i.nodeType&&i.tagName===t.tagName&&n++}}},{key:"getAttribute",value:function(e){return this.domElement.getAttribute(e)||null}},{key:"getHash",value:function(){var e=String(this.getXpathTo()),t=0;if(0===e.length){return t}for(var n=0;n<e.length;n++){t=(t<<5)-t+e.charCodeAt(n),t|=0}return t}}])&&c(t.prototype,n),r&&c(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,n,r}(),y=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:document;return new d(e,t)};window.elementHelper=t.elementHelper})(); |
@@ -1,1 +0,1 @@ | ||
(()=>{"use strict";var e={d:(t,r)=>{for(var n in r){e.o(r,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:r[n]})}},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};function r(e){return r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},r(e)}function n(e){return function(e){if(Array.isArray(e)){return o(e)}}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"]){return Array.from(e)}}(e)||function(e,t){if(!e){return}if("string"==typeof e){return o(e,t)}var r=Object.prototype.toString.call(e).slice(8,-1);"Object"===r&&e.constructor&&(r=e.constructor.name);if("Map"===r||"Set"===r){return Array.from(e)}if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)){return o(e,t)}}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function o(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++){n[r]=e[r]}return n}function i(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,a(n.key),n)}}function a(e){var t=function(e,t){if("object"!=r(e)||!e){return e}var n=e[Symbol.toPrimitive];if(void 0!==n){var o=n.call(e,t||"default");if("object"!=r(o)){return o}throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==r(t)?t:t+""}e.r(t),e.d(t,{EventBus:()=>c,_eventBus:()=>l,default:()=>f,eventBus:()=>f});var u={},c=function(){return e=function e(){!function(e,t){if(!(e instanceof t)){throw new TypeError("Cannot call a class as a function")}}(this,e),u={}},t=[{key:"on",value:function(e,t){this.registerListener(e,t)}},{key:"once",value:function(e,t){this.registerListener(e,t,1)}},{key:"exactly",value:function(e,t,r){this.registerListener(e,t,r)}},{key:"off",value:function(e){delete u[e]}},{key:"detach",value:function(e,t){var r=(u[e]||[]).filter((function(e){return e.callback!==t}));return e in u&&(u[e]=r,!0)}},{key:"emit",value:function(e){for(var t=this,r=arguments.length,o=new Array(r>1?r-1:0),i=1;i<r;i++){o[i-1]=arguments[i]}var a=[],c=null,l=this.extractContextFromArgs(o),f=l[0];if(o=l[1],this.hasListener(e)){a=u[e]}else if(e.includes("*")){(c=this.patternSearch(e,Object.keys(u))).length>0&&c.forEach((function(e){a=a.concat(u[e])}))}else{for(var s in u){s.includes("*")&&(c=this.patternSearch(s,[e]))&&(a=a.concat(u[s]))}}a.forEach((function(r,i){var c=r.callback;f&&(c=c.bind(f)),void 0!==r.triggerCapacity&&(r.triggerCapacity--,a[i].triggerCapacity=r.triggerCapacity),t.checkToRemoveListener(r)&&u[e].splice(i,1),c.apply(void 0,n(o))}))}},{key:"patternSearch",value:function(e,t){var r,n=new RegExp(this.setWildCardString(e),"g");return 0===(r=t.filter((function(e){return n.test(e)}))).length?null:r}},{key:"setWildCardString",value:function(e){var t=e.replace(/([.+?^${}()|\[\]\/\\])/g,"\\$&");return t=t.replace(/\*/g,"(.*?)"),"^".concat(t)}},{key:"extractContextFromArgs",value:function(e){for(var t=null,n=0;n<e.length;n++){var o=e[n];if(o&&"object"===r(o)&&o.hasOwnProperty("__context")){t=o.__context,e.splice(n,1);break}}return[t,e]}},{key:"registerListener",value:function(e,t,r){this.hasListener(e)||(u[e]=[]),u[e].push({callback:t,triggerCapacity:r})}},{key:"checkToRemoveListener",value:function(e){return void 0!==e.triggerCapacity&&e.triggerCapacity<=0}},{key:"hasListener",value:function(e){return e in u}},{key:"global",value:function(){return l()}}],t&&i(e.prototype,t),o&&i(e,o),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,t,o}();function l(){return"undefined"!=typeof window?(window.eventBus||(window.eventBus=new c),window.eventBus):"undefined"!=typeof global?(global.eventBus||(global.eventBus=new c),global.eventBus):new c}function f(){return new c}window.EventBus=t})(); | ||
(()=>{"use strict";var e={d:(t,r)=>{for(var n in r){e.o(r,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:r[n]})}},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t)},t={};function r(e){return r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},r(e)}function n(e){return function(e){if(Array.isArray(e)){return i(e)}}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"]){return Array.from(e)}}(e)||function(e,t){if(!e){return}if("string"==typeof e){return i(e,t)}var r=Object.prototype.toString.call(e).slice(8,-1);"Object"===r&&e.constructor&&(r=e.constructor.name);if("Map"===r||"Set"===r){return Array.from(e)}if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)){return i(e,t)}}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function i(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++){n[r]=e[r]}return n}function o(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,a(n.key),n)}}function a(e){var t=function(e,t){if("object"!=r(e)||!e){return e}var n=e[Symbol.toPrimitive];if(void 0!==n){var i=n.call(e,t||"default");if("object"!=r(i)){return i}throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==r(t)?t:t+""}e.d(t,{EventBus:()=>s});var s=function(){return e=function e(){!function(e,t){if(!(e instanceof t)){throw new TypeError("Cannot call a class as a function")}}(this,e),this.listeners={}},t=[{key:"on",value:function(e,t){this.registerListener(e,t)}},{key:"once",value:function(e,t){this.registerListener(e,t,1)}},{key:"exactly",value:function(e,t,r){this.registerListener(e,t,r)}},{key:"off",value:function(e){delete this.listeners[e]}},{key:"detach",value:function(e,t){var r=(this.listeners[e]||[]).filter((function(e){return e.callback!==t}));return e in this.listeners&&(this.listeners[e]=r,!0)}},{key:"emit",value:function(e){for(var t=this,r=arguments.length,i=new Array(r>1?r-1:0),o=1;o<r;o++){i[o-1]=arguments[o]}var a=[],s=null,c=this.extractContextFromArgs(i),l=c[0];if(i=c[1],this.hasListener(e)){a=this.listeners[e]}else if(e.includes("*")){(s=this.patternSearch(e,Object.keys(this.listeners))).length>0&&s.forEach((function(e){a=a.concat(t.listeners[e])}))}else{for(var u in this.listeners){u.includes("*")&&(s=this.patternSearch(u,[e]))&&(a=a.concat(this.listeners[u]))}}a.forEach((function(r,o){var s=r.callback;l&&(s=s.bind(l)),void 0!==r.triggerCapacity&&(r.triggerCapacity--,a[o].triggerCapacity=r.triggerCapacity),t.checkToRemoveListener(r)&&t.listeners[e].splice(o,1),s.apply(void 0,n(i))}))}},{key:"patternSearch",value:function(e,t){var r,n=new RegExp(this.setWildCardString(e),"g");return 0===(r=t.filter((function(e){return n.test(e)}))).length?null:r}},{key:"setWildCardString",value:function(e){var t=e.replace(/([.+?^${}()|\[\]\/\\])/g,"\\$&");return t=t.replace(/\*/g,"(.*?)"),"^".concat(t)}},{key:"extractContextFromArgs",value:function(e){for(var t=null,n=0;n<e.length;n++){var i=e[n];if(i&&"object"===r(i)&&i.hasOwnProperty("__context")){t=i.__context,e.splice(n,1);break}}return[t,e]}},{key:"registerListener",value:function(e,t,r){this.hasListener(e)||(this.listeners[e]=[]),this.listeners[e].push({callback:t,triggerCapacity:r})}},{key:"checkToRemoveListener",value:function(e){return void 0!==e.triggerCapacity&&e.triggerCapacity<=0}},{key:"hasListener",value:function(e){return e in this.listeners}}],t&&o(e.prototype,t),i&&o(e,i),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,t,i}();window.EventBus=t.EventBus})(); |
@@ -19,2 +19,3 @@ // Author Knighttower | ||
const executeOnNodeChanged = {}; | ||
let observer; | ||
/** | ||
@@ -24,2 +25,4 @@ * When node change | ||
* @param {Function} callback Callback when any node changes/ add/deleted/modified | ||
* @memberof DomObserver | ||
* @usage domObserver.addOnNodeChange('elementIdentifier', () => { console.log('Node changed') }) | ||
* @return {Void} | ||
@@ -35,2 +38,4 @@ */ | ||
* @param {String} id | ||
* @memberof DomObserver | ||
* @usage domObserver.removeOnNodeChange('elementIdentifier') | ||
* @return {Void} | ||
@@ -55,4 +60,4 @@ */ | ||
*/ | ||
(() => { | ||
if (typeof window !== 'undefined') { | ||
const start = () => { | ||
if (typeof window !== 'undefined' && !observer) { | ||
const callback = (mutationList) => { | ||
@@ -71,8 +76,21 @@ for (const mutation of mutationList) { | ||
}; | ||
const observer = new MutationObserver(callback); | ||
observer.observe(document.body, config); | ||
observer = new MutationObserver(callback); | ||
if (document.body) { | ||
return observer.observe(document.body, config); | ||
} | ||
document.addEventListener('DOMContentLoaded', (event) => { | ||
return observer.observe(document.body, config); | ||
}); | ||
} | ||
})(); | ||
const DomObserver = { | ||
executeOnNodeChanged, | ||
}; | ||
/** | ||
* @exports domObserver | ||
* @type {Object} | ||
* @usage domObserver.addOnNodeChange('elementIdentifier', () => { console.log('Node changed') }) | ||
* @usage domObserver.removeOnNodeChange('elementIdentifier') | ||
* @usage domObserver.cleanup() | ||
*/ | ||
const domObserver = { | ||
start, | ||
addOnNodeChange, | ||
@@ -83,2 +101,2 @@ removeOnNodeChange, | ||
export { DomObserver, DomObserver as default, DomObserver as domObserver }; | ||
export { domObserver as DomObserver, domObserver as default, domObserver }; |
@@ -19,2 +19,3 @@ // Author Knighttower | ||
const executeOnNodeChanged = {}; | ||
let observer; | ||
/** | ||
@@ -24,2 +25,4 @@ * When node change | ||
* @param {Function} callback Callback when any node changes/ add/deleted/modified | ||
* @memberof DomObserver | ||
* @usage domObserver.addOnNodeChange('elementIdentifier', () => { console.log('Node changed') }) | ||
* @return {Void} | ||
@@ -35,2 +38,4 @@ */ | ||
* @param {String} id | ||
* @memberof DomObserver | ||
* @usage domObserver.removeOnNodeChange('elementIdentifier') | ||
* @return {Void} | ||
@@ -55,4 +60,4 @@ */ | ||
*/ | ||
(() => { | ||
if (typeof window !== 'undefined') { | ||
const start = () => { | ||
if (typeof window !== 'undefined' && !observer) { | ||
const callback = (mutationList) => { | ||
@@ -71,8 +76,21 @@ for (const mutation of mutationList) { | ||
}; | ||
const observer = new MutationObserver(callback); | ||
observer.observe(document.body, config); | ||
observer = new MutationObserver(callback); | ||
if (document.body) { | ||
return observer.observe(document.body, config); | ||
} | ||
document.addEventListener('DOMContentLoaded', (event) => { | ||
return observer.observe(document.body, config); | ||
}); | ||
} | ||
})(); | ||
const DomObserver = { | ||
executeOnNodeChanged, | ||
}; | ||
/** | ||
* @exports domObserver | ||
* @type {Object} | ||
* @usage domObserver.addOnNodeChange('elementIdentifier', () => { console.log('Node changed') }) | ||
* @usage domObserver.removeOnNodeChange('elementIdentifier') | ||
* @usage domObserver.cleanup() | ||
*/ | ||
const domObserver = { | ||
start, | ||
addOnNodeChange, | ||
@@ -104,2 +122,3 @@ removeOnNodeChange, | ||
constructor(selector, scope = document) { | ||
domObserver.start(); | ||
this.selector = selector; | ||
@@ -138,3 +157,3 @@ if (typeof selector === 'object') { | ||
if (!$this.isInDom()) { | ||
DomObserver.addOnNodeChange(callbackId, () => { | ||
domObserver.addOnNodeChange(callbackId, () => { | ||
let element = new ElementHelper($this.selector); | ||
@@ -144,3 +163,3 @@ if (element.isInDom()) { | ||
resolveThis($this); | ||
DomObserver.removeOnNodeChange(callbackId); | ||
domObserver.removeOnNodeChange(callbackId); | ||
} | ||
@@ -161,3 +180,4 @@ }); | ||
getElementByXpath(xpath) { | ||
return document.evaluate(xpath, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue; | ||
return document.evaluate(xpath, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null) | ||
.singleNodeValue; | ||
} | ||
@@ -186,3 +206,8 @@ | ||
return ( | ||
new ElementHelper(element.parentNode).getXpathTo() + '/' + element.tagName + '[' + (ix + 1) + ']' | ||
new ElementHelper(element.parentNode).getXpathTo() + | ||
'/' + | ||
element.tagName + | ||
'[' + | ||
(ix + 1) + | ||
']' | ||
); | ||
@@ -232,3 +257,4 @@ } | ||
const selectElement = (selector, scope = document) => new ElementHelper(selector, scope); | ||
const elementHelper = (selector, scope = document) => new ElementHelper(selector, scope); | ||
export { ElementHelper, ElementHelper as default, ElementHelper as elementHelper, selectElement }; | ||
export { ElementHelper, ElementHelper as default, elementHelper, selectElement }; |
@@ -1,6 +0,5 @@ | ||
let listeners = {}; | ||
class EventBus { | ||
constructor() { | ||
// cleanup | ||
listeners = {}; | ||
this.listeners = {}; | ||
} | ||
@@ -14,3 +13,3 @@ // creates an event that can be triggered any number of times | ||
* @return {void} | ||
* @example eventBus.on('event.name', function() { console.log('event.name was triggered') }) | ||
* @example EventBus.on('event.name', function() { console.log('event.name was triggered') }) | ||
*/ | ||
@@ -26,3 +25,3 @@ on(eventName, callback) { | ||
* @return {void} | ||
* @example eventBus.once('event.name', function() { console.log('event.name was triggered only once') }) | ||
* @example EventBus.once('event.name', function() { console.log('event.name was triggered only once') }) | ||
*/ | ||
@@ -37,3 +36,3 @@ once(eventName, callback) { | ||
* @return {void} | ||
* @example eventBus.exactly('event.name', function() { console.log('event.name was triggered 3 times') }, 3) | ||
* @example EventBus.exactly('event.name', function() { console.log('event.name was triggered 3 times') }, 3) | ||
*/ | ||
@@ -48,6 +47,6 @@ exactly(eventName, callback, capacity) { | ||
* @return {void} | ||
* @example eventBus.off('event.name') | ||
* @example EventBus.off('event.name') | ||
*/ | ||
off(eventName) { | ||
delete listeners[eventName]; | ||
delete this.listeners[eventName]; | ||
} | ||
@@ -60,11 +59,11 @@ /** | ||
* @return {void|boolean} - Returns true if the event was found and removed, void otherwise | ||
* @example eventBus.detach('event.name', callback) | ||
* @example EventBus.detach('event.name', callback) | ||
*/ | ||
detach(eventName, callback) { | ||
const listenersRecords = listeners[eventName] || []; | ||
const listenersRecords = this.listeners[eventName] || []; | ||
const filteredListeners = listenersRecords.filter(function (value) { | ||
return value.callback !== callback; | ||
}); | ||
if (eventName in listeners) { | ||
listeners[eventName] = filteredListeners; | ||
if (eventName in this.listeners) { | ||
this.listeners[eventName] = filteredListeners; | ||
return true; // Event was found and removed | ||
@@ -81,4 +80,4 @@ } | ||
* @use {__context: this|Instance} to pass the context to the callback | ||
* @example eventBus.emit('event.name', arg1, arg2, arg3) | ||
* @example eventBus.emit('event.name', arg1, arg2, arg3, {__context: YourInstance}) | ||
* @example EventBus.emit('event.name', arg1, arg2, arg3) | ||
* @example EventBus.emit('event.name', arg1, arg2, arg3, {__context: YourInstance}) | ||
*/ | ||
@@ -94,3 +93,3 @@ emit(eventName, ...args) { | ||
if (this.hasListener(eventName)) { | ||
queueListeners = listeners[eventName]; | ||
queueListeners = this.listeners[eventName]; | ||
} else { | ||
@@ -101,8 +100,8 @@ // ----------------------------------------- | ||
// case 1, if the incoming string has * or ** in it | ||
// Matches the emit 'eventName' to the registered 'on' listeners | ||
matches = this.patternSearch(eventName, Object.keys(listeners)); | ||
// Matches the emit 'eventName' to the registered 'on' this.listeners | ||
matches = this.patternSearch(eventName, Object.keys(this.listeners)); | ||
if (matches.length > 0) { | ||
matches.forEach((match) => { | ||
queueListeners = queueListeners.concat(listeners[match]); | ||
queueListeners = queueListeners.concat(this.listeners[match]); | ||
}); | ||
@@ -112,8 +111,8 @@ } | ||
// case 2, if the incoming string does not have * or ** in it | ||
// get the patterns from the listeners (on method) and match them to the emit name | ||
for (const key in listeners) { | ||
// get the patterns from the this.listeners (on method) and match them to the emit name | ||
for (const key in this.listeners) { | ||
if (key.includes('*')) { | ||
matches = this.patternSearch(key, [eventName]); | ||
if (matches) { | ||
queueListeners = queueListeners.concat(listeners[key]); | ||
queueListeners = queueListeners.concat(this.listeners[key]); | ||
} | ||
@@ -135,3 +134,3 @@ } | ||
if (this.checkToRemoveListener(listener)) { | ||
listeners[eventName].splice(k, 1); | ||
this.listeners[eventName].splice(k, 1); | ||
} | ||
@@ -187,5 +186,5 @@ callback(...args); | ||
if (!this.hasListener(eventName)) { | ||
listeners[eventName] = []; | ||
this.listeners[eventName] = []; | ||
} | ||
listeners[eventName].push({ callback, triggerCapacity }); | ||
this.listeners[eventName].push({ callback, triggerCapacity }); | ||
} | ||
@@ -199,31 +198,6 @@ checkToRemoveListener(eventInformation) { | ||
hasListener(eventName) { | ||
return eventName in listeners; | ||
return eventName in this.listeners; | ||
} | ||
global() { | ||
return _eventBus(); | ||
} | ||
} | ||
function _eventBus() { | ||
// support for browser | ||
if (typeof window !== 'undefined') { | ||
if (!window.eventBus) { | ||
window.eventBus = new EventBus(); | ||
} | ||
return window.eventBus; | ||
} | ||
if (typeof global !== 'undefined') { | ||
if (!global.eventBus) { | ||
global.eventBus = new EventBus(); | ||
} | ||
return global.eventBus; | ||
} | ||
// if none of the above is available, return a new instance | ||
return new EventBus(); | ||
} | ||
function eventBus() { | ||
return new EventBus(); | ||
} | ||
export { EventBus, _eventBus, eventBus as default, eventBus }; | ||
export { EventBus, EventBus as default }; |
@@ -1,1 +0,1 @@ | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("EventBus",[],t):"object"==typeof exports?exports.EventBus=t():e.EventBus=t()}(this,(()=>(()=>{"use strict";var e={d:(t,r)=>{for(var n in r){e.o(r,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:r[n]})}},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};function r(e){return r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},r(e)}function n(e){return function(e){if(Array.isArray(e)){return o(e)}}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"]){return Array.from(e)}}(e)||function(e,t){if(!e){return}if("string"==typeof e){return o(e,t)}var r=Object.prototype.toString.call(e).slice(8,-1);"Object"===r&&e.constructor&&(r=e.constructor.name);if("Map"===r||"Set"===r){return Array.from(e)}if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)){return o(e,t)}}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function o(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++){n[r]=e[r]}return n}function i(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,a(n.key),n)}}function a(e){var t=function(e,t){if("object"!=r(e)||!e){return e}var n=e[Symbol.toPrimitive];if(void 0!==n){var o=n.call(e,t||"default");if("object"!=r(o)){return o}throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==r(t)?t:t+""}e.r(t),e.d(t,{EventBus:()=>c,_eventBus:()=>l,default:()=>f,eventBus:()=>f});var u={},c=function(){return e=function e(){!function(e,t){if(!(e instanceof t)){throw new TypeError("Cannot call a class as a function")}}(this,e),u={}},t=[{key:"on",value:function(e,t){this.registerListener(e,t)}},{key:"once",value:function(e,t){this.registerListener(e,t,1)}},{key:"exactly",value:function(e,t,r){this.registerListener(e,t,r)}},{key:"off",value:function(e){delete u[e]}},{key:"detach",value:function(e,t){var r=(u[e]||[]).filter((function(e){return e.callback!==t}));return e in u&&(u[e]=r,!0)}},{key:"emit",value:function(e){for(var t=this,r=arguments.length,o=new Array(r>1?r-1:0),i=1;i<r;i++){o[i-1]=arguments[i]}var a=[],c=null,l=this.extractContextFromArgs(o),f=l[0];if(o=l[1],this.hasListener(e)){a=u[e]}else if(e.includes("*")){(c=this.patternSearch(e,Object.keys(u))).length>0&&c.forEach((function(e){a=a.concat(u[e])}))}else{for(var s in u){s.includes("*")&&(c=this.patternSearch(s,[e]))&&(a=a.concat(u[s]))}}a.forEach((function(r,i){var c=r.callback;f&&(c=c.bind(f)),void 0!==r.triggerCapacity&&(r.triggerCapacity--,a[i].triggerCapacity=r.triggerCapacity),t.checkToRemoveListener(r)&&u[e].splice(i,1),c.apply(void 0,n(o))}))}},{key:"patternSearch",value:function(e,t){var r,n=new RegExp(this.setWildCardString(e),"g");return 0===(r=t.filter((function(e){return n.test(e)}))).length?null:r}},{key:"setWildCardString",value:function(e){var t=e.replace(/([.+?^${}()|\[\]\/\\])/g,"\\$&");return t=t.replace(/\*/g,"(.*?)"),"^".concat(t)}},{key:"extractContextFromArgs",value:function(e){for(var t=null,n=0;n<e.length;n++){var o=e[n];if(o&&"object"===r(o)&&o.hasOwnProperty("__context")){t=o.__context,e.splice(n,1);break}}return[t,e]}},{key:"registerListener",value:function(e,t,r){this.hasListener(e)||(u[e]=[]),u[e].push({callback:t,triggerCapacity:r})}},{key:"checkToRemoveListener",value:function(e){return void 0!==e.triggerCapacity&&e.triggerCapacity<=0}},{key:"hasListener",value:function(e){return e in u}},{key:"global",value:function(){return l()}}],t&&i(e.prototype,t),o&&i(e,o),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,t,o}();function l(){return"undefined"!=typeof window?(window.eventBus||(window.eventBus=new c),window.eventBus):"undefined"!=typeof global?(global.eventBus||(global.eventBus=new c),global.eventBus):new c}function f(){return new c}return t})())); | ||
var e,t;e=this,t=()=>(()=>{"use strict";var e={d:(t,r)=>{for(var n in r){e.o(r,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:r[n]})}},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t)},t={};function r(e){return r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},r(e)}function n(e){return function(e){if(Array.isArray(e)){return i(e)}}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"]){return Array.from(e)}}(e)||function(e,t){if(e){if("string"==typeof e){return i(e,t)}var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?i(e,t):void 0}}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function i(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++){n[r]=e[r]}return n}function o(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,a(n.key),n)}}function a(e){var t=function(e,t){if("object"!=r(e)||!e){return e}var n=e[Symbol.toPrimitive];if(void 0!==n){var i=n.call(e,t||"default");if("object"!=r(i)){return i}throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==r(t)?t:t+""}e.d(t,{EventBus:()=>s});var s=function(){return e=function e(){!function(e,t){if(!(e instanceof t)){throw new TypeError("Cannot call a class as a function")}}(this,e),this.listeners={}},t=[{key:"on",value:function(e,t){this.registerListener(e,t)}},{key:"once",value:function(e,t){this.registerListener(e,t,1)}},{key:"exactly",value:function(e,t,r){this.registerListener(e,t,r)}},{key:"off",value:function(e){delete this.listeners[e]}},{key:"detach",value:function(e,t){var r=(this.listeners[e]||[]).filter((function(e){return e.callback!==t}));return e in this.listeners&&(this.listeners[e]=r,!0)}},{key:"emit",value:function(e){for(var t=this,r=arguments.length,i=new Array(r>1?r-1:0),o=1;o<r;o++){i[o-1]=arguments[o]}var a=[],s=null,c=this.extractContextFromArgs(i),l=c[0];if(i=c[1],this.hasListener(e)){a=this.listeners[e]}else if(e.includes("*")){(s=this.patternSearch(e,Object.keys(this.listeners))).length>0&&s.forEach((function(e){a=a.concat(t.listeners[e])}))}else{for(var u in this.listeners){u.includes("*")&&(s=this.patternSearch(u,[e]))&&(a=a.concat(this.listeners[u]))}}a.forEach((function(r,o){var s=r.callback;l&&(s=s.bind(l)),void 0!==r.triggerCapacity&&(r.triggerCapacity--,a[o].triggerCapacity=r.triggerCapacity),t.checkToRemoveListener(r)&&t.listeners[e].splice(o,1),s.apply(void 0,n(i))}))}},{key:"patternSearch",value:function(e,t){var r,n=new RegExp(this.setWildCardString(e),"g");return 0===(r=t.filter((function(e){return n.test(e)}))).length?null:r}},{key:"setWildCardString",value:function(e){var t=e.replace(/([.+?^${}()|\[\]\/\\])/g,"\\$&");return t=t.replace(/\*/g,"(.*?)"),"^".concat(t)}},{key:"extractContextFromArgs",value:function(e){for(var t=null,n=0;n<e.length;n++){var i=e[n];if(i&&"object"===r(i)&&i.hasOwnProperty("__context")){t=i.__context,e.splice(n,1);break}}return[t,e]}},{key:"registerListener",value:function(e,t,r){this.hasListener(e)||(this.listeners[e]=[]),this.listeners[e].push({callback:t,triggerCapacity:r})}},{key:"checkToRemoveListener",value:function(e){return void 0!==e.triggerCapacity&&e.triggerCapacity<=0}},{key:"hasListener",value:function(e){return e in this.listeners}}],t&&o(e.prototype,t),i&&o(e,i),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,t,i}();return t=t.EventBus})(),"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("EventBus",[],t):"object"==typeof exports?exports.EventBus=t():e.EventBus=t(); |
115
index.js
@@ -1,16 +0,13 @@ | ||
// Single Modules and Aliases from: DomObserver | ||
import { domObserver } from './dist/esm/DomObserver.js'; | ||
// Default Module from: DomObserver | ||
import DomObserver from './dist/esm/DomObserver.js'; | ||
// Single Modules and Aliases from: domObserver | ||
import { DomObserver } from './src/domObserver.js'; | ||
// Default Module from: domObserver | ||
import domObserver from './src/domObserver.js'; | ||
// Single Modules and Aliases from: ElementHelper | ||
import { elementHelper, selectElement } from './dist/esm/ElementHelper.js'; | ||
import { selectElement, elementHelper } from './src/ElementHelper.js'; | ||
// Default Module from: ElementHelper | ||
import ElementHelper from './dist/esm/ElementHelper.js'; | ||
// Single Modules and Aliases from: EventBus | ||
import { EventBus, _eventBus } from './dist/esm/EventBus.js'; | ||
import ElementHelper from './src/ElementHelper.js'; | ||
// Default Module from: EventBus | ||
import eventBus from './dist/esm/EventBus.js'; | ||
// Single Modules and Aliases from: PowerHelpers | ||
import EventBus from './src/event-bus/EventBus.js'; | ||
// Single Modules and Aliases from: powerHelper | ||
import { | ||
PowerHelper, | ||
addQuotes, | ||
@@ -22,37 +19,25 @@ cleanStr, | ||
fixQuotes, | ||
getObjectFromPath, | ||
getArrObjFromString, | ||
getChunks, | ||
getDirectivesFromString, | ||
getMatchBlock, | ||
getChunks, | ||
getMatchInBetween, | ||
getObjectFromPath, | ||
removeQuotes, | ||
startAndEndWith, | ||
setExpString, | ||
setLookUpExp, | ||
setWildCardString, | ||
startAndEndWith, | ||
wildCardStringSearch, | ||
} from './dist/esm/PowerHelpers.js'; | ||
// Default Module from: PowerHelpers | ||
import powerHelper from './dist/esm/PowerHelpers.js'; | ||
// Single Modules and Aliases from: PromiseQueue | ||
} from './src/powerHelper.js'; | ||
// Single Modules and Aliases from: promiseQueue | ||
import { promisePool, promiseQueue, doPoll, doTimeout, doAsync } from './src/promiseQueue.js'; | ||
// Single Modules and Aliases from: proxyObject | ||
import { proxyClass } from './src/proxyObject.js'; | ||
// Default Module from: proxyObject | ||
import proxyObject from './src/proxyObject.js'; | ||
// Default Module from: urlHelper | ||
import urlHelper from './src/urlHelper.js'; | ||
// Single Modules and Aliases from: utility | ||
import { | ||
PromisePool, | ||
PromiseQueue, | ||
doAsync, | ||
doPoll, | ||
doTimeout, | ||
promisePool, | ||
promiseQueue, | ||
} from './dist/esm/PromiseQueue.js'; | ||
// Single Modules and Aliases from: ProxyObject | ||
import { ProxyClass, ProxyObject, proxyClass } from './dist/esm/ProxyObject.js'; | ||
// Default Module from: ProxyObject | ||
import proxyObject from './dist/esm/ProxyObject.js'; | ||
// Single Modules and Aliases from: UrlHelper | ||
import { urlHelper } from './dist/esm/UrlHelper.js'; | ||
// Default Module from: UrlHelper | ||
import UrlHelper from './dist/esm/UrlHelper.js'; | ||
// Single Modules and Aliases from: Utility | ||
import { | ||
convertToBool, | ||
@@ -65,35 +50,28 @@ convertToNumber, | ||
formatPhoneNumber, | ||
makeArray, | ||
getDynamicId, | ||
getRandomId, | ||
randomId, | ||
uuid, | ||
uniqueId, | ||
getGoogleMapsAddress, | ||
getRandomId, | ||
includes, | ||
instanceOf, | ||
isEmpty, | ||
isNumber, | ||
makeArray, | ||
instanceOf, | ||
openGoogleMapsAddress, | ||
randomId, | ||
toCurrency, | ||
toDollarString, | ||
typeOf, | ||
uniqueId, | ||
utility, | ||
utils, | ||
uuid, | ||
validateEmail, | ||
validatePhone, | ||
} from './dist/esm/Utility.js'; | ||
// Default Module from: Utility | ||
import Utility from './dist/esm/Utility.js'; | ||
} from './src/utility.js'; | ||
export { | ||
DomObserver, | ||
domObserver, | ||
DomObserver, | ||
selectElement, | ||
elementHelper, | ||
selectElement, | ||
ElementHelper, | ||
EventBus, | ||
_eventBus, | ||
eventBus, | ||
PowerHelper, | ||
addQuotes, | ||
@@ -105,28 +83,22 @@ cleanStr, | ||
fixQuotes, | ||
getObjectFromPath, | ||
getArrObjFromString, | ||
getChunks, | ||
getDirectivesFromString, | ||
getMatchBlock, | ||
getChunks, | ||
getMatchInBetween, | ||
getObjectFromPath, | ||
removeQuotes, | ||
startAndEndWith, | ||
setExpString, | ||
setLookUpExp, | ||
setWildCardString, | ||
startAndEndWith, | ||
wildCardStringSearch, | ||
powerHelper, | ||
PromisePool, | ||
PromiseQueue, | ||
doAsync, | ||
promisePool, | ||
promiseQueue, | ||
doPoll, | ||
doTimeout, | ||
promisePool, | ||
promiseQueue, | ||
ProxyClass, | ||
ProxyObject, | ||
doAsync, | ||
proxyClass, | ||
proxyObject, | ||
urlHelper, | ||
UrlHelper, | ||
convertToBool, | ||
@@ -139,22 +111,19 @@ convertToNumber, | ||
formatPhoneNumber, | ||
makeArray, | ||
getDynamicId, | ||
getRandomId, | ||
randomId, | ||
uuid, | ||
uniqueId, | ||
getGoogleMapsAddress, | ||
getRandomId, | ||
includes, | ||
instanceOf, | ||
isEmpty, | ||
isNumber, | ||
makeArray, | ||
instanceOf, | ||
openGoogleMapsAddress, | ||
randomId, | ||
toCurrency, | ||
toDollarString, | ||
typeOf, | ||
uniqueId, | ||
utility, | ||
utils, | ||
uuid, | ||
validateEmail, | ||
validatePhone, | ||
Utility, | ||
}; |
@@ -5,4 +5,4 @@ #!/usr/bin/env node | ||
import glob from 'glob'; | ||
import { PowerHelper as helper } from '../src/PowerHelpers.js'; | ||
import { Utility as utils } from '../src/Utility.js'; | ||
import * as helper from '../src/powerHelper.js'; | ||
import * as utils from '../src/utility.js'; | ||
import { getFlagValue } from './NodeHelpers.js'; | ||
@@ -21,5 +21,7 @@ | ||
// Example matches: export myVar, export myFunc | ||
const matchSingleExps = content.match(/export\s+(const|let|var|function|class)\s+(\w+)|export\s+(\w+)/g) || []; | ||
const matchSingleExps = | ||
content.match(/export\s+(const|let|var|function|class)\s+(\w+)|export\s+(\w+)/g) || []; | ||
// Example matches: export default class MyClass, export default function myFunc, | ||
const matchDefClasses = content.match(/export\s+default\s+(class|function)\s*(\b(?!(\{|\())\w+\b)/) || []; | ||
const matchDefClasses = | ||
content.match(/export\s+default\s+(class|function)\s*(\b(?!(\{|\())\w+\b)/) || []; | ||
// Example matches: export default Name, Name as default | ||
@@ -34,7 +36,17 @@ const matchDefSingles = | ||
//Example matches: module.exports = { myVar, myFunc } | ||
const matchModuleExports = helper.getMatchInBetween(content, /module\.exports\s*={/g, '}', true); | ||
const matchModuleExports2 = helper.getMatchInBetween(content, /module\.exports\./g, /(=|;)/, true); | ||
const matchModuleExports3 = (content.match(/module\.exports\s*=\s*(\w+)/g) || []).map((module) => | ||
helper.cleanStr(module, 'module.exports', '=') | ||
const matchModuleExports = helper.getMatchInBetween( | ||
content, | ||
/module\.exports\s*={/g, | ||
'}', | ||
true | ||
); | ||
const matchModuleExports2 = helper.getMatchInBetween( | ||
content, | ||
/module\.exports\./g, | ||
/(=|;)/, | ||
true | ||
); | ||
const matchModuleExports3 = (content.match(/module\.exports\s*=\s*(\w+)/g) || []).map( | ||
(module) => helper.cleanStr(module, 'module.exports', '=') | ||
); | ||
@@ -78,25 +90,30 @@ //Example matches: modules.myModule = any | ||
// Handle aliases | ||
[...matchAliasesExps, ...matchModuleExports, ...matchModuleExports2, ...matchModuleExports3].forEach( | ||
(aliasLine) => { | ||
helper | ||
// cleanup and create an array of aliases | ||
.getChunks(helper.cleanStr(aliasLine, 'export', '{', '}')) | ||
// exclude default export | ||
.filter((chunk) => chunk && !chunk.includes('default')) | ||
// iterate to pick the correct alias; | ||
.forEach((chunk) => { | ||
if (chunk.includes(' as ')) { | ||
const alias = helper.getChunks(chunk, ' as '); | ||
if (alias[1]) { | ||
aliasExports.push(alias[1]); | ||
} | ||
} else { | ||
aliasExports.push(chunk); | ||
[ | ||
...matchAliasesExps, | ||
...matchModuleExports, | ||
...matchModuleExports2, | ||
...matchModuleExports3, | ||
].forEach((aliasLine) => { | ||
helper | ||
// cleanup and create an array of aliases | ||
.getChunks(helper.cleanStr(aliasLine, 'export', '{', '}')) | ||
// exclude default export | ||
.filter((chunk) => chunk && !chunk.includes('default')) | ||
// iterate to pick the correct alias; | ||
.forEach((chunk) => { | ||
if (chunk.includes(' as ')) { | ||
const alias = helper.getChunks(chunk, ' as '); | ||
if (alias[1]) { | ||
aliasExports.push(alias[1]); | ||
} | ||
}); | ||
} | ||
); | ||
} else { | ||
aliasExports.push(chunk); | ||
} | ||
}); | ||
}); | ||
// Merge all named exports and filter | ||
namedExports = [...aliasExports, ...singleExports].filter((name) => name !== 'default' && name !== defaultExport); | ||
namedExports = [...aliasExports, ...singleExports].filter( | ||
(name) => name !== 'default' && name !== defaultExport | ||
); | ||
@@ -190,3 +207,5 @@ return { | ||
const singleFile = getFlagValue('file') ?? false; | ||
const out = getFlagValue('out') ? helper.cleanStr(getFlagValue('out'), '.js', '.mjs', '.cjs', '.ts') : null; | ||
const out = getFlagValue('out') | ||
? helper.cleanStr(getFlagValue('out'), '.js', '.mjs', '.cjs', '.ts') | ||
: null; | ||
const destination = out ? `${out}.${ext}` : `${workingDir}/index.${ext}`; | ||
@@ -197,3 +216,5 @@ // Synchronously fetch all file paths within a esmDir and its subdirectories | ||
const processFiles = () => { | ||
const filePaths = !singleFile ? glob.sync(`${dir}/**/*.{js,mjs,cjs}`) : glob.sync(`${singleFile}`); | ||
const filePaths = !singleFile | ||
? glob.sync(`${dir}/**/*.{js,mjs,cjs}`) | ||
: glob.sync(`${singleFile}`); | ||
const allExports = {}; | ||
@@ -207,3 +228,4 @@ | ||
const indexContent = type === 'cjs' ? getCommonJsContent(allExports) : getEsmContent(allExports); | ||
const indexContent = | ||
type === 'cjs' ? getCommonJsContent(allExports) : getEsmContent(allExports); | ||
@@ -210,0 +232,0 @@ fs.writeFileSync(destination, indexContent); |
{ | ||
"name": "@knighttower/utility", | ||
"version": "6.0.7", | ||
"version": "7.0.9", | ||
"type": "module", | ||
"main": "index.cjs", | ||
"module": "index.js", | ||
"jsdelivr": "dist/browser/Utility.js", | ||
"browser": "dist/browser/Utility.js", | ||
"jsdelivr": "dist/browser/utility.js", | ||
"browser": "dist/browser/utility.js", | ||
"license": "MIT", | ||
@@ -32,4 +32,4 @@ "publishConfig": { | ||
"./proxyObject": { | ||
"import": "./dist/esm/ProxyObject.js", | ||
"require": "./dist/cjs/ProxyObject.cjs" | ||
"import": "./dist/esm/proxyObject.js", | ||
"require": "./dist/cjs/proxyObject.cjs" | ||
}, | ||
@@ -41,10 +41,10 @@ "./proxyClass": { | ||
"./powerHelpers": { | ||
"import": "./dist/esm/PowerHelpers.js", | ||
"require": "./dist/cjs/PowerHelpers.cjs" | ||
"import": "./dist/esm/powerHelper.js", | ||
"require": "./dist/cjs/powerHelper.cjs" | ||
}, | ||
"./promiseQueue": { | ||
"import": "./dist/esm/PromiseQueue.js", | ||
"require": "./dist/cjs/PromiseQueue.cjs" | ||
"import": "./dist/esm/promiseQueue.js", | ||
"require": "./dist/cjs/promiseQueue.cjs" | ||
}, | ||
"./eventBus": { | ||
"./EventBus": { | ||
"import": "./dist/esm/EventBus.js", | ||
@@ -63,3 +63,3 @@ "require": "./dist/cjs/EventBus.cjs" | ||
"keywords": [ | ||
"Utility", | ||
"utility", | ||
"Vue", | ||
@@ -66,0 +66,0 @@ "react", |
213
README.md
@@ -1,2 +0,2 @@ | ||
# JS Utility Library Documentation | ||
# JS utility Library Documentation | ||
@@ -8,22 +8,2 @@ ## Collection of libraries with classes and functions for JavaScript | ||
<br/> | ||
## Node, NPM and Browser ready (esm, cjs, umd...) | ||
- [Utility](https://github.com/knighttower/JsUtility/blob/development/packages/utility/src/Utility.js): A collection of utility functions for common cases | ||
- [EventBus](https://github.com/knighttower/JsUtility/tree/development/packages/utility/src/event-bus): A class for creating event buses | ||
- [PromiseQueue](https://github.com/knighttower/JsUtility/blob/development/packages/utility/src/PromiseQueue.js): A class for managing promises in a queue and polling | ||
- [PowerHelpers](https://github.com/knighttower/JsUtility/blob/development/packages/utility/src/PowerHelpers.js): A collection of powerful functions for regex and string manipulation | ||
- [ProxyObject](https://github.com/knighttower/JsUtility/blob/development/packages/utility/src/ProxyObject.js): A class for working with proxy objects | ||
- [ProxyClass](https://github.com/knighttower/JsUtility/blob/development/packages/utility/src/ProxyObject.js): A class for working with proxy classes | ||
- [DomObserver](https://github.com/knighttower/JsUtility/blob/development/packages/utility/src/DomObserver.js): A class for observing DOM changes | ||
- [UrlHelper](https://github.com/knighttower/JsUtility/blob/development/packages/utility/src/UrlHelper.js): A class for working with URLs | ||
- [ElementHelper](https://github.com/knighttower/JsUtility/blob/development/packages/utility/src/ElementHelper.js): extra functionlality for working with elements in DOM | ||
<br/> | ||
## Node ONLY | ||
- [NodeHelpers](https://github.com/knighttower/JsUtility/blob/development/packages/utility/nodeUtils/NodeHelpers.cjs): A collection of functions for working with NodeJS | ||
- [Minify](https://github.com/knighttower/JsUtility/blob/development/packages/utility/nodeUtils/Minify.js): A class for minifying files | ||
- [Rollup](https://github.com/knighttower/JsUtility/blob/development/packages/utility/nodeUtils/rollup.config.cjs) Config: Advanced Rollup configuration for building libraries | ||
- [Webpack](https://github.com/knighttower/JsUtility/blob/development/packages/utility/nodeUtils/webpack.config.cjs) Config: Advanced Webpack configuration for building libraries | ||
## Installation | ||
@@ -37,3 +17,81 @@ | ||
### @exports included | ||
```javascript | ||
Here is a list of the export paths: | ||
- `@knighttower/utility` (DEFAULT entry: exports all libraries) | ||
export { | ||
DomObserver, | ||
domObserver, | ||
elementHelper, | ||
selectElement, | ||
ElementHelper, | ||
EventBus, | ||
addQuotes, | ||
cleanStr, | ||
convertKeysToSymbols, | ||
findAndReplaceInArray, | ||
findNested, | ||
fixQuotes, | ||
getArrObjFromString, | ||
getChunks, | ||
getDirectivesFromString, | ||
getMatchBlock, | ||
getMatchInBetween, | ||
getObjectFromPath, | ||
removeQuotes, | ||
setExpString, | ||
setLookUpExp, | ||
setWildCardString, | ||
startAndEndWith, | ||
wildCardStringSearch, | ||
powerHelper, | ||
doAsync, | ||
doPoll, | ||
doTimeout, | ||
promisePool, | ||
promiseQueue, | ||
proxyClass, | ||
proxyObject, | ||
urlHelper, | ||
convertToBool, | ||
convertToNumber, | ||
currencyToDecimal, | ||
dateFormat, | ||
decimalToCurrency, | ||
emptyOrValue, | ||
formatPhoneNumber, | ||
getDynamicId, | ||
getGoogleMapsAddress, | ||
getRandomId, | ||
includes, | ||
instanceOf, | ||
isEmpty, | ||
isNumber, | ||
makeArray, | ||
openGoogleMapsAddress, | ||
randomId, | ||
toCurrency, | ||
toDollarString, | ||
typeOf, | ||
uniqueId, | ||
uuid, | ||
validateEmail, | ||
validatePhone, | ||
}; | ||
// INDIVIDUALLY | ||
- `@knighttower/utility/dist/*` (all libraries in the dist folder (umd, cjs, esm..)) | ||
- `@knighttower/utility/node/*` (all node libraries) | ||
- `@knighttower/utility/nodeUtils/*` (all node utilities) | ||
- `@knighttower/utility/nodeUtils` (default export) | ||
- `@knighttower/utility/proxyObject` (default export) | ||
- `@knighttower/utility/proxyClass` (default export) | ||
- `@knighttower/utility/powerHelpers` (default export) | ||
- `@knighttower/utility/promiseQueue` (default export) | ||
- `@knighttower/utility/EventBus` (default export) | ||
- `@knighttower/utility/event-bus` (default export) | ||
``` | ||
<br/> | ||
## In the browser | ||
@@ -43,8 +101,5 @@ Each library can be loaded individually or all at once. The library is also available via CDN. | ||
```html | ||
<script src="https://cdn.jsdelivr.net/npm/@knighttower/utility@latest/dist/browser/Utility.min.js"></script> | ||
// in addition, you can also load other libraries | ||
<script src="https://cdn.jsdelivr.net/npm/@knighttower/utility@latest/dist/browser/PowerHelpers.min.js"></script> | ||
<script src="https://cdn.jsdelivr.net/npm/@knighttower/utility@latest/dist/browser/UrlHelper.min.js"></script> | ||
<script src="https://cdn.jsdelivr.net/npm/@knighttower/utility@VERSION_NUMBER/dist/browser/LIBRARY_NAME.min.js"></script> | ||
//or ESM | ||
<script src="https://esm.run/@knighttower/utility@latest/index.mjs"></script> | ||
<script src="https://esm.run/@knighttower/utility@VERSION_NUMBER/index.mjs"></script> | ||
``` | ||
@@ -54,5 +109,89 @@ | ||
## Node, NPM and Browser ready (esm, cjs, umd...) | ||
## List of functions included in Utility | ||
- [utility](https://github.com/knighttower/JsUtility/blob/development/packages/utility/src/utility.js): A collection of utility functions for common cases | ||
ℹ [docs](https://github.com/knighttower/JsUtility/blob/development/packages/utility/docs/utils.md) | ||
@imports | ||
* all, or import individual functions from the utility library; | ||
<br/> | ||
- [EventBus](https://github.com/knighttower/JsUtility/tree/development/packages/utility/src/event-bus): A class for creating event buses | ||
ℹ [docs](https://github.com/knighttower/JsUtility/blob/development/packages/utility/src/event-bus) | ||
@imports | ||
- class EventBus | ||
<br/> | ||
- [promiseQueue](https://github.com/knighttower/JsUtility/blob/development/packages/utility/src/promiseQueue.js): A class for managing promises in a queue and polling | ||
@imports | ||
- doAsync, | ||
doPoll, | ||
doTimeout, | ||
promisePool, | ||
promiseQueue, | ||
<br/> | ||
- [powerHelper](https://github.com/knighttower/JsUtility/blob/development/packages/utility/src/powerHelper.js): A collection of powerful functions for regex and string manipulation | ||
@imports | ||
- all, or import individual functions from the powerHelper library; | ||
<br/> | ||
- [proxyObject](https://github.com/knighttower/JsUtility/blob/development/packages/utility/src/proxyObject.js): A class for working with proxy objects | ||
ℹ [docs](https://github.com/knighttower/JsUtility/blob/development/packages/utility/docs/proxyObject.md) | ||
@imports | ||
- proxyObject, proxyObject as default, proxyClass | ||
<br/> | ||
- [proxyClass](https://github.com/knighttower/JsUtility/blob/development/packages/utility/src/proxyObject.js): A class for working with proxy classes | ||
@imports | ||
- proxyObject, proxyObject as default, proxyClass | ||
<br/> | ||
- [domObserver](https://github.com/knighttower/JsUtility/blob/development/packages/utility/src/domObserver.js): A class for observing DOM changes | ||
ℹ [docs](https://github.com/knighttower/JsUtility/blob/development/packages/utility/docs/domObserver.md) | ||
@imports | ||
- domObserver, domObserver as default | ||
<br/> | ||
- [urlHelper](https://github.com/knighttower/JsUtility/blob/development/packages/utility/src/urlHelper.js): A class for working with URLs | ||
@imports | ||
- urlHelper, urlHelper as default | ||
<br/> | ||
- [ElementHelper](https://github.com/knighttower/JsUtility/blob/development/packages/utility/src/ElementHelper.js): extra functionlality for working with elements in DOM | ||
@imports | ||
- ElementHelper as default, ElementHelper, selectElement, elementHelper | ||
<br/> | ||
<br/> | ||
## Node ONLY | ||
- [NodeHelpers](https://github.com/knighttower/JsUtility/blob/development/packages/utility/nodeUtils/NodeHelpers.cjs): A collection of functions for working with NodeJS | ||
- [Minify](https://github.com/knighttower/JsUtility/blob/development/packages/utility/nodeUtils/Minify.js): A class for minifying files | ||
- [Rollup](https://github.com/knighttower/JsUtility/blob/development/packages/utility/nodeUtils/rollup.config.cjs) Config: Advanced Rollup configuration for building libraries | ||
- [Webpack](https://github.com/knighttower/JsUtility/blob/development/packages/utility/nodeUtils/webpack.config.cjs) Config: Advanced Webpack configuration for building libraries | ||
## List of functions included in utility | ||
```javascript | ||
@@ -86,5 +225,5 @@ { | ||
You can see the src with github and explore the functions by using the "symbols explorer" from Github [here](https://github.com/knighttower/JsUtility/blob/development/src/Utility.js) | ||
You can see the src with github and explore the functions by using the "symbols explorer" from Github [here](https://github.com/knighttower/JsUtility/blob/development/src/utility.js) | ||
# List of functions included in PowerHelpers | ||
# List of functions included in powerHelper | ||
@@ -114,3 +253,3 @@ ```javascript | ||
You can see the src with github and explore the functions by using the "symbols explorer" from Github [here](https://github.com/knighttower/JsUtility/blob/development/src/PowerHelpers.js) | ||
You can see the src with github and explore the functions by using the "symbols explorer" from Github [here](https://github.com/knighttower/JsUtility/blob/development/src/powerHelper.js) | ||
@@ -126,3 +265,3 @@ | ||
All functions are handy, but the most handy of all is **"emptyOrValue"** which helps to mitigate a lot of headaches when dealing with variables to know whether or not they have a value or even to set a default value when empty. From the PowerHelpers, there are a lot of regex and string functions that are very handy. | ||
All functions are handy, but the most handy of all is **"emptyOrValue"** which helps to mitigate a lot of headaches when dealing with variables to know whether or not they have a value or even to set a default value when empty. From the powerHelper, there are a lot of regex and string functions that are very handy. | ||
All Functions have also been Unit Tested and tests are in the source code if you want to experiment or see more examples. | ||
@@ -138,9 +277,9 @@ | ||
// All other modules can also be imported individually from the same path | ||
import Utility from '@knighttower/utility'; | ||
import utility from '@knighttower/utility'; | ||
//and or | ||
import PowerHelpers from '@knighttower/utility'; | ||
import powerHelper from '@knighttower/utility'; | ||
// or | ||
import { functionThatYouWantToUse, otherFunction } from '@knighttower/utility'; | ||
// or | ||
import { Utility as yourCustomName } from '@knighttower/utility'; | ||
import { utility as yourCustomName } from '@knighttower/utility'; | ||
import { functionThatYouWantToUse } from 'https://cdn.jsdelivr.net/npm/@knighttower/utility@latest/index.mjs'; | ||
@@ -156,3 +295,3 @@ ``` | ||
... plugins: [ | ||
AutoImport({ imports: [ { '@knighttower/utility': ['Utility'] }] }), | ||
AutoImport({ imports: [ { '@knighttower/utility': ['utility'] }] }), | ||
] | ||
@@ -162,4 +301,4 @@ | ||
let something = Utility.theFunctionYouWantToUse(); | ||
//ex: Utility.emptyOrValue() // Autoimport will only import the 'emptyOrValue' module automatically | ||
let something = utility.theFunctionYouWantToUse(); | ||
//ex: utility.emptyOrValue() // Autoimport will only import the 'emptyOrValue' module automatically | ||
``` | ||
@@ -166,0 +305,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
306
361399
51
6641
2