@randajan/jet-core
Advanced tools
Comparing version 3.0.10 to 3.0.11
1211
dist/index.js
@@ -1,3 +0,1210 @@ | ||
var be=Object.defineProperty;var ye=(e,t)=>{for(var r in t)be(e,r,{get:t[r],enumerable:!0})};var E=class extends Function{static extend(t,r={}){for(let o in r)Object.defineProperty(t,o,{value:r[o],enumerable:!0});return t}constructor(t,r={}){super();return E.extend(Object.setPrototypeOf(t?t.bind():this,new.target.prototype),r)}},M=E;var te={},I=new Map,re={},oe=(e,t)=>`jet${t?` type '${t}'`:""} ${e}`,j=(e,t)=>{throw oe(e,t)},ne=(e,t)=>{console.warn(oe(e,t))},S=e=>te[e],se=e=>{let t=I.get(e);return t?t[0]:void 0},V=(e,t,r=!0)=>{if(!t.is||t.is(e))return r?t:t.name},ee=(e,t,r=!0)=>{let o=I.get(t);if(!!o){if(o.length===1)return V(e,o[0],r);for(let n of o){let s=V(e,n,r);if(s)return s}}},ie=(e,t,r=!0)=>{if(e==null)return;if(t)return ee(e,e.__proto__,r);let o,n=e;do o=ee(e,n=n.__proto__,r);while(n&&o===void 0);return o},b=(e,t=!0)=>ie(e,t,!0),je=(e,t=!0)=>ie(e,t,!1),ue=e=>{te[e.name]=e,Object.defineProperty(re,e.name,{enumerable:!0,value:e.constructor});let t=I.get(e.prototype);t?t.unshift(e):I.set(e.prototype,[e])},p=new M(je,{types:re});var W=["only","full","tap","pull","is","to","copy","rnd"],_e=e=>{let t=typeof e;return e!=null&&(t==="function"||t==="object")},we=(e,t)=>t instanceof e,$=(e,t,r=!0)=>{if(!e)return!1;let o=S(e);if(o)return t==null||r&&t.__proto__!==o.prototype||!r&&!(t instanceof o.constructor)?!1:!o.is||o.is(t);let n=typeof e;return n==="string"?typeof t===e:t==null||n!=="function"&&n!=="object"?!1:r?t.constructor===e:t instanceof e},R=(e,t)=>{if(!t)return e===!1||e===0||!!e;for(let r of t(e))if(r!=null)return!0;return!1},le=(e,t,r,...o)=>{if(e[t])return e[t](...o);r&&j(`undefined operation '${t}' - unavailable for this type`,e.name)},Z=(e,t,r,...o)=>{let n=S(e);if(n)return le(n,t,r,...o);r&&j(`unable execute '${t}' - type unknown`,e)},O=(e,t,r,...o)=>{let n=b(e,!1);if(n)return le(n,t,r,e,...o);r&&j(`unable execute '${t}' - missing type of '${e}'`)},_=(e,t,...r)=>{let o=S(e),n=_e(e);n&&t>0&&j(`unable execute '${W[t]}' - unavailable for plain constructors`),e&&!n&&!o&&j(`unable execute '${W[t]}' - type unknown`,e),!e&&t!==1&&j(`unable execute '${W[t]}' - type missing`);for(let s of r)if(n){if(we(e,s))return s}else{let i=b(s);if((!e||i&&i.name===e)&&(t!==1||i&&i.full(s)||!i&&R(s)))return t===3?i.copy(s):s}if(t>1)return o.create()},k=(e,t,...r)=>{let o=S(e);o||j("unable execute 'to' - type unknown",e);let n=b(t,!1);if(!n)return o.create();if(o.name===n.name)return t;let s=n.to[e]||n.to["*"];return s?k(e,s(t,...r),...r):o.create(t)},C=(e,t,r)=>{let o=typeof t,n=S(e);n||j("unable define 'to' - type unknown",e);let s=n.to;if(o==="function")s["*"]=t;else if(o==="object"&&Array.isArray(t))for(let i in t)s[t[i]]=r;else if(o==="object")for(let i in t)s[i]=t[i];else s[t]=r},T=(e,t,r,o)=>{if(!e)return;e=Array.from(e);let n=e.length;return e[Math.floor(Number.jet.rnd(Number.jet.frame(t||0,0,n),Number.jet.frame(r||n,0,n),o))]};var H=!0,Ne=(e,t,r={})=>{let{create:o,is:n,full:s,copy:i,rnd:u,keys:f,vals:a,entries:d,get:y,set:m,rem:h,to:A,extend:v,extendPrototype:F,extendConstructor:U}=r;S(e)&&j("is allready defined",e),t||j("constructor missing",e),(f||a||d)&&!(f&&a&&d)&&j("keys, vals or entries missing",e);let L=t.prototype;o=o||((...c)=>new t(...c)),i=i||(c=>c);let q=U===!1?null:typeof U=="object"?U:{},D=F===!1?null:typeof F=="object"?F:{},z,B;if(v!==!1){let c=se(L);c?ne(`constructor allready extended as '${c}'. Use option 'extend=false'`,e):(q&&Object.defineProperty(t,"jet",{value:z={}}),D&&(B={},Object.defineProperty(L,"jet",{get:function(){return{__:this,...B}}})))}let g=(c,x,N)=>{c&&B&&Object.defineProperty(B,x,{enumerable:H,value:c<2?N:function(...J){return N(this.__,...J)}}),z&&Object.defineProperty(z,x,{enumerable:H,value:N}),p[x]&&Object.defineProperty(p[x],e,{enumerable:H,value:N})};if(g(0,"create",o),g(0,"is",(c,x=!0)=>$(e,c,x)),g(0,"to",(c,...x)=>k(e,c,...x)),g(0,"only",(...c)=>_(e,0,...c)),g(0,"full",(...c)=>_(e,1,...c)),g(0,"tap",(...c)=>_(e,2,...c)),g(0,"pull",(...c)=>_(e,3,...c)),g(0,"rnd",u=u||o),g(2,"isFull",s=s||(c=>R(c,a))),d&&(g(2,"keys",f),g(2,"vals",a),g(2,"entries",d),g(2,"get",y=y||((c,x)=>c[x])),g(2,"set",m=m||((c,x,N)=>c[x]=N)),g(2,"rem",h=h||((c,x)=>delete c[x])),g(2,"getRND",(c,x,N,J)=>T(a(c),x,N,J))),ue({name:e,constructor:t,prototype:L,is:n,create:o,full:s,copy:i,rnd:u,keys:f,vals:a,entries:d,get:y,set:m,rem:h,to:{}}),C(e,A),z)for(let c in q)g(0,c,q[c]);if(B)for(let c in D)g(p.isRunnable(D[c])?2:1,c,D[c]);return t},ce=Ne;var K={};ye(K,{assign:()=>Pe,compare:()=>Me,deflate:()=>G,dig:()=>he,digIn:()=>Y,digOut:()=>Oe,forEach:()=>w,inflate:()=>ve,json:()=>Ae,map:()=>Se,melt:()=>ge,merge:()=>Fe,prop:()=>xe,reducer:()=>de});var ae=({create:e,entries:t,set:r},o,n,s,i,u,f,a,d)=>{let y=f||e();for(let[m,h]of t(o)){let A=(u?u+".":"")+m,v=s||!n?b(h):null,F=s&&v&&v.entries;if(F?i?h=s(h,A,u,m,a):h=ae(v,h,n,s,i,A,f,a,d):h=n?n(h,A,u,m,a):v?v.copy(h):h,h!==void 0&&(f?F||f.push(h):r(y,m,h)),d())break}return y},pe=(e,t,r,o,n)=>{let s=b(e);o=String.jet.to(o,".");let i,u=a=>i=!0;if(s&&s.entries)return ae(s,e,t,r,p.isRunnable(r),o,n,u,a=>i);let f=t?t(e,o,"",o,u):s.copy?s.copy(e):e;return n&&f!==void 0&&n.push(f),n||f},w=(e,t,r=!1,o="")=>pe(e,t,r,o,[]),Se=(e,t,r=!1,o="")=>pe(e,t,r,o),de=e=>{let t=0,r;return r=(...o)=>e(r,t++,...o)},he=(e,t,r)=>{let o=String.jet.to(t,".").split("."),n=o.length-1;return de((s,i,u)=>{let f=o.slice(0,i).join(".");return r(s,u,(f?f+".":"")+o[i],f,o[i],i===n)})(e)},Oe=(e,t,r)=>{if(t=String.jet.to(t,"."),!t)return e;for(let o of t.split("."))if((e=p.get(e,o,!1))==null)return r;return e},Y=(e,t,r,o=!0,n=void 0)=>{let s=(i,u,f,a,d,y)=>{let m=b(u);if(!m||!m.entries){if(!o)return u;u=String.jet.isNumeric(d)?[]:{},m=b(u)}let h=y?r:i(m.get(u,d,!1));if(h!=null)return m.set(u,d,h,!1),u;if(m.rem(u,d),m.full(u))return u};return he(e,t,p.isRunnable(n)?(i,u,f,a,d,y)=>n(m=>s(i,m,f,a,d,y),u,f,a,d,y):s)},G=(e,t=!1)=>{let r={},o=(s,i)=>{r[i]=s},n=(s,i)=>{o(s,i),w(s,o,n,i)};return w(e,o,t?n:!0),t&&(r[""]=e),r},ve=(e,t=!0)=>{let r={};for(let o of p.keys(e).sort())!t&&p.isMapable(e[o])||Y(r,"to."+o,e[o],!0);return r.to},me=(e,t,...r)=>{let o={to:t},n=G(o.to,!0),s=(u,f)=>{o.to=Y(o.to,f,u)},i=(u,f)=>{n[f]||s(n[f]=b(u).create(),f),Array.isArray(u)&&Array.isArray(n[f])?n[f].push(...u):w(u,s,i,f)};for(let u of r)w(u,s,!!e||i);return o.to},Pe=(e,t,r=!0)=>me(r,e,t),Fe=(...e)=>me(!1,{},...e),Me=(e,t,r=!1)=>{let o=[];if(!r&&e===t)return!0;let n=G(e);w(t,(s,i,u,f,a)=>{n[i]!==s&&o.push(i),delete n[i],o.length&&!r&&a()},!0);for(let s in n){if(o.length&&!r)break;o.push(s)}return r?o:!o.length},ge=(e,t)=>{let r="",o=String.jet.to(t);return p.isMapable(e)?(w(e,n=>{n=ge(n,o),r+=n?(r?o:"")+n:""}),r):String.jet.to(e,o)},xe={add:(e,t,r,o=!1,n=!1,s=!0)=>(p.isMapable(t)?w(t,(i,u)=>{let f=String.jet.isNumeric(u);xe.add(e,f?i:u,f?r:i,o,n,s)}):(!e[t]||s)&&Object.defineProperty(e,t,{value:r,writable:o,configurable:o,enumerable:n}),e),get:(e,t)=>{if(t||(t=Array.from(Object.getOwnPropertyNames(e))),!p.isMapable(t))return e[t];let r={};return w(t,o=>r[o]=e[o]),r}},Ae={from:(e,t=!1)=>{if(p.isMapable(e))return e;try{return JSON.parse(String.jet.to(e))}catch(r){if(t===!0)throw r}},to:(e,t=!1)=>{let r=Number.jet.only(t===!0?2:t);return JSON.stringify(p.isMapable(e)?e:{},null,r)}};M.extend(p,{is:$,to:k,isFull:e=>{let t=b(e,!1);return t?t.full(e):R(e)},isMapable:(e,t=!0)=>{let r=b(e,t);return r?!!r.entries:!1},isRunnable:e=>typeof e=="function",full:(...e)=>_(null,1,...e),only:(e,...t)=>_(e,0,...t),tap:(e,...t)=>_(e,2,...t),pull:(e,...t)=>_(e,3,...t),create:(e,...t)=>Z(e,"create",!0,...t),rnd:(e,...t)=>Z(e,"rnd",!0,...t),copy:(e,t=!1,r=!1)=>t?p.map(e,r?void 0:o=>o,!0):O(e,"copy"),keys:(e,t=!1)=>O(e,"keys",t)||[],vals:(e,t=!1)=>O(e,"vals",t)||[],entries:(e,t=!1)=>O(e,"entries",t)||[],get:(e,t,r=!1)=>O(e,"get",r,t),set:(e,t,r,o=!1)=>O(e,"set",o,t,r),rem:(e,t,r=!0)=>O(e,"rem",r,t),getRND:(e,t,r,o)=>{let n=b(e);if(n&&n.vals)e=n.vals(e);else if(typeof e=="string")return T(e,t,r,o)},run:(e,...t)=>{if(p.isRunnable(e))return e(...t);if(!!p.isMapable(e))return p.forEach(e,r=>p.isRunnable(r)?r(...t):void 0,!0)},...K,define:new M(ce,{to:C})});p.define("Plex",M,{copy:e=>Object.defineProperties({},Object.getOwnPropertyDescriptors(e)),keys:e=>Object.keys(e),vals:e=>Object.values(e),entries:e=>Object.entries(e)});var l=p;var Be=l.define("Object",Object,{create:Object,copy:e=>Object.defineProperties({},Object.getOwnPropertyDescriptors(e)),keys:e=>Object.keys(e),vals:e=>Object.values(e),entries:e=>Object.entries(e),extendPrototype:!1,to:{Function:e=>t=>e,Symbol:e=>Symbol(l.json.to(e)),Boolean:e=>l.isFull.Object(e),Number:e=>Object.values(e),Array:e=>Object.values(e),String:e=>l.json.to(e),Promise:async e=>e,Error:e=>l.json.to(e),RegExp:(e,t)=>l.melt(e,t??"|")}});var Re=l.define("Boolean",Boolean,{create:Boolean,rnd:e=>Math.random()<(e||.5),to:{Function:e=>t=>e}});var ke=l.define("Number",Number,{create:Number,rnd:(e,t,r)=>{let o=Math.random();return r?o=Math.pow(o,2):r===!1&&(o=Math.sqrt(o)),o.jet.fromRatio(e||0,t||e*2||1)},to:{Function:e=>t=>e,Boolean:e=>!!e,Array:(e,t)=>t?[e]:Array(e),Promise:async e=>e,String:e=>String(e)},extendPrototype:{x:(e,t,r)=>{let o=t,n=Number.jet.zoomIn(e,r),[s,i]=n;return o==="/"?s/i:o==="*"?s*i/Math.pow(n.zoom,2):(o==="+"?s+i:o==="-"?s-i:o==="%"?s%i:NaN)/n.zoom},frame:(e,t,r)=>(e=r==null?e:Math.min(e,r),t==null?e:Math.max(e,t)),round:(e,t,r)=>{let o=Math.pow(10,t||0);return Math[r==null?"round":r?"ceil":"floor"](e*o)/o},len:(e,t)=>{let r=t,o=String.jet.to(e),n=o.length,s=o.indexOf("."),i=s>=0;return r===!1?i?n-s-1:0:!i||!r?n:s},period:(e,t,r)=>{let o=r-t;return(o+(e-t)%o)%o+t},toRatio:(e,t,r)=>{let o=r-t;return o?(e-t)/o:0},fromRatio:(e,t,r)=>{let o=r-t;return e*o+t},zoomIn:(...e)=>{let t=Math.pow(10,Math.max(...e.map(r=>Number.jet.len(r,!1))));return l.prop.add(e.map(r=>Math.round(r*t)),"zoom",t)},zoomOut:(...e)=>e.map(t=>t/e.zoom),diffusion:(e,t,r,o)=>{let n=e*o;return Number.jet.rnd(Math.max(t,e-n),Math.min(r,e+n))},snap:(e,t,r,o,n,s=!0)=>{var i=e,u=t,f=r,a=o,d=f!=null,y=a!=null,m=n;if(i==null||u==null||u<=0||!(d||y))return i;s&&(i=Number.jet.frame(i,f,a));var h=d?i-f:a-i;return i=h%u?(d?f:a)+Number.jet.round(h/u,0,m==null?null:m===d)*u*(d*2-1):i,s?Number.jet.frame(i,f,a):i},whatpow:(e,t)=>Math.log(e)/Math.log(Number.jet.to(t)),toHex:e=>{var t=Math.round(e).toString(16);return t.length===1?"0"+t:t},toLetter:(e,t)=>{t=String.jet.to(t)||"ABCDEFGHIJKLMNOPQRSTUVWXYZ";let r=t.length;return(e>=r?Number.jet.toLetter(Math.floor(e/r)-1):"")+t[e%r]}}});var De={point:"\u2022",cross:"\xD7",flake:"\u2600",draft:"\u232D",power:"\u26A1",star:"\u2605",skull:"\u2620",card:"\u2660\u2665\u2666\u2663",notes:"\u2669\u266A\u266B\u266C\u266D\u266E\u266F",chess:"\u2654\u2655\u2656\u2657\u2658\u2659\u265A\u265B\u265C\u265D\u265E\u265F",block:"\u2596\u2597\u2598\u2599\u259A\u259B\u259C\u259D\u259E\u259F",bar:"\u2502\u2551 \u258C\u2590\u2588",iting:"\u2630\u2631\u2632\u2633\u2634\u2635\u2636\u2637",astro:"\u2648\u2649\u264A\u264B\u264C\u264D\u264E\u264F\u2650\u2651\u2652\u2653",die:"\u2680\u2681\u2682\u2683\u2684\u2685",runic:"\u16A0\u16A1\u16A2\u16A3\u16A4\u16A5\u16A6\u16A7\u16A8\u16A9\u16AA\u16AB\u16AC\u16AD\u16AE\u16AF\u16B0\u16B1\u16B3\u16B4\u16B5\u16B6\u16B7\u16B8\u16B9\u16BA\u16BB\u16BC\u16BD\u16BE\u16BF\u16C0\u16C1\u16C2\u16C3\u16C4\u16C5\u16C6\u16C7\u16C8\u16C9\u16CA\u16CB\u16CF\u16D0\u16D1\u16D2\u16D3\u16D4\u16D5\u16D6\u16D7\u16D8\u16D9\u16DA\u16DB\u16DC\u16DD\u16DE\u16DF\u16E0\u16E1\u16E2\u16E3\u16E4\u16E5\u16E6\u16E8\u16E9\u16EA\u16EE\u16EF\u16F0",dots:"\u2800\u2801\u2802\u2803\u2804\u2805\u2806\u2807\u2808\u2809\u280A\u280B\u280C\u280D\u280E\u280F\u2810\u2811\u2812\u2813\u2814\u2815\u2816\u2817\u2818\u2819\u281A\u281B\u281C\u281D\u281E\u281F\u2820\u2821\u2822\u2823\u2824\u2825\u2826\u2827\u2828\u2829\u282A\u282B\u282C\u282D\u282E\u282F\u2830\u2831\u2832\u2833\u2834\u2835\u2836\u2837\u2838\u2839\u283A\u283B\u283C\u283D\u283E\u283F\u2840\u2841\u2842\u2843\u2844\u2845\u2846\u2847\u2848\u2849\u284A\u284B\u284C\u284D\u284E\u284F\u2850\u2851\u2852\u2853\u2854\u2855\u2856\u2857\u2858\u2859\u285A\u285B\u285C\u285D\u285E\u285F\u2860\u2861\u2862\u2863\u2864\u2865\u2866\u2867\u2868\u2869\u286A\u286B\u286C\u286D\u286E\u286F\u2870\u2871\u2872\u2873\u2874\u2875\u2876\u2877\u2878\u2879\u287A\u287B\u287C\u287D\u287E\u287F\u2880\u2881\u2882\u2883\u2884\u2885\u2886\u2887\u2888\u2889\u288A\u288B\u288C\u288D\u288E\u288F\u2890\u2891\u2892\u2893\u2894\u2895\u2896\u2897\u2898\u2899\u289A\u289B\u289C\u289D\u289E\u289F\u28A0\u28A1\u28A2\u28A3\u28A4\u28A5\u28A6\u28A7\u28A8\u28A9\u28AA\u28AB\u28AC\u28AD\u28AE\u28AF\u28B0\u28B1\u28B2\u28B3\u28B4\u28B5\u28B6\u28B7\u28B8\u28B9\u28BA\u28BB\u28BC\u28BD\u28BE\u28BF\u28C0\u28C1\u28C2\u28C3\u28C4\u28C5\u28C6\u28C7\u28C8\u28C9\u28CA\u28CB\u28CC\u28CD\u28CE\u28CF\u28D0\u28D1\u28D2\u28D3\u28D4\u28D5\u28D6\u28D7\u28D8\u28D9\u28DA\u28DB\u28DC\u28DD\u28DE\u28DF\u28E0\u28E1\u28E2\u28E3\u28E4\u28E5\u28E6\u28E7\u28E8\u28E9\u28EA\u28EB\u28EC\u28ED\u28EE\u28EF\u28F0\u28F1\u28F2\u28F3\u28F4\u28F5\u28F6\u28F7\u28F8\u28F9\u28FA\u28FB\u28FC\u28FD\u28FE\u28FF"},ze=l.define("String",String,{create:e=>e==null?"":String(e),rnd:(e,t,r)=>{let o=["bcdfghjklmnpqrstvwxz","aeiouy"],n=o[0].length/(o[0].length+o[1].length),s=Number.jet.rnd(Math.max(e,2),t,r),i=Boolean.jet.rnd(n),u="";for(;u.length<s;)u+=l.getRND(o[+(i=!i)]);return u},to:{Function:e=>t=>e,Boolean:e=>!["0","false","null","undefined","NaN"].includes(e.toLowerCase()),Array:(e,t)=>e.split(t),Object:e=>l.json.from(e),Promise:async e=>e,Number:(e,t)=>{if(e){if(t)return Number(e)}else return 0;let r=String(e).replace(/\u00A0/g," ").match(RegExp.jet.lib.number);return!r||!r[0]?0:Number(r[0].replaceAll(" ","").replace(",","."))||0}},extendPrototype:{isNumeric:e=>!isNaN(Number(e)),lower:e=>e.toLowerCase(),upper:e=>e.toUpperCase(),capitalize:e=>e.charAt(0).jet.upper()+e.slice(1),delone:e=>{let t="",r="aaccdeeillnooorstuuuyrzzAACCDEEILLNOOORSTUUUYRZZ",o="\xE1\xE4\u010D\u0107\u010F\xE9\u011B\xED\u013A\u013E\u0148\xF3\xF4\xF6\u0155\u0161\u0165\xFA\u016F\xFC\xFD\u0159\u017E\u017A\xC1\xC4\u010C\u0106\u010E\xC9\u011A\xCD\u0139\u013D\u0147\xD3\xD4\xD6\u0154\u0160\u0164\xDA\u016E\xDC\xDD\u0158\u017D\u0179";for(let n of e){let s=o.indexOf(n);t+=s>=0?r[s]:n}return t},efface:(e,t)=>e.replaceAll(t,"").replace(/[\s\n\r]+/g," ").trim(),simplify:(e,t)=>e.jet.efface(t).jet.delone().jet.lower(),sort:(...e)=>e.map(t=>{let r=String.jet.to(t),o=r.jet.delone();return{l:o.jet.lower(),d:o,s:r}}).sort((t,r)=>{for(let o=0;;o++)for(let n in t){let s=t[n].charCodeAt(o)||0,i=r[n].charCodeAt(o)||0;if(s!==i||!s)return s-i}}).map(t=>t.s),fight:(...e)=>String.jet.sort(...e)[0],carret:(e,t)=>Number.jet.tap(t,e.length).frame(0,e.length),splice:(e,t,r,...o)=>{let n=e.jet.carret(t),s=Number.jet.frame(r,0,e.length-n);return e.slice(0,n)+String.jet.to(o,"")+e.slice(n+s)},hide:(e,t,r)=>{if(!e)return e;for(var o="",n=e,s=De[t]||t||"\u2022",i=r===!1,u=0;u<e.length;u++)o+=i&&(n[u]===` | ||
`||n[u]===" ")?n[u]:s.length-1?l.getRND(s):s;return o},levenshtein:(e,t,r)=>{var o=r===!1?[e,t]:[e.jet.simplify(r),String.jet.simplify(t,r)];if(o[0]===o[1])return 1;if(!o[0]||!o[1])return 0;var n=[o[0].length,o[1].length],s=[];n[1]>n[0]&&(n.reverse(),o.reverse());for(var i=0;i<=n[0];i++){for(var u=i,f=0;f<=n[1];f++)if(i===0)s[f]=f;else if(f>0){var a=s[f-1];o[0].charAt(i-1)!==o[1].charAt(f-1)&&(a=Math.min(Math.min(a,u),s[f])+1),s[f-1]=u,u=a}i>0&&(s[n[1]]=u)}return(n[0]-s[n[1]])/parseFloat(n[0])},mutate:(e,t)=>{for(var r=[],o=e.length/2,n=e.length*2,s=Math.abs(1e3*(t||1));r.length<s;){var i=String.jet.rnd(o,n);r.push([i,i.jet.levenshtein(e)])}return r.sort((u,f)=>f[1]-u[1])[0][0]}}});var Ee=e=>String(e).slice(7,-1),Ie=l.define("Symbol",Symbol,{create:Symbol,copy:e=>Symbol(Ee(e)),rnd:(...e)=>Symbol(l.rnd.String(...e)),to:{Function:e=>t=>e}});var $e=l.define("Function",Function,{create:Function,copy:e=>Object.defineProperties({[e.name]:(...t)=>e(...t)}[e.name],Object.getOwnPropertyDescriptors(e)),to:{"*":(e,...t)=>e(...t),Promise:async(e,...t)=>await e(...t)}});var Ce=l.define("RegExp",RegExp,{create:RegExp,copy:e=>RegExp(e.source),extendPrototype:!1,extendConstructor:{lib:{line:/[^\n\r]+/g,number:/-?[0-9]+(\s+[0-9]+)*([,.][0-9]+)?/,word:/[^\s\n\r]+/g,num:/-?[0-9]*[.,]?[0-9]+/,email:/(?:[a-z0-9!#$%&'*+/=?^_{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_{|}~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])/i,ip:/((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?))/i,domain:/([a-z0-9]+\.)+(cz|de|sk|au|com|eu|info|org|[a-z]+)/i,hexadecimal:/[0-9a-fA-F]{6,6}/}},to:{Function:e=>t=>e,String:e=>e.source}});var Te=l.define("Date",Date,{create:e=>e?new Date(e):new Date,rnd:(e,t)=>new Date(Number.jet.rnd(new Date(e).getTime(),t?new Date(t).getTime():Date.now()*2)),to:{Function:e=>t=>e}});var Ue=l.define("NaN",Number,{create:e=>NaN,is:isNaN,primitives:["object"],extend:!1,to:e=>{}});var Le=l.define("Error",Error,{create:Error,rnd:(...e)=>new Error(l.rnd.String(...e)),to:{Function:e=>t=>e}});var qe=l.define("Promise",Promise,{create:e=>new Promise(l.only.Function(e,t=>t()))});var Je=l.define("Array",Array,{create:Array,copy:e=>Array.from(e),keys:e=>e.keys(),vals:e=>e.values(),entries:e=>e.entries(),to:{Function:e=>t=>e,Boolean:e=>e.jet.isFull(),Number:e=>e.length,String:(e,t)=>l.melt(e,t),Object:e=>Object.assign({},e),Promise:async e=>e,Error:(e,t)=>l.melt(e,t??" "),RegExp:(e,t)=>l.melt(e,t??"|")},plugins:{swap:(e,t,r)=>(e[t]=e.splice(r,1,e[t])[0],e),shuffle:e=>{for(var t=e.length-1;t>0;t--)e.jet.swap(Math.floor(Math.random()*(t+1)),t);return e},clean:(e,t,r)=>(r=Function.jet.tap(r,o=>o??void 0),t!==!1?e.filter(r):l.map(e,r))}});var We=l.define("Set",Set,{copy:e=>new Set(e),keys:e=>e.keys(),vals:e=>e.values(),entries:e=>e.entries(),get:(e,t)=>e.has(t)?t:void 0,set:(e,t,r)=>e.add(r)?r:void 0,rem:(e,t)=>e.delete(t),to:{"*":e=>Array.from(e),Function:e=>t=>e,Boolean:e=>e.jet.isFull(),Object:e=>l.merge(e),Promise:async e=>e}});var Ze=l.define("Map",Map,{copy:e=>new Map(e),keys:e=>e.keys(),vals:e=>e.values(),entries:e=>e.entries(),get:(e,t)=>e.get(t),set:(e,t,r)=>e.set(t,r),rem:(e,t)=>e.delete(t),to:{Function:e=>t=>e}});var P=class extends Array{static pass(t,r,o,n=1){if(!Array.isArray(t))throw"Pool.pass 'from' require array";if(!Array.isArray(r))throw"Pool.pass 'to' require array";return r.push(...t.splice(o,n))>=0}constructor(...t){super(...t);let r={};Object.defineProperties(this,{_autoFilter:{get:o=>r.autoFilter,set:o=>{l.isRunnable(o)?this.filter(r.autoFilter=o):delete r.autoFilter}},_autoSort:{get:o=>r.autoSort,set:o=>{l.isRunnable(o)?this.sort(r.autoSort=o):delete r.autoSort}}})}has(t){return this.includes(t)}add(...t){return this.splice(-1,0,...t),r=>this.remove(...t)}remove(...t){return this.filter(r=>!t.includes(r))}push(...t){return this.splice(-1,0,...t),this}unshift(...t){return this.splice(0,0,...t),this}put(t,...r){return this.splice(t,0,...r),this}splice(t,r=1,...o){let n;return r<0&&(r=0),t<0&&(t=Math.max(0,this.length+t+1-r)),o.length?(o=o.flat(),this._autoFilter&&(o=o.filter(this._autoFilter)),t===this.length?super.push(...o):t===0?super.unshift(...o):n=super.splice(t,r,...o),this._autoSort&&this.sort(this._autoSort)):r>0&&(n=super.splice(t,r)),n||new P}passTo(t,r,o=1){return P.pass(this,t,r,o)}passFrom(t,r,o=1){return P.pass(t,this,r,o)}flush(){return super.splice(0,this.length)}filter(t){let r=0;for(let o=0;o<this.length;o++)t(this[o],o,this)&&(this[r++]=this[o]);return this.length=r,this}map(t){let r=[];for(let o=this.length-1;o>=0;o--)r.push(t(this[o],o,this));return r}autoFilter(t){return this._autoFilter=t,this}autoSort(t){return this._autoSort=t,this}toString(t=" "){return l.melt(this,String.jet.to(t,this))}},Q=l.define("Pool",P,{copy:e=>new P(...e).autoFilter(e._autoFilter).autoSort(e._autoSort),keys:e=>e.keys(),vals:e=>e.values(),entries:e=>e.entries()});var X=class extends Q{constructor(...t){let r={with:[]};super(...t);this.autoFilter(l.isRunnable),Object.defineProperty(this,"_with",{get:o=>r.with,set:o=>r.with=Array.jet.to(o)})}with(...t){return this._with=t,this}run(...t){let r=!this._run,o=this._run=[];for(let n of this)if(o.push(n(...this._with,...t)),o!==this._run)break;return o=this._run,r&&delete this._run,o}fit(...t){if(this._fit)throw"RunPool.fit maximum call stack size exceeded";this._fit=!0;let r=this._with,o=l.reducer((n,s,...i)=>this[s]?this[s](n,...r,...i):i[0])(...r,...t);return delete this._fit,o}},He=l.define("RunPool",X,{copy:e=>new X(...e).autoFilter(e._autoFilter).autoSort(e._autoSort),keys:e=>e.keys(),vals:e=>e.values(),entries:e=>e.entries()});var rr=l,or=l.types.Plex;export{Je as Array,Re as Boolean,Te as Date,Le as Error,$e as Function,Ze as Map,Ue as NaN,ke as Number,Be as Object,or as Plex,Q as Pool,qe as Promise,Ce as RegExp,He as RunPool,We as Set,ze as String,Ie as Symbol,rr as default}; | ||
var __defProp = Object.defineProperty; | ||
var __export = (target, all) => { | ||
for (var name in all) | ||
__defProp(target, name, { get: all[name], enumerable: true }); | ||
}; | ||
// src/jet/Plex.js | ||
var Plex = class extends Function { | ||
static extend(self, props = {}) { | ||
for (let i in props) { | ||
Object.defineProperty(self, i, { value: props[i], enumerable: true }); | ||
} | ||
return self; | ||
} | ||
constructor(fce, props = {}) { | ||
super(); | ||
return Plex.extend(Object.setPrototypeOf(fce ? fce.bind() : this, new.target.prototype), props); | ||
} | ||
}; | ||
var Plex_default = Plex; | ||
// src/jet/defs.js | ||
var byName = {}; | ||
var byPrototype = /* @__PURE__ */ new Map(); | ||
var constructorByName = {}; | ||
var defaultThrow = (msg, name) => `jet${name ? ` type '${name}'` : ""} ${msg}`; | ||
var throwError = (msg, name) => { | ||
throw defaultThrow(msg, name); | ||
}; | ||
var throwWarn = (msg, name) => { | ||
console.warn(defaultThrow(msg, name)); | ||
}; | ||
var getDefByName = (name) => byName[name]; | ||
var getDefByProto = (prototype) => { | ||
const list = byPrototype.get(prototype); | ||
return list ? list[0] : void 0; | ||
}; | ||
var getByInst = (any, def, withDef = true) => { | ||
if (!def.is || def.is(any)) { | ||
return withDef ? def : def.name; | ||
} | ||
}; | ||
var findByProto = (any, proto, withDef = true) => { | ||
const list = byPrototype.get(proto); | ||
if (!list) { | ||
return; | ||
} | ||
if (list.length === 1) { | ||
return getByInst(any, list[0], withDef); | ||
} | ||
for (const def of list) { | ||
const r = getByInst(any, def, withDef); | ||
if (r) { | ||
return r; | ||
} | ||
} | ||
}; | ||
var findByInst = (any, strict, withDef = true) => { | ||
if (any == null) { | ||
return; | ||
} | ||
if (strict) { | ||
return findByProto(any, any.__proto__, withDef); | ||
} | ||
let r, p = any; | ||
do { | ||
r = findByProto(any, p = p.__proto__, withDef); | ||
} while (p && r === void 0); | ||
return r; | ||
}; | ||
var getDefByInst = (any, strict = true) => findByInst(any, strict, true); | ||
var getNameByInst = (any, strict = true) => findByInst(any, strict, false); | ||
var register = (def) => { | ||
byName[def.name] = def; | ||
Object.defineProperty(constructorByName, def.name, { enumerable: true, value: def.constructor }); | ||
const list = byPrototype.get(def.prototype); | ||
if (list) { | ||
list.unshift(def); | ||
} else { | ||
byPrototype.set(def.prototype, [def]); | ||
} | ||
}; | ||
var defs_default = new Plex_default(getNameByInst, { | ||
types: constructorByName | ||
}); | ||
// src/jet/methods.js | ||
var magic = ["only", "full", "tap", "pull", "is", "to", "copy", "rnd"]; | ||
var isInstance = (any) => { | ||
const t = typeof any; | ||
return any != null && (t === "function" || t === "object"); | ||
}; | ||
var isInstanceOf = (constructor, any) => any instanceof constructor; | ||
var is = (name, any, strict = true) => { | ||
if (!name) { | ||
return false; | ||
} | ||
const def = getDefByName(name); | ||
if (def) { | ||
if (any == null) { | ||
return false; | ||
} | ||
if (strict && any.__proto__ !== def.prototype) { | ||
return false; | ||
} | ||
if (!strict && !(any instanceof def.constructor)) { | ||
return false; | ||
} | ||
return !def.is || def.is(any); | ||
} | ||
const nt = typeof name; | ||
if (nt === "string") { | ||
return typeof any === name; | ||
} | ||
if (any == null || nt !== "function" && nt !== "object") { | ||
return false; | ||
} | ||
return strict ? any.constructor === name : any instanceof name; | ||
}; | ||
var isFull = (any, vals) => { | ||
if (!vals) { | ||
return any === false || any === 0 || !!any; | ||
} | ||
for (let v of vals(any)) { | ||
if (v != null) { | ||
return true; | ||
} | ||
} | ||
return false; | ||
}; | ||
var _touch = (def, op, err, ...args) => { | ||
if (def[op]) { | ||
return def[op](...args); | ||
} | ||
if (err) { | ||
throwError(`undefined operation '${op}' - unavailable for this type`, def.name); | ||
} | ||
}; | ||
var touch = (name, op, err, ...args) => { | ||
const def = getDefByName(name); | ||
if (def) { | ||
return _touch(def, op, err, ...args); | ||
} | ||
if (err) { | ||
throwError(`unable execute '${op}' - type unknown`, name); | ||
} | ||
}; | ||
var touchBy = (any, op, err, ...args) => { | ||
const def = getDefByInst(any, false); | ||
if (def) { | ||
return _touch(def, op, err, any, ...args); | ||
} | ||
if (err) { | ||
throwError(`unable execute '${op}' - missing type of '${any}'`); | ||
} | ||
}; | ||
var factory = (name, mm, ...args) => { | ||
const def = getDefByName(name); | ||
const n = isInstance(name); | ||
if (n && mm > 0) { | ||
throwError(`unable execute '${magic[mm]}' - unavailable for plain constructors`); | ||
} | ||
if (name && !n && !def) { | ||
throwError(`unable execute '${magic[mm]}' - type unknown`, name); | ||
} | ||
if (!name && mm !== 1) { | ||
throwError(`unable execute '${magic[mm]}' - type missing`); | ||
} | ||
for (const a of args) { | ||
if (!n) { | ||
const at = getDefByInst(a); | ||
if ((!name || at && at.name === name) && (mm !== 1 || (at && at.full(a) || !at && isFull(a)))) { | ||
return mm === 3 ? at.copy(a) : a; | ||
} | ||
} else if (isInstanceOf(name, a)) { | ||
return a; | ||
} | ||
} | ||
if (mm > 1) { | ||
return def.create(); | ||
} | ||
}; | ||
var to = (name, any, ...args) => { | ||
const def = getDefByName(name); | ||
if (!def) { | ||
throwError(`unable execute 'to' - type unknown`, name); | ||
} | ||
const at = getDefByInst(any, false); | ||
if (!at) { | ||
return def.create(); | ||
} | ||
if (def.name === at.name) { | ||
return any; | ||
} | ||
const exe = at.to[name] || at.to["*"]; | ||
return exe ? to(name, exe(any, ...args), ...args) : def.create(any); | ||
}; | ||
var toDefine = (from, to3, exe) => { | ||
const tt = typeof to3; | ||
const def = getDefByName(from); | ||
if (!def) { | ||
throwError(`unable define 'to' - type unknown`, from); | ||
} | ||
const conv = def.to; | ||
if (tt === "function") { | ||
conv["*"] = to3; | ||
} else if (tt === "object" && Array.isArray(to3)) { | ||
for (let i in to3) { | ||
conv[to3[i]] = exe; | ||
} | ||
} else if (tt === "object") { | ||
for (let i in to3) { | ||
conv[i] = to3[i]; | ||
} | ||
} else { | ||
conv[to3] = exe; | ||
} | ||
}; | ||
var getRND = (arr, min, max, sqr) => { | ||
if (!arr) { | ||
return; | ||
} | ||
arr = Array.from(arr); | ||
const l = arr.length; | ||
return arr[Math.floor(Number.jet.rnd(Number.jet.frame(min || 0, 0, l), Number.jet.frame(max || l, 0, l), sqr))]; | ||
}; | ||
// src/jet/define.js | ||
var enumerable = true; | ||
var define = (name, constructor, options = {}) => { | ||
let { create, is: is2, full, copy, rnd, keys, vals, entries, get, set, rem, to: to3, extend, extendPrototype, extendConstructor } = options; | ||
if (getDefByName(name)) { | ||
throwError("is allready defined", name); | ||
} | ||
if (!constructor) { | ||
throwError("constructor missing", name); | ||
} | ||
if ((keys || vals || entries) && !(keys && vals && entries)) { | ||
throwError("keys, vals or entries missing", name); | ||
} | ||
const prototype = constructor.prototype; | ||
create = create || ((...a) => new constructor(...a)); | ||
copy = copy || ((any) => any); | ||
const ec = extendConstructor === false ? null : typeof extendConstructor === "object" ? extendConstructor : {}; | ||
const ep = extendPrototype === false ? null : typeof extendPrototype === "object" ? extendPrototype : {}; | ||
let jc, jp; | ||
if (extend !== false) { | ||
const ancestor = getDefByProto(prototype); | ||
if (ancestor) { | ||
throwWarn(`constructor allready extended as '${ancestor}'. Use option 'extend=false'`, name); | ||
} else { | ||
if (ec) { | ||
Object.defineProperty(constructor, "jet", { value: jc = {} }); | ||
} | ||
if (ep) { | ||
jp = {}; | ||
Object.defineProperty(prototype, "jet", { get: function() { | ||
return { __: this, ...jp }; | ||
} }); | ||
} | ||
} | ||
} | ||
const ex = (pnw, key, fce) => { | ||
if (pnw && jp) { | ||
Object.defineProperty(jp, key, { enumerable, value: pnw < 2 ? fce : function(...a) { | ||
return fce(this.__, ...a); | ||
} }); | ||
} | ||
if (jc) { | ||
Object.defineProperty(jc, key, { enumerable, value: fce }); | ||
} | ||
if (defs_default[key]) { | ||
Object.defineProperty(defs_default[key], name, { enumerable, value: fce }); | ||
} | ||
}; | ||
ex(0, "create", create); | ||
ex(0, "is", (any, strict = true) => is(name, any, strict)); | ||
ex(0, "to", (any, ...a) => to(name, any, ...a)); | ||
ex(0, "only", (...a) => factory(name, 0, ...a)); | ||
ex(0, "full", (...a) => factory(name, 1, ...a)); | ||
ex(0, "tap", (...a) => factory(name, 2, ...a)); | ||
ex(0, "pull", (...a) => factory(name, 3, ...a)); | ||
ex(0, "rnd", rnd = rnd || create); | ||
ex(2, "isFull", full = full || ((any) => isFull(any, vals))); | ||
if (entries) { | ||
ex(2, "keys", keys); | ||
ex(2, "vals", vals); | ||
ex(2, "entries", entries); | ||
ex(2, "get", get = get || ((x, k) => x[k])); | ||
ex(2, "set", set = set || ((x, k, v) => x[k] = v)); | ||
ex(2, "rem", rem = rem || ((x, k) => delete x[k])); | ||
ex(2, "getRND", (any, min, max, sqr) => getRND(vals(any), min, max, sqr)); | ||
} | ||
register({ name, constructor, prototype, is: is2, create, full, copy, rnd, keys, vals, entries, get, set, rem, to: {} }); | ||
toDefine(name, to3); | ||
if (jc) { | ||
for (const k in ec) { | ||
ex(0, k, ec[k]); | ||
} | ||
} | ||
if (jp) { | ||
for (const k in ep) { | ||
ex(defs_default.isRunnable(ep[k]) ? 2 : 1, k, ep[k]); | ||
} | ||
} | ||
return constructor; | ||
}; | ||
var define_default = define; | ||
// src/jet/pile.js | ||
var pile_exports = {}; | ||
__export(pile_exports, { | ||
assign: () => assign, | ||
compare: () => compare, | ||
deflate: () => deflate, | ||
dig: () => dig, | ||
digIn: () => digIn, | ||
digOut: () => digOut, | ||
forEach: () => forEach, | ||
inflate: () => inflate, | ||
json: () => json, | ||
map: () => map, | ||
melt: () => melt, | ||
merge: () => merge, | ||
prop: () => prop, | ||
reducer: () => reducer | ||
}); | ||
var _each = ({ create, entries, set }, any, fce, deep, dprun, dir, flat, stop, isStop) => { | ||
const res = flat || create(); | ||
for (let [key, val] of entries(any)) { | ||
const path = (dir ? dir + "." : "") + key; | ||
const def = deep || !fce ? getDefByInst(val) : null; | ||
const dp = deep && def && def.entries; | ||
if (!dp) { | ||
val = fce ? fce(val, path, dir, key, stop) : def ? def.copy(val) : val; | ||
} else if (dprun) { | ||
val = deep(val, path, dir, key, stop); | ||
} else { | ||
val = _each(def, val, fce, deep, dprun, path, flat, stop, isStop); | ||
} | ||
if (val !== void 0) { | ||
if (!flat) { | ||
set(res, key, val); | ||
} else if (!dp) { | ||
flat.push(val); | ||
} | ||
} | ||
if (isStop()) { | ||
break; | ||
} | ||
} | ||
; | ||
return res; | ||
}; | ||
var _eachInit = (any, fce, deep, dir, flat) => { | ||
const df = getDefByInst(any); | ||
dir = String.jet.to(dir, "."); | ||
let _stop, stop = (_) => _stop = true; | ||
if (df && df.entries) { | ||
return _each( | ||
df, | ||
any, | ||
fce, | ||
deep, | ||
defs_default.isRunnable(deep), | ||
dir, | ||
flat, | ||
stop, | ||
(_) => _stop | ||
); | ||
} | ||
; | ||
const val = fce ? fce(any, dir, "", dir, stop) : df.copy ? df.copy(any) : any; | ||
if (flat && val !== void 0) { | ||
flat.push(val); | ||
} | ||
return flat || val; | ||
}; | ||
var forEach = (any, fce, deep = false, dir = "") => _eachInit(any, fce, deep, dir, []); | ||
var map = (any, fce, deep = false, dir = "") => _eachInit(any, fce, deep, dir); | ||
var reducer = (reductor) => { | ||
let i = 0, next; | ||
return next = (...input) => reductor(next, i++, ...input); | ||
}; | ||
var dig = (any, path, reductor) => { | ||
const pa = String.jet.to(path, ".").split("."); | ||
const end = pa.length - 1; | ||
return reducer((next, index, parent) => { | ||
const dir = pa.slice(0, index).join("."); | ||
return reductor(next, parent, (dir ? dir + "." : "") + pa[index], dir, pa[index], index === end); | ||
})(any); | ||
}; | ||
var digOut = (any, path, def) => { | ||
path = String.jet.to(path, "."); | ||
if (!path) { | ||
return any; | ||
} | ||
for (let p of path.split(".")) { | ||
if (null == (any = defs_default.get(any, p, false))) { | ||
return def; | ||
} | ||
} | ||
return any; | ||
}; | ||
var digIn = (any, path, val, force = true, reductor = void 0) => { | ||
const step = (next, parent, path2, dir, key, isEnd) => { | ||
let df = getDefByInst(parent); | ||
if (!df || !df.entries) { | ||
if (!force) { | ||
return parent; | ||
} | ||
parent = String.jet.isNumeric(key) ? [] : {}; | ||
df = getDefByInst(parent); | ||
} | ||
const v = isEnd ? val : next(df.get(parent, key, false)); | ||
if (v != null) { | ||
df.set(parent, key, v, false); | ||
return parent; | ||
} | ||
df.rem(parent, key); | ||
if (df.full(parent)) { | ||
return parent; | ||
} | ||
}; | ||
return dig( | ||
any, | ||
path, | ||
!defs_default.isRunnable(reductor) ? step : (next, parent, path2, dir, key, isEnd) => reductor( | ||
(parent2) => step(next, parent2, path2, dir, key, isEnd), | ||
parent, | ||
path2, | ||
dir, | ||
key, | ||
isEnd | ||
) | ||
); | ||
}; | ||
var deflate = (any, includeMapable = false) => { | ||
const flat = {}; | ||
const add = (v, p) => { | ||
flat[p] = v; | ||
}; | ||
const deep = (v, p) => { | ||
add(v, p); | ||
forEach(v, add, deep, p); | ||
}; | ||
forEach(any, add, includeMapable ? deep : true); | ||
if (includeMapable) { | ||
flat[""] = any; | ||
} | ||
return flat; | ||
}; | ||
var inflate = (flat, includeMapable = true) => { | ||
const r = {}; | ||
for (const e of defs_default.keys(flat).sort()) { | ||
if (!includeMapable && defs_default.isMapable(flat[e])) { | ||
continue; | ||
} | ||
digIn(r, "to." + e, flat[e], true); | ||
} | ||
return r.to; | ||
}; | ||
var _assign = (overwriteArray, to3, ...any) => { | ||
const r = { to: to3 }; | ||
const flat = deflate(r.to, true); | ||
const add = (v, p) => { | ||
r.to = digIn(r.to, p, v); | ||
}; | ||
const acumulate = (v, p) => { | ||
if (!flat[p]) { | ||
add(flat[p] = getDefByInst(v).create(), p); | ||
} | ||
if (Array.isArray(v) && Array.isArray(flat[p])) { | ||
flat[p].push(...v); | ||
} else { | ||
forEach(v, add, acumulate, p); | ||
} | ||
}; | ||
for (const a of any) { | ||
forEach(a, add, !!overwriteArray || acumulate); | ||
} | ||
return r.to; | ||
}; | ||
var assign = (to3, from, overwriteArray = true) => _assign(overwriteArray, to3, from); | ||
var merge = (...any) => _assign(false, {}, ...any); | ||
var compare = (a, b, changeList = false) => { | ||
const res = []; | ||
if (!changeList && a === b) { | ||
return true; | ||
} | ||
const flat = deflate(a); | ||
forEach(b, (v, p, d, k, stop) => { | ||
if (flat[p] !== v) { | ||
res.push(p); | ||
} | ||
delete flat[p]; | ||
if (res.length && !changeList) { | ||
stop(); | ||
} | ||
}, true); | ||
for (let p in flat) { | ||
if (res.length && !changeList) { | ||
break; | ||
} | ||
res.push(p); | ||
} | ||
return changeList ? res : !res.length; | ||
}; | ||
var melt = (any, comma) => { | ||
let j = "", c = String.jet.to(comma); | ||
if (!defs_default.isMapable(any)) { | ||
return String.jet.to(any, c); | ||
} | ||
forEach(any, (v) => { | ||
v = melt(v, c); | ||
j += v ? (j ? c : "") + v : ""; | ||
}); | ||
return j; | ||
}; | ||
var prop = { | ||
add: (obj, property, val, writable = false, enumerable2 = false, overwrite = true) => { | ||
if (defs_default.isMapable(property)) { | ||
forEach(property, (f, i) => { | ||
const n = String.jet.isNumeric(i); | ||
prop.add(obj, n ? f : i, n ? val : f, writable, enumerable2, overwrite); | ||
}); | ||
} else if (!obj[property] || overwrite) { | ||
Object.defineProperty(obj, property, { value: val, writable, configurable: writable, enumerable: enumerable2 }); | ||
} | ||
return obj; | ||
}, | ||
get: (obj, property) => { | ||
if (!property) { | ||
property = Array.from(Object.getOwnPropertyNames(obj)); | ||
} | ||
if (!defs_default.isMapable(property)) { | ||
return obj[property]; | ||
} | ||
const props = {}; | ||
forEach(property, (k) => props[k] = obj[k]); | ||
return props; | ||
} | ||
}; | ||
var json = { | ||
from: (json2, throwErr = false) => { | ||
if (defs_default.isMapable(json2)) { | ||
return json2; | ||
} | ||
try { | ||
return JSON.parse(String.jet.to(json2)); | ||
} catch (e) { | ||
if (throwErr === true) { | ||
throw e; | ||
} | ||
} | ||
}, | ||
to: (obj, prettyPrint = false) => { | ||
const spacing = Number.jet.only(prettyPrint === true ? 2 : prettyPrint); | ||
return JSON.stringify(defs_default.isMapable(obj) ? obj : {}, null, spacing); | ||
} | ||
}; | ||
// src/jet/index.js | ||
Plex_default.extend(defs_default, { | ||
is, | ||
to, | ||
isFull: (any) => { | ||
const def = getDefByInst(any, false); | ||
return def ? def.full(any) : isFull(any); | ||
}, | ||
isMapable: (any, strict = true) => { | ||
const def = getDefByInst(any, strict); | ||
return def ? !!def.entries : false; | ||
}, | ||
isRunnable: (any) => typeof any === "function", | ||
full: (...a) => factory(null, 1, ...a), | ||
only: (name, ...a) => factory(name, 0, ...a), | ||
tap: (name, ...a) => factory(name, 2, ...a), | ||
pull: (name, ...a) => factory(name, 3, ...a), | ||
create: (name, ...a) => touch(name, "create", true, ...a), | ||
rnd: (name, ...a) => touch(name, "rnd", true, ...a), | ||
copy: (any, deep = false, copyUnmapable = false) => deep ? defs_default.map(any, copyUnmapable ? void 0 : (_) => _, true) : touchBy(any, "copy"), | ||
keys: (any, throwError2 = false) => touchBy(any, "keys", throwError2) || [], | ||
vals: (any, throwError2 = false) => touchBy(any, "vals", throwError2) || [], | ||
entries: (any, throwError2 = false) => touchBy(any, "entries", throwError2) || [], | ||
get: (any, key, throwError2 = false) => touchBy(any, "get", throwError2, key), | ||
set: (any, key, val, throwError2 = false) => touchBy(any, "set", throwError2, key, val), | ||
rem: (any, key, throwError2 = true) => touchBy(any, "rem", throwError2, key), | ||
getRND: (any, min, max, sqr) => { | ||
const def = getDefByInst(any); | ||
if (def && def.vals) { | ||
any = def.vals(any); | ||
} else if (typeof any === "string") { | ||
return getRND(any, min, max, sqr); | ||
} | ||
}, | ||
run: (any, ...args) => { | ||
if (defs_default.isRunnable(any)) { | ||
return any(...args); | ||
} | ||
if (!defs_default.isMapable(any)) { | ||
return void 0; | ||
} | ||
return defs_default.forEach(any, (f) => defs_default.isRunnable(f) ? f(...args) : void 0, true); | ||
}, | ||
...pile_exports, | ||
define: new Plex_default(define_default, { to: toDefine }) | ||
}); | ||
defs_default.define("Plex", Plex_default, { | ||
copy: (x) => Object.defineProperties({}, Object.getOwnPropertyDescriptors(x)), | ||
keys: (x) => Object.keys(x), | ||
vals: (x) => Object.values(x), | ||
entries: (x) => Object.entries(x) | ||
}); | ||
var jet_default = defs_default; | ||
// src/native/Object.js | ||
var Object_default = jet_default.define("Object", Object, { | ||
create: Object, | ||
copy: (x) => Object.defineProperties({}, Object.getOwnPropertyDescriptors(x)), | ||
keys: (x) => Object.keys(x), | ||
vals: (x) => Object.values(x), | ||
entries: (x) => Object.entries(x), | ||
extendPrototype: false, | ||
to: { | ||
Function: (obj) => (_) => obj, | ||
Symbol: (obj) => Symbol(jet_default.json.to(obj)), | ||
Boolean: (obj) => jet_default.isFull.Object(obj), | ||
Number: (obj) => Object.values(obj), | ||
Array: (obj) => Object.values(obj), | ||
String: (obj) => obj.toString ? obj.toString() : jet_default.json.to(obj), | ||
Promise: async (obj) => obj, | ||
Error: (obj) => jet_default.json.to(obj), | ||
RegExp: (obj, comma) => jet_default.melt(obj, comma != null ? comma : "|") | ||
} | ||
}); | ||
// src/native/Boolean.js | ||
var Boolean_default = jet_default.define("Boolean", Boolean, { | ||
create: Boolean, | ||
rnd: (trueRatio) => Math.random() < (trueRatio || 0.5), | ||
to: { | ||
Function: (bol) => (_) => bol | ||
} | ||
}); | ||
// src/native/Number.js | ||
var Number_default = jet_default.define("Number", Number, { | ||
create: Number, | ||
rnd: (min, max, sqr) => { | ||
let r = Math.random(); | ||
if (sqr) { | ||
r = Math.pow(r, 2); | ||
} else if (sqr === false) { | ||
r = Math.sqrt(r); | ||
} | ||
return r.jet.fromRatio(min || 0, max || min * 2 || 1); | ||
}, | ||
to: { | ||
Function: (num) => (_) => num, | ||
Boolean: (num) => !!num, | ||
Array: (num, comma) => comma ? [num] : Array(num), | ||
Promise: async (num) => num, | ||
String: (num) => String(num) | ||
}, | ||
extendPrototype: { | ||
x: (num1, symbol, num2) => { | ||
const s = symbol, nums = Number.jet.zoomIn(num1, num2), [n, m] = nums; | ||
if (s === "/") { | ||
return n / m; | ||
} | ||
if (s === "*") { | ||
return n * m / Math.pow(nums.zoom, 2); | ||
} | ||
return (s === "+" ? n + m : s === "-" ? n - m : s === "%" ? n % m : NaN) / nums.zoom; | ||
}, | ||
frame: (num, min, max) => { | ||
num = max == null ? num : Math.min(num, max); | ||
return min == null ? num : Math.max(num, min); | ||
}, | ||
round: (num, dec, kind) => { | ||
const k = Math.pow(10, dec || 0); | ||
return Math[kind == null ? "round" : kind ? "ceil" : "floor"](num * k) / k; | ||
}, | ||
len: (num, bol) => { | ||
const b = bol, s = String.jet.to(num), l = s.length, i = s.indexOf("."), p = i >= 0; | ||
return b === false ? p ? l - i - 1 : 0 : !p || !b ? l : i; | ||
}, | ||
period: (val, min, max) => { | ||
const m = max - min; | ||
return (m + (val - min) % m) % m + min; | ||
}, | ||
toRatio: (num, min, max) => { | ||
const m = max - min; | ||
return m ? (num - min) / m : 0; | ||
}, | ||
fromRatio: (num, min, max) => { | ||
const m = max - min; | ||
return num * m + min; | ||
}, | ||
zoomIn: (...nums) => { | ||
const zoom = Math.pow(10, Math.max(...nums.map((num) => Number.jet.len(num, false)))); | ||
return jet_default.prop.add(nums.map((num) => Math.round(num * zoom)), "zoom", zoom); | ||
}, | ||
zoomOut: (...nums) => nums.map((num) => num / nums.zoom), | ||
diffusion: (num, min, max, diffusion) => { | ||
const d = num * diffusion; | ||
return Number.jet.rnd(Math.max(min, num - d), Math.min(max, num + d)); | ||
}, | ||
snap: (num, step, min, max, ceil, frame = true) => { | ||
var v = num, s = step, n = min, m = max, ni = n != null, mi = m != null, c = ceil; | ||
if (v == null || s == null || s <= 0 || !(ni || mi)) { | ||
return v; | ||
} else if (frame) { | ||
v = Number.jet.frame(v, n, m); | ||
} | ||
var r = ni ? v - n : m - v; | ||
v = r % s ? (ni ? n : m) + Number.jet.round(r / s, 0, c == null ? null : c === ni) * s * (ni * 2 - 1) : v; | ||
return frame ? Number.jet.frame(v, n, m) : v; | ||
}, | ||
whatpow: (num, base) => Math.log(num) / Math.log(Number.jet.to(base)), | ||
toHex: (num) => { | ||
var r = Math.round(num).toString(16); | ||
return r.length === 1 ? "0" + r : r; | ||
}, | ||
toLetter: (num, letters) => { | ||
letters = String.jet.to(letters) || "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; | ||
const len = letters.length; | ||
return (num >= len ? Number.jet.toLetter(Math.floor(num / len) - 1) : "") + letters[num % len]; | ||
} | ||
} | ||
}); | ||
// src/native/String.js | ||
var hidePats = { | ||
point: "\u2022", | ||
cross: "\xD7", | ||
flake: "\u2600", | ||
draft: "\u232D", | ||
power: "\u26A1", | ||
star: "\u2605", | ||
skull: "\u2620", | ||
card: "\u2660\u2665\u2666\u2663", | ||
notes: "\u2669\u266A\u266B\u266C\u266D\u266E\u266F", | ||
chess: "\u2654\u2655\u2656\u2657\u2658\u2659\u265A\u265B\u265C\u265D\u265E\u265F", | ||
block: "\u2596\u2597\u2598\u2599\u259A\u259B\u259C\u259D\u259E\u259F", | ||
bar: "\u2502\u2551 \u258C\u2590\u2588", | ||
iting: "\u2630\u2631\u2632\u2633\u2634\u2635\u2636\u2637", | ||
astro: "\u2648\u2649\u264A\u264B\u264C\u264D\u264E\u264F\u2650\u2651\u2652\u2653", | ||
die: "\u2680\u2681\u2682\u2683\u2684\u2685", | ||
runic: "\u16A0\u16A1\u16A2\u16A3\u16A4\u16A5\u16A6\u16A7\u16A8\u16A9\u16AA\u16AB\u16AC\u16AD\u16AE\u16AF\u16B0\u16B1\u16B3\u16B4\u16B5\u16B6\u16B7\u16B8\u16B9\u16BA\u16BB\u16BC\u16BD\u16BE\u16BF\u16C0\u16C1\u16C2\u16C3\u16C4\u16C5\u16C6\u16C7\u16C8\u16C9\u16CA\u16CB\u16CF\u16D0\u16D1\u16D2\u16D3\u16D4\u16D5\u16D6\u16D7\u16D8\u16D9\u16DA\u16DB\u16DC\u16DD\u16DE\u16DF\u16E0\u16E1\u16E2\u16E3\u16E4\u16E5\u16E6\u16E8\u16E9\u16EA\u16EE\u16EF\u16F0", | ||
dots: "\u2800\u2801\u2802\u2803\u2804\u2805\u2806\u2807\u2808\u2809\u280A\u280B\u280C\u280D\u280E\u280F\u2810\u2811\u2812\u2813\u2814\u2815\u2816\u2817\u2818\u2819\u281A\u281B\u281C\u281D\u281E\u281F\u2820\u2821\u2822\u2823\u2824\u2825\u2826\u2827\u2828\u2829\u282A\u282B\u282C\u282D\u282E\u282F\u2830\u2831\u2832\u2833\u2834\u2835\u2836\u2837\u2838\u2839\u283A\u283B\u283C\u283D\u283E\u283F\u2840\u2841\u2842\u2843\u2844\u2845\u2846\u2847\u2848\u2849\u284A\u284B\u284C\u284D\u284E\u284F\u2850\u2851\u2852\u2853\u2854\u2855\u2856\u2857\u2858\u2859\u285A\u285B\u285C\u285D\u285E\u285F\u2860\u2861\u2862\u2863\u2864\u2865\u2866\u2867\u2868\u2869\u286A\u286B\u286C\u286D\u286E\u286F\u2870\u2871\u2872\u2873\u2874\u2875\u2876\u2877\u2878\u2879\u287A\u287B\u287C\u287D\u287E\u287F\u2880\u2881\u2882\u2883\u2884\u2885\u2886\u2887\u2888\u2889\u288A\u288B\u288C\u288D\u288E\u288F\u2890\u2891\u2892\u2893\u2894\u2895\u2896\u2897\u2898\u2899\u289A\u289B\u289C\u289D\u289E\u289F\u28A0\u28A1\u28A2\u28A3\u28A4\u28A5\u28A6\u28A7\u28A8\u28A9\u28AA\u28AB\u28AC\u28AD\u28AE\u28AF\u28B0\u28B1\u28B2\u28B3\u28B4\u28B5\u28B6\u28B7\u28B8\u28B9\u28BA\u28BB\u28BC\u28BD\u28BE\u28BF\u28C0\u28C1\u28C2\u28C3\u28C4\u28C5\u28C6\u28C7\u28C8\u28C9\u28CA\u28CB\u28CC\u28CD\u28CE\u28CF\u28D0\u28D1\u28D2\u28D3\u28D4\u28D5\u28D6\u28D7\u28D8\u28D9\u28DA\u28DB\u28DC\u28DD\u28DE\u28DF\u28E0\u28E1\u28E2\u28E3\u28E4\u28E5\u28E6\u28E7\u28E8\u28E9\u28EA\u28EB\u28EC\u28ED\u28EE\u28EF\u28F0\u28F1\u28F2\u28F3\u28F4\u28F5\u28F6\u28F7\u28F8\u28F9\u28FA\u28FB\u28FC\u28FD\u28FE\u28FF" | ||
}; | ||
var String_default = jet_default.define("String", String, { | ||
create: (any) => any == null ? "" : String(any), | ||
rnd: (min, max, sqr) => { | ||
const c = ["bcdfghjklmnpqrstvwxz", "aeiouy"], p = c[0].length / (c[0].length + c[1].length); | ||
const l = Number.jet.rnd(Math.max(min, 2), max, sqr); | ||
let s = Boolean.jet.rnd(p), r = ""; | ||
while (r.length < l) { | ||
r += jet_default.getRND(c[+(s = !s)]); | ||
} | ||
return r; | ||
}, | ||
to: { | ||
Function: (str) => (_) => str, | ||
Boolean: (str) => !["0", "false", "null", "undefined", "NaN"].includes(str.toLowerCase()), | ||
Array: (str, comma) => str.split(comma), | ||
Object: (str) => jet_default.json.from(str), | ||
Promise: async (str) => str, | ||
Number: (str, strict) => { | ||
if (!str) { | ||
return 0; | ||
} else if (strict) { | ||
return Number(str); | ||
} | ||
const match = String(str).replace(/\u00A0/g, " ").match(RegExp.jet.lib.number); | ||
if (!match || !match[0]) { | ||
return 0; | ||
} | ||
return Number(match[0].replaceAll(" ", "").replace(",", ".")) || 0; | ||
} | ||
}, | ||
extendPrototype: { | ||
isNumeric: (str) => !isNaN(Number(str)), | ||
lower: (str) => str.toLowerCase(), | ||
upper: (str) => str.toUpperCase(), | ||
capitalize: (str) => str.charAt(0).jet.upper() + str.slice(1), | ||
delone: (str) => { | ||
let r = "", to3 = "aaccdeeillnooorstuuuyrzzAACCDEEILLNOOORSTUUUYRZZ", from = "\xE1\xE4\u010D\u0107\u010F\xE9\u011B\xED\u013A\u013E\u0148\xF3\xF4\xF6\u0155\u0161\u0165\xFA\u016F\xFC\xFD\u0159\u017E\u017A\xC1\xC4\u010C\u0106\u010E\xC9\u011A\xCD\u0139\u013D\u0147\xD3\xD4\xD6\u0154\u0160\u0164\xDA\u016E\xDC\xDD\u0158\u017D\u0179"; | ||
for (let v of str) { | ||
let x = from.indexOf(v); | ||
r += x >= 0 ? to3[x] : v; | ||
} | ||
return r; | ||
}, | ||
efface: (str, remove) => str.replaceAll(remove, "").replace(/[\s\n\r]+/g, " ").trim(), | ||
simplify: (str, remove) => str.jet.efface(remove).jet.delone().jet.lower(), | ||
sort: (...strs) => strs.map((v) => { | ||
const s = String.jet.to(v), d = s.jet.delone(), l = d.jet.lower(); | ||
return { l, d, s }; | ||
}).sort((m1, m2) => { | ||
for (let i = 0; true; i++) { | ||
for (let k in m1) { | ||
let c1 = m1[k].charCodeAt(i) || 0, c2 = m2[k].charCodeAt(i) || 0; | ||
if (c1 !== c2 || !c1) { | ||
return c1 - c2; | ||
} | ||
} | ||
} | ||
}).map((m) => m.s), | ||
fight: (...strs) => String.jet.sort(...strs)[0], | ||
carret: (str, pos) => Number.jet.tap(pos, str.length).frame(0, str.length), | ||
splice: (str, index, howmany, ...strs) => { | ||
const s = str.jet.carret(index), m = Number.jet.frame(howmany, 0, str.length - s); | ||
return str.slice(0, s) + String.jet.to(strs, "") + str.slice(s + m); | ||
}, | ||
hide: (str, pat, whitespace) => { | ||
if (!str) { | ||
return str; | ||
} | ||
var r = "", s = str, p = hidePats[pat] || pat || "\u2022", w = whitespace === false; | ||
for (var i = 0; i < str.length; i++) { | ||
r += w && (s[i] === "\n" || s[i] === " ") ? s[i] : p.length - 1 ? jet_default.getRND(p) : p; | ||
} | ||
return r; | ||
}, | ||
levenshtein: (s0, s1, blend) => { | ||
var s = blend === false ? [s0, s1] : [s0.jet.simplify(blend), String.jet.simplify(s1, blend)]; | ||
if (s[0] === s[1]) { | ||
return 1; | ||
} else if (!s[0] || !s[1]) { | ||
return 0; | ||
} | ||
var l = [s[0].length, s[1].length], c = []; | ||
if (l[1] > l[0]) { | ||
l.reverse(); | ||
s.reverse(); | ||
} | ||
for (var i = 0; i <= l[0]; i++) { | ||
var oV = i; | ||
for (var j = 0; j <= l[1]; j++) { | ||
if (i === 0) { | ||
c[j] = j; | ||
} else if (j > 0) { | ||
var nV = c[j - 1]; | ||
if (s[0].charAt(i - 1) !== s[1].charAt(j - 1)) { | ||
nV = Math.min(Math.min(nV, oV), c[j]) + 1; | ||
} | ||
c[j - 1] = oV; | ||
oV = nV; | ||
} | ||
} | ||
if (i > 0) { | ||
c[l[1]] = oV; | ||
} | ||
} | ||
return (l[0] - c[l[1]]) / parseFloat(l[0]); | ||
}, | ||
mutate: (str, factor) => { | ||
var r = [], n = str.length / 2, m = str.length * 2, f = Math.abs(1e3 * (factor || 1)); | ||
while (r.length < f) { | ||
var s = String.jet.rnd(n, m); | ||
r.push([s, s.jet.levenshtein(str)]); | ||
} | ||
return r.sort((a, b) => b[1] - a[1])[0][0]; | ||
} | ||
} | ||
}); | ||
// src/native/Symbol.js | ||
var to2 = (sym) => String(sym).slice(7, -1); | ||
var Symbol_default = jet_default.define("Symbol", Symbol, { | ||
create: Symbol, | ||
copy: (x) => Symbol(to2(x)), | ||
rnd: (...a) => Symbol(jet_default.rnd.String(...a)), | ||
to: { | ||
Function: (sym) => (_) => sym | ||
} | ||
}); | ||
// src/native/Function.js | ||
var Function_default = jet_default.define("Function", Function, { | ||
create: Function, | ||
copy: (x) => Object.defineProperties({ [x.name]: (...a) => x(...a) }[x.name], Object.getOwnPropertyDescriptors(x)), | ||
to: { | ||
"*": (fce, ...args) => fce(...args), | ||
Promise: async (fce, ...args) => await fce(...args) | ||
} | ||
}); | ||
// src/native/RegExp.js | ||
var RegExp_default = jet_default.define("RegExp", RegExp, { | ||
create: RegExp, | ||
copy: (x) => RegExp(x.source), | ||
extendPrototype: false, | ||
extendConstructor: { | ||
lib: { | ||
line: /[^\n\r]+/g, | ||
number: /-?[0-9]+(\s+[0-9]+)*([,.][0-9]+)?/, | ||
word: /[^\s\n\r]+/g, | ||
num: /-?[0-9]*[.,]?[0-9]+/, | ||
email: /(?:[a-z0-9!#$%&'*+/=?^_{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_{|}~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])/i, | ||
ip: /((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?))/i, | ||
domain: /([a-z0-9]+\.)+(cz|de|sk|au|com|eu|info|org|[a-z]+)/i, | ||
hexadecimal: /[0-9a-fA-F]{6,6}/ | ||
} | ||
}, | ||
to: { | ||
Function: (regex) => (_) => regex, | ||
String: (regex) => regex.source | ||
} | ||
}); | ||
// src/native/Date.js | ||
var Date_default = jet_default.define("Date", Date, { | ||
create: (x) => !x ? new Date() : new Date(x), | ||
rnd: (from, to3) => new Date(Number.jet.rnd(new Date(from).getTime(), to3 ? new Date(to3).getTime() : Date.now() * 2)), | ||
to: { | ||
Function: (date) => (_) => date | ||
} | ||
}); | ||
// src/native/NaN.js | ||
var NaN_default = jet_default.define("NaN", Number, { | ||
create: (_) => NaN, | ||
is: isNaN, | ||
primitives: ["object"], | ||
extend: false, | ||
to: (_) => void 0 | ||
}); | ||
// src/native/Error.js | ||
var Error_default = jet_default.define("Error", Error, { | ||
create: Error, | ||
rnd: (...a) => new Error(jet_default.rnd.String(...a)), | ||
to: { | ||
Function: (err) => (_) => err | ||
} | ||
}); | ||
// src/native/Promise.js | ||
var Promise_default = jet_default.define("Promise", Promise, { | ||
create: (x) => new Promise(jet_default.only.Function(x, (e) => e())) | ||
}); | ||
// src/native/Array.js | ||
var Array_default = jet_default.define("Array", Array, { | ||
create: Array, | ||
copy: (x) => Array.from(x), | ||
keys: (x) => x.keys(), | ||
vals: (x) => x.values(), | ||
entries: (x) => x.entries(), | ||
to: { | ||
Function: (arr) => (_) => arr, | ||
Boolean: (arr) => arr.jet.isFull(), | ||
Number: (arr) => arr.length, | ||
String: (arr, comma) => jet_default.melt(arr, comma), | ||
Object: (arr) => Object.assign({}, arr), | ||
Promise: async (arr) => arr, | ||
Error: (arr, comma) => jet_default.melt(arr, comma != null ? comma : " "), | ||
RegExp: (arr, comma) => jet_default.melt(arr, comma != null ? comma : "|") | ||
}, | ||
plugins: { | ||
swap: (arr, to3, from) => { | ||
arr[to3] = arr.splice(from, 1, arr[to3])[0]; | ||
return arr; | ||
}, | ||
shuffle: (arr) => { | ||
for (var i = arr.length - 1; i > 0; i--) { | ||
arr.jet.swap(Math.floor(Math.random() * (i + 1)), i); | ||
} | ||
return arr; | ||
}, | ||
clean: (arr, rekey, handler) => { | ||
handler = Function.jet.tap(handler, (v) => v != null ? v : void 0); | ||
return rekey !== false ? arr.filter(handler) : jet_default.map(arr, handler); | ||
} | ||
} | ||
}); | ||
// src/native/Set.js | ||
var Set_default = jet_default.define("Set", Set, { | ||
copy: (x) => new Set(x), | ||
keys: (x) => x.keys(), | ||
vals: (x) => x.values(), | ||
entries: (x) => x.entries(), | ||
get: (x, k) => x.has(k) ? k : void 0, | ||
set: (x, k, v) => x.add(v) ? v : void 0, | ||
rem: (x, k) => x.delete(k), | ||
to: { | ||
"*": (set) => Array.from(set), | ||
Function: (set) => (_) => set, | ||
Boolean: (set) => set.jet.isFull(), | ||
Object: (set) => jet_default.merge(set), | ||
Promise: async (set) => set | ||
} | ||
}); | ||
// src/native/Map.js | ||
var Map_default = jet_default.define("Map", Map, { | ||
copy: (x) => new Map(x), | ||
keys: (x) => x.keys(), | ||
vals: (x) => x.values(), | ||
entries: (x) => x.entries(), | ||
get: (x, k) => x.get(k), | ||
set: (x, k, v) => x.set(k, v), | ||
rem: (x, k) => x.delete(k), | ||
to: { | ||
Function: (map2) => (_) => map2 | ||
} | ||
}); | ||
// src/custom/Pool.js | ||
var Pool = class extends Array { | ||
static pass(from, to3, start, length = 1) { | ||
if (!Array.isArray(from)) { | ||
throw "Pool.pass 'from' require array"; | ||
} | ||
if (!Array.isArray(to3)) { | ||
throw "Pool.pass 'to' require array"; | ||
} | ||
return to3.push(...from.splice(start, length)) >= 0; | ||
} | ||
constructor(...items) { | ||
super(...items); | ||
const _p = {}; | ||
Object.defineProperties(this, { | ||
_autoFilter: { get: (_) => _p.autoFilter, set: (fce) => { | ||
if (!jet_default.isRunnable(fce)) { | ||
delete _p.autoFilter; | ||
} else { | ||
this.filter(_p.autoFilter = fce); | ||
} | ||
} }, | ||
_autoSort: { get: (_) => _p.autoSort, set: (fce) => { | ||
if (!jet_default.isRunnable(fce)) { | ||
delete _p.autoSort; | ||
} else { | ||
this.sort(_p.autoSort = fce); | ||
} | ||
} } | ||
}); | ||
} | ||
has(item) { | ||
return this.includes(item); | ||
} | ||
add(...items) { | ||
this.splice(-1, 0, ...items); | ||
return (_) => this.remove(...items); | ||
} | ||
remove(...items) { | ||
return this.filter((v) => !items.includes(v)); | ||
} | ||
push(...items) { | ||
this.splice(-1, 0, ...items); | ||
return this; | ||
} | ||
unshift(...items) { | ||
this.splice(0, 0, ...items); | ||
return this; | ||
} | ||
put(start, ...items) { | ||
this.splice(start, 0, ...items); | ||
return this; | ||
} | ||
splice(start, length = 1, ...items) { | ||
let result; | ||
if (length < 0) { | ||
length = 0; | ||
} | ||
if (start < 0) { | ||
start = Math.max(0, this.length + start + 1 - length); | ||
} | ||
if (items.length) { | ||
items = items.flat(); | ||
if (this._autoFilter) { | ||
items = items.filter(this._autoFilter); | ||
} | ||
if (start === this.length) { | ||
super.push(...items); | ||
} else if (start === 0) { | ||
super.unshift(...items); | ||
} else { | ||
result = super.splice(start, length, ...items); | ||
} | ||
if (this._autoSort) { | ||
this.sort(this._autoSort); | ||
} | ||
} else if (length > 0) { | ||
result = super.splice(start, length); | ||
} | ||
return result || new Pool(); | ||
} | ||
passTo(to3, start, length = 1) { | ||
return Pool.pass(this, to3, start, length); | ||
} | ||
passFrom(from, start, length = 1) { | ||
return Pool.pass(from, this, start, length); | ||
} | ||
flush() { | ||
return super.splice(0, this.length); | ||
} | ||
filter(fce) { | ||
let k = 0; | ||
for (let i = 0; i < this.length; i++) { | ||
if (fce(this[i], i, this)) { | ||
this[k++] = this[i]; | ||
} | ||
} | ||
this.length = k; | ||
return this; | ||
} | ||
map(fce) { | ||
const r = []; | ||
for (let i = this.length - 1; i >= 0; i--) { | ||
r.push(fce(this[i], i, this)); | ||
} | ||
return r; | ||
} | ||
autoFilter(fce) { | ||
this._autoFilter = fce; | ||
return this; | ||
} | ||
autoSort(fce) { | ||
this._autoSort = fce; | ||
return this; | ||
} | ||
toString(separator = " ") { | ||
return jet_default.melt(this, String.jet.to(separator, this)); | ||
} | ||
}; | ||
var Pool_default = jet_default.define("Pool", Pool, { | ||
copy: (x) => new Pool(...x).autoFilter(x._autoFilter).autoSort(x._autoSort), | ||
keys: (x) => x.keys(), | ||
vals: (x) => x.values(), | ||
entries: (x) => x.entries() | ||
}); | ||
// src/custom/RunPool.js | ||
var RunPool = class extends Pool_default { | ||
constructor(...items) { | ||
const _p = { with: [] }; | ||
super(...items); | ||
this.autoFilter(jet_default.isRunnable); | ||
Object.defineProperty(this, "_with", { get: (_) => _p.with, set: (v) => _p.with = Array.jet.to(v) }); | ||
} | ||
with(...args) { | ||
this._with = args; | ||
return this; | ||
} | ||
run(...args) { | ||
const first = !this._run; | ||
let r = this._run = []; | ||
for (const fce of this) { | ||
r.push(fce(...this._with, ...args)); | ||
if (r !== this._run) { | ||
break; | ||
} | ||
} | ||
r = this._run; | ||
if (first) { | ||
delete this._run; | ||
} | ||
return r; | ||
} | ||
fit(...args) { | ||
if (this._fit) { | ||
throw "RunPool.fit maximum call stack size exceeded"; | ||
} | ||
this._fit = true; | ||
const w = this._with; | ||
const result = jet_default.reducer( | ||
(next, i, ...a) => this[i] ? this[i](next, ...w, ...a) : a[0] | ||
)(...w, ...args); | ||
delete this._fit; | ||
return result; | ||
} | ||
}; | ||
var RunPool_default = jet_default.define("RunPool", RunPool, { | ||
copy: (x) => new RunPool(...x).autoFilter(x._autoFilter).autoSort(x._autoSort), | ||
keys: (x) => x.keys(), | ||
vals: (x) => x.values(), | ||
entries: (x) => x.entries() | ||
}); | ||
// src/index.js | ||
var src_default = jet_default; | ||
var Plex2 = jet_default.types.Plex; | ||
export { | ||
Array_default as Array, | ||
Boolean_default as Boolean, | ||
Date_default as Date, | ||
Error_default as Error, | ||
Function_default as Function, | ||
Map_default as Map, | ||
NaN_default as NaN, | ||
Number_default as Number, | ||
Object_default as Object, | ||
Plex2 as Plex, | ||
Pool_default as Pool, | ||
Promise_default as Promise, | ||
RegExp_default as RegExp, | ||
RunPool_default as RunPool, | ||
Set_default as Set, | ||
String_default as String, | ||
Symbol_default as Symbol, | ||
src_default as default | ||
}; | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@randajan/jet-core", | ||
"version": "3.0.10", | ||
"version": "3.0.11", | ||
"description": "Ecosystem of types and related usefull tools.", | ||
@@ -19,3 +19,3 @@ "repository": "randajan/jet-core", | ||
"devDependencies": { | ||
"@randajan/simple-lib": "^1.2.0", | ||
"@randajan/simple-lib": "^2.0.0", | ||
"chokidar": "^3.5.3", | ||
@@ -22,0 +22,0 @@ "esbuild": "^0.14.27", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
122320
1196
1