pepka 1.0.0-beta.1 → 1.0.0-beta.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/bundle.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";const e=Symbol("Placeholder"),r=r=>{let t=0;for(const s of r)s!==e&&t++;return t},t=(r,t)=>{const s=r.length,o=r.slice(),p=t.length;let n=p,x=0;for(;n&&x<s;x++)o[x]===e&&(o[x]=t[p-n],n--);for(x=s;n;x++,n--)o[x]=t[p-n];return o},s=(e,o,p)=>{const n=e.length-o.length-r(p);if(n<1)return e(...t(o,p));{const r=(...r)=>s(e,t(o,p),r);return r.$args_left=n,r}},o=e=>(...t)=>e.length>r(t)?s(e,[],t):e(...t),p=r=>function(t){return t===e?r:r(t)};function n(r){return function(t,s){const o=t===e,n=arguments.length;if(1===n&&o)throw new Error("Senseless placeholder usage.");return arguments.length>1?o?p((e=>r(e,s))):r(t,s):e=>r(t,e)}}function x(e){return o(e)}const c=void 0,a=1/0,i=e=>typeof e,l=e=>null===e,u=e=>"number"==i(e),f=e=>Array.isArray(e),h=e=>"function"===i(e),d={u:"U",b:"B",n:"N",s:"S",f:"F"},m=e=>{const r=i(e);return"object"===r?l(e)?"Null":e.constructor.name:d[r[0]]+r.slice(1)},y=n(((e,r)=>m(r)===e)),g=n(((e,r)=>(r.push(e),r))),b=x(((e,r,t)=>(t[e]=r,t))),w=x(((e,r,t)=>t.reduce(e,r))),j=x(((e,r,t)=>{for(let s in t)switch(m(t[s])){case"Array":if(e>1&&"Array"===m(r[s]))switch(e){case 2:const o=r[s],p=t[s];for(const r in p)o[r]?j(e,o[r],p[r]):o[r]=p[r];break;case 3:r[s].push(...t[s])}else r[s]=t[s];break;case"Object":if("Object"===m(r[s])){j(e,r[s],t[s]);break}default:r[s]=t[s]}return r})),O=j(1),q=j(2),A=j(3),E=n(((e,r)=>{let t,s,o,p;for(t in e)s=e[t],[o,p]=h(s)?s(r):[s,r[t]],r[o]=p,t!==o&&delete r[t];return r})),k=n(((e,r)=>{for(let t in r)r[t]=e(r[t],+t,r);return r})),S=n(((e,r)=>{const t=f(r);for(let s in r)e(r[s],s)||(t?r.splice(s,1):delete r[s]);return r})),v=n(((e,r)=>r.indexOf(e))),P=e=>(...r)=>r[e],D=n(((e,r)=>{const t=m(e);if(t===m(r)&&("Object"===t||"Array"==t)){if(l(e)||l(r))return e===r;if(e===r)return!0;for(const t of[e,r])for(const s in t)if(!(t===r&&s in e||t===e&&s in r&&D(e[s],r[s])))return!1;return!0}return e===r})),z=o(((e,r,t,s)=>e(s)?r(s):t(s))),N=x(((e,r,t)=>z(e,r,M,t))),B=(...r)=>(...t)=>{let s,o=!0;for(let p=H(r)-1;p>-1;p--)o?(o=!1,s=r[p](...t)):s=s===e?r[p]():r[p](s);return s},_=n(((e,r)=>e.bind(r))),C=n(((e,r)=>r[e])),I=n(((e,r)=>{if((e=>"string"===i(e))(r))return r.includes(e);for(const t of r)if(D(t,e))return!0;return!1})),T=x(((e,r,t)=>t.slice(e,u(r)?r:a))),U=e=>n(((r,t)=>e(t,r))),$=C(0),F=T(1,a),K=n(((e,r)=>e+r)),L=n(((e,r)=>r-e)),W=n(((e,r)=>e*r)),X=n(((e,r)=>e/r)),G=e=>l(e)||(e=>e===c)(e),H=e=>e.length,J=e=>()=>e,M=e=>e,Q=e=>!e,R=e=>(...r)=>{const t=e(...r),s=h(t);return!s||s&&t.$args_left<=0?Q(t):R(t)},V=e=>Object.entries(e),Y=n(((e,r)=>e.test(r))),Z=n(((e,r)=>(e(r),r))),ee=n(((e,r)=>[...r,e])),re=n(((e,r)=>r.split(e))),te=J(!0),se=J(!1),oe=n(((e,r)=>r(...e))),pe=n(((e,r)=>xe(K(e),r-e))),ne=n(((e,r)=>e.filter(U(I)(r)))),xe=n(((e,r)=>[...Array(r)].map(((r,t)=>e(t))))),ce=n(((e,r)=>e>r)),ae=n(((e,r)=>e<r)),ie=n(((e,r)=>r>=e)),le=n(((e,r)=>r<=e)),ue=n(((e,r)=>r.sort(e))),fe=n(((e,r)=>r.find(e))),he=n(((e,r)=>r.findIndex(e))),de=n(((e,r)=>he(D(e),r))),me=n(((e,r)=>{for(const[t,s]of e)if(t(r))return s(r)})),ye=x(((e,r,t)=>({...t,[e]:r}))),ge=x(((e,r,t)=>B((s=>{return ye(s,H(e)<2?r:ge(T(1,a,e),r,(o=t[s],l(o)||"object"!==i(o)?{}:t[s])),t);var o}),$)(e))),be=n(((e,r)=>r.every(e))),we=n(((e,r)=>r.some(e))),je=n(((e,r)=>e.every((e=>e(r))))),Oe=n(((e,r)=>e.some((e=>e(r))))),qe=n(((e,r)=>r[e])),Ae=x(((e,r,t)=>D(t[e],r))),Ee=x(((e,r,t)=>D(r[e],t[e]))),ke=x(((e,r,t)=>z(H,(()=>G(t)?e:B(z(G,J(e),(t=>ke(e,T(1,a,r),t))),U(qe)(t),$)(r)),J(t),r))),Se=ke(c),ve=x(((e,r,t)=>D(Se(e,t),r))),Pe=x(((e,r,t)=>D(Se(e,r),Se(e,t)))),De=/^(.*?)(8|16|32|64)(Clamped)?Array$/,ze=(e,r=!1)=>{const t=m(e);switch(t){case"Null":case"String":case"Number":case"Boolean":case"Symbol":return e;case"Array":return r?[...e]:$e(B(ze,P(0)),e);case"Object":if(r)return{...e};const s={};for(let r in e)s[r]=ze(e[r]);return s;default:return De.test(t)?e.constructor.from(e):e}},Ne=x(((e,r,t)=>w(e,ze(r),t))),Be=n(((e,r)=>We(e,r))),_e=n(((e,r)=>{const t={};for(const s of e)s in r&&(t[s]=r[s]);return t})),Ce=n(((e,r)=>We(((r,t)=>!I(t,e)),r))),Ie=e=>Ne(((e,r)=>ye(...r,e)),{},e),Te=n(((e,r)=>r.concat(e))),Ue=n(((e,r)=>r.join(e))),$e=n(((e,r)=>r.map(e))),Fe=n(((e,r)=>r.forEach(e))),Ke=x(((e,r,t)=>r(t)&&e(t))),Le=x(((e,r,t)=>t.replace(e,r))),We=n(((e,r)=>f(r)?r.filter(e):B(Ie,We((([r,t])=>e(t,r))),V)(r))),Xe=n(((e,r)=>Object.assign({},e,r))),Ge=n(((e,r)=>O(ze(e),ze(r)))),He=n(((e,r)=>q(ze(e),ze(r)))),Je=n(((e,r)=>A(ze(e),ze(r)))),Me=x(((e,r,t)=>ye(e,r(t[e]),t))),Qe=n(((e,r)=>E(e,Object.assign({},r)))),Re=n(((e,r)=>$e(((e,t)=>[e,r[t]]),e))),Ve=n(((e,r)=>Ne(((e,t,s)=>ye(t,r[s],e)),{},e))),Ye=x(((e,r,t)=>$e(((r,s)=>e(r,t[s])),r))),Ze=(()=>{const e=async(r,t,s)=>{s<t.length&&(await r(t[s]),await e(r,t,++s))};return n(((r,t)=>e(r,t,0)))})(),er=n((async(e,r)=>(await e(r),r))),rr=n(((e,r)=>Promise.all(r.map(e)))),tr=(()=>{const e=async(r,t,s)=>~s?await e(r,await r[s](t),--s):t;return(...r)=>t=>e(r,t,r.length-1)})(),sr=M,or=M,pr=M,nr=R,xr=ee;exports.F=se,exports.T=te,exports.__=e,exports.add=K,exports.all=be,exports.allPass=je,exports.always=J,exports.any=we,exports.anyPass=Oe,exports.append=ee,exports.assoc=ye,exports.assocPath=ge,exports.bind=_,exports.both=Ke,exports.callWith=oe,exports.clone=ze,exports.cloneShallow=e=>ze(e,!0),exports.complement=R,exports.compose=B,exports.composeAsync=tr,exports.concat=Te,exports.cond=me,exports.curry=o,exports.curry2=n,exports.curry3=x,exports.divide=X,exports.echo=pr,exports.empty=e=>{switch(m(e)){case"String":return"";case"Object":return{};case"Array":return[];default:return c}},exports.equals=D,exports.explore=(e,r="log")=>Z((t=>console[r](e,t))),exports.filter=We,exports.find=fe,exports.findIndex=he,exports.flip=U,exports.forEach=Fe,exports.forEachAsync=rr,exports.forEachSerial=Ze,exports.fromPairs=Ie,exports.genBy=xe,exports.getTmpl=e=>{const r=[],t=[],s=e.length;let o,p,n,x=0,c=0,a=!1,i=$(e),l=!1;for(x=0;x<s;x++)switch(o=e[x],o){case"{":if(!i){a=!0,c=x;break}case"}":if(!i){a=!1,r.push(""),t.push(e.slice(c+1,x));break}default:n=e[x+1],l="\\"===o,a||l&&("{"===n||"}"===n)||(p=r.length-1,p<0&&(r.push(""),p++),r[p]+=o),i=l}return e=>{const s=[],o=r.length-1;for(const p in r)x=+p,s.push(r[x]),x!==o&&s.push(Se(t[x].split("."),e));return s.join("")}},exports.gt=ce,exports.gte=ie,exports.head=$,exports.identity=M,exports.ifElse=z,exports.includes=I,exports.indexOf=de,exports.intersection=ne,exports.isEmpty=e=>{switch(m(e)){case"String":case"Array":return 0==H(e);case"Object":for(const r in e)return!1;return!0;default:return null}},exports.isNil=G,exports.join=Ue,exports.keys=e=>Object.keys(e),exports.last=e=>e[H(e)-1],exports.length=H,exports.lt=ae,exports.lte=le,exports.map=$e,exports.mapKeys=Qe,exports.memoize=e=>{let r,t=!1;return()=>t?r:(t=!0,r=e())},exports.mergeDeep=Ge,exports.mergeDeepAdd=Je,exports.mergeDeepX=He,exports.mergeShallow=Xe,exports.mirror=sr,exports.multiply=W,exports.noop=(...e)=>{},exports.not=Q,exports.notf=nr,exports.nth=C,exports.omit=Ce,exports.once=e=>{let r,t=!1;return(...s)=>t?r:(t=!0,r=e(...s))},exports.overProp=Me,exports.path=Se,exports.pathEq=ve,exports.pathOr=ke,exports.pathsEq=Pe,exports.pick=_e,exports.pickBy=Be,exports.prop=qe,exports.propEq=Ae,exports.propsEq=Ee,exports.push=xr,exports.qappend=g,exports.qassoc=b,exports.qfilter=S,exports.qindexOf=v,exports.qmap=k,exports.qmapKeys=E,exports.qmergeDeep=O,exports.qmergeDeepAdd=A,exports.qmergeDeepX=q,exports.qreduce=w,exports.range=pe,exports.reduce=Ne,exports.reflect=or,exports.replace=Le,exports.reverse=e=>B((r=>Ne(((t,s,o)=>g(e[r-o],t)),[],e)),K(-1),H)(e),exports.sizeof=e=>{if("Object"===m(e)){let r=0;for(let t in e)r++;return r}return H(e)},exports.slice=T,exports.sort=ue,exports.split=re,exports.subtract=L,exports.tail=F,exports.take=P,exports.tap=Z,exports.test=Y,exports.toLower=e=>e.toLowerCase(),exports.toPairs=V,exports.toUpper=e=>e.toUpperCase(),exports.trim=e=>e.trim(),exports.type=m,exports.typeIs=y,exports.uncurry=e=>(...r)=>w(((e,r)=>e?e(r):e),e,r),exports.uniq=e=>w(((e,r)=>I(r,e)?e:g(r,e)),[],e),exports.values=e=>Object.values(e),exports.waitAll=e=>Promise.all(e),exports.waitTap=er,exports.when=N,exports.zip=Re,exports.zipObj=Ve,exports.zipWith=Ye;
1
+ "use strict";const e=Symbol("Placeholder"),r=r=>{let t=0;for(const s of r)s!==e&&t++;return t},t=(r,t)=>{const s=r.length,o=r.slice(),p=t.length;let n=p,x=0;for(;n&&x<s;x++)o[x]===e&&(o[x]=t[p-n],n--);for(x=s;n;x++,n--)o[x]=t[p-n];return o},s=(e,o,p)=>{const n=e.length-o.length-r(p);if(n<1)return e(...t(o,p));{const r=(...r)=>s(e,t(o,p),r);return r.$args_left=n,r}},o=e=>(...t)=>e.length>r(t)?s(e,[],t):e(...t),p=r=>function(t){return t===e?r:r(t)};function n(r){return function(t,s){const o=t===e,n=arguments.length;if(1===n&&o)throw new Error("Senseless placeholder usage.");return arguments.length>1?o?p((e=>r(e,s))):r(t,s):e=>r(t,e)}}function x(e){return o(e)}const c=void 0,a=1/0,l=e=>typeof e,i=e=>null===e,u=e=>"number"==l(e),f=e=>Array.isArray(e),h=e=>"function"===l(e),m=e=>!i(e)&&"object"===l(e),d={u:"U",b:"B",n:"N",s:"S",f:"F"},y=e=>{const r=l(e);return"object"===r?i(e)?"Null":e.constructor.name:d[r[0]]+r.slice(1)},g=n(((e,r)=>y(r)===e)),b=e=>(...r)=>r[e],w=n(((e,r)=>e===r)),q=n(((e,r)=>e==r)),j=n(((e,r)=>{const t=y(e);if(w(t,y(r))&&(w(t,"Object")||w(t,"Array"))){if(i(e)||i(r))return w(e,r);if(w(e,r))return!0;for(const t of[e,r])for(const s in t)if(!(w(t,r)&&s in e||w(t,e)&&s in r&&j(e[s],r[s])))return!1;return!0}return w(e,r)})),O=o(((e,r,t,s)=>e(s)?r(s):t(s))),A=x(((e,r,t)=>O(e,r,M,t))),S=(...r)=>(...t)=>{let s,o=!0;for(let p=H(r)-1;p>-1;p--)o?(o=!1,s=r[p](...t)):s=s===e?r[p]():r[p](s);return s},E=n(((e,r)=>e.bind(r))),k=n(((e,r)=>r[e])),z=n(((e,r)=>{if((e=>"string"===l(e))(r))return r.includes(e);for(const t of r)if(j(t,e))return!0;return!1})),v=x(((e,r,t)=>t.slice(e,u(r)?r:a))),P=e=>n(((r,t)=>e(t,r))),D=k(0),N=v(1,a),B=n(((e,r)=>e+r)),T=n(((e,r)=>r-e)),_=n(((e,r)=>e*r)),C=n(((e,r)=>e>r)),F=n(((e,r)=>e<r)),I=n(((e,r)=>r>=e)),U=n(((e,r)=>r<=e)),$=n(((e,r)=>r.sort(e))),K=n(((e,r)=>r.find(e))),L=n(((e,r)=>r.findIndex(e))),W=n(((e,r)=>L(j(e),r))),X=n(((e,r)=>e/r)),G=e=>i(e)||(e=>e===c)(e),H=e=>e.length,J=e=>()=>e,M=e=>e,Q=e=>!e,R=n(((e,r)=>e.test(r))),V=n(((e,r)=>(e(r),r))),Y=n(((e,r)=>[...r,e])),Z=n(((e,r)=>[...r,e])),ee=n(((e,r)=>r.flat(e))),re=n(((e,r)=>r.split(e))),te=J(!0),se=J(!1),oe=n(((e,r)=>r(...e))),pe=o(((e,r,t)=>t[r](...e))),ne=e=>(...r)=>{const t=e(...r),s=h(t);return!s||s&&t.$args_left<=0?Q(t):ne(t)},xe=n(((e,r)=>ae(B(e),r-e))),ce=n(((e,r)=>e.filter(P(z)(r)))),ae=n(((e,r)=>[...Array(r)].map(((r,t)=>e(t))))),le=n(((e,r)=>{for(const[t,s]of e)if(t(r))return s(r)})),ie=x(((e,r,t)=>({...t,[e]:r}))),ue=x(((e,r,t)=>S((s=>ie(s,H(e)<2?r:ue(v(1,a,e),r,m(t[s])?t[s]:{}),t)),D)(e))),fe=n(((e,r)=>r.every(e))),he=n(((e,r)=>r.some(e))),me=n(((e,r)=>e.every((e=>e(r))))),de=n(((e,r)=>e.some((e=>e(r))))),ye=n(((e,r)=>r[e])),ge=x(((e,r,t)=>j(t[e],r))),be=x(((e,r,t)=>j(r[e],t[e]))),we=x(((e,r,t)=>O(H,(()=>G(t)?e:S(O(G,J(e),(t=>we(e,v(1,a,r),t))),P(ye)(t),D)(r)),J(t),r))),qe=we(c),je=x(((e,r,t)=>j(qe(e,t),r))),Oe=x(((e,r,t)=>j(qe(e,r),qe(e,t)))),Ae=/^(.*?)(8|16|32|64)(Clamped)?Array$/,Se=(e,r=!1)=>{const t=y(e);switch(t){case"Null":case"String":case"Number":case"Boolean":case"Symbol":return e;case"Array":return r?[...e]:Ne(S(Se,b(0)),e);case"Object":if(r)return{...e};const s={};for(let r in e)s[r]=Se(e[r]);return s;default:return Ae.test(t)?e.constructor.from(e):e}},Ee=x(((e,r,t)=>or(e,Se(r),t))),ke=n(((e,r)=>Ce(e,r))),ze=n(((e,r)=>{const t={};for(const s of e)s in r&&(t[s]=r[s]);return t})),ve=n(((e,r)=>Ce(((r,t)=>!z(t,e)),r))),Pe=n(((e,r)=>r.concat(e))),De=n(((e,r)=>r.join(e))),Ne=n(((e,r)=>r.map(e))),Be=n(((e,r)=>r.forEach(e))),Te=x(((e,r,t)=>r(t)&&e(t))),_e=x(((e,r,t)=>t.replace(e,r))),Ce=n(((e,r)=>f(r)?r.filter(e):ur(e,{...r}))),Fe=n(((e,r)=>Object.assign({},e,r))),Ie=n(((e,r)=>nr(Se(e),Se(r)))),Ue=n(((e,r)=>xr(Se(e),Se(r)))),$e=n(((e,r)=>cr(Se(e),Se(r)))),Ke=x(((e,r,t)=>ie(e,r(t[e]),t))),Le=n(((e,r)=>lr(e,Object.assign({},r)))),We=n(((e,r)=>Ne(((e,t)=>[e,r[t]]),e))),Xe=n(((e,r)=>Ee(((e,t,s)=>ie(t,r[s],e)),{},e))),Ge=x(((e,r,t)=>Ne(((r,s)=>e(r,t[s])),r))),He=(()=>{const e=async(r,t,s)=>{s<t.length&&(await r(t[s]),await e(r,t,++s))};return n(((r,t)=>e(r,t,0)))})(),Je=n((async(e,r)=>(await e(r),r))),Me=n(((e,r)=>Promise.all(r.map(e)))),Qe=(()=>{const e=async(r,t,s)=>~s?await e(r,[await r[s](...t)],--s):D(t);return(...r)=>(...t)=>e(r,t,r.length-1)})(),Re=M,Ve=M,Ye=M,Ze=ne,er=Y,rr=he,tr=n(((e,r)=>(r.push(e),r))),sr=x(((e,r,t)=>(t[e]=r,t))),or=x(((e,r,t)=>t.reduce(e,r))),pr=x(((e,r,t)=>{for(let s in t)switch(y(t[s])){case"Array":if(e>1&&"Array"===y(r[s]))switch(e){case 2:const o=r[s],p=t[s];for(const r in p)o[r]?pr(e,o[r],p[r]):o[r]=p[r];break;case 3:r[s].push(...t[s])}else r[s]=t[s];break;case"Object":if("Object"===y(r[s])){pr(e,r[s],t[s]);break}default:r[s]=t[s]}return r})),nr=pr(1),xr=pr(2),cr=pr(3),ar=n(((e,r)=>Object.assign(e,r))),lr=n(((e,r)=>{let t,s,o,p;for(t in e)t in r&&(s=e[t],[o,p]=h(s)?s(r[t],t,r):[s,r[t]],r[G(o)?t:o]=p,t!==o&&delete r[t]);return r})),ir=n(((e,r)=>{for(let t in r)r[t]=e(r[t],+t,r);return r})),ur=n(((e,r)=>{const t=f(r);let s,o;t&&(s=0,o=[]);for(let s in r)e(r[s],s)||(t?o.push(+s):delete r[s]);if(t)for(const e of o)r.splice(e-s++,1);return r})),fr=e=>{let r;for(const t in e)r=e[t],m(r)&&fr(r);return Object.freeze(e)},hr=e=>Object.freeze(e),mr=n(((e,r)=>r.unshift(e))),dr=x(((e,r,t)=>{const s=e[0];return sr(s,e.length<2?r:dr(e.slice(1),r,m(t[s])?t[s]:{}),t)}));exports.F=se,exports.T=te,exports.__=e,exports.add=B,exports.all=fe,exports.allPass=me,exports.always=J,exports.any=he,exports.anyPass=de,exports.append=Y,exports.assoc=ie,exports.assocPath=ue,exports.bind=E,exports.both=Te,exports.callFrom=pe,exports.callWith=oe,exports.clone=Se,exports.cloneShallow=e=>Se(e,!0),exports.complement=ne,exports.compose=S,exports.composeAsync=Qe,exports.concat=Pe,exports.cond=le,exports.curry=o,exports.curry2=n,exports.curry3=x,exports.divide=X,exports.echo=Ye,exports.empty=e=>{switch(y(e)){case"String":return"";case"Object":return{};case"Array":return[];default:return c}},exports.eq=w,exports.equals=j,exports.explore=(e,r="log")=>V((t=>console[r](e,t))),exports.filter=Ce,exports.find=K,exports.findIndex=L,exports.flat=e=>e.flat(a),exports.flatShallow=e=>e.flat(),exports.flatTo=ee,exports.flip=P,exports.forEach=Be,exports.forEachAsync=Me,exports.forEachSerial=He,exports.freeze=e=>fr(Se(e)),exports.freezeShallow=e=>hr(Se(e)),exports.fromPairs=e=>Object.fromEntries(e),exports.genBy=ae,exports.getTmpl=e=>{const r=[],t=[],s=e.length;let o,p,n,x=0,c=0,a=!1,l=D(e),i=!1;for(x=0;x<s;x++)switch(o=e[x],o){case"{":if(!l){a=!0,c=x;break}case"}":if(!l){a=!1,r.push(""),t.push(e.slice(c+1,x));break}default:n=e[x+1],i="\\"===o,a||i&&("{"===n||"}"===n)||(p=r.length-1,p<0&&(r.push(""),p++),r[p]+=o),l=i}return e=>{const s=[],o=r.length-1;for(const p in r)x=+p,s.push(r[x]),x!==o&&s.push(qe(t[x].split("."),e));return s.join("")}},exports.gt=C,exports.gte=I,exports.head=D,exports.identity=M,exports.ifElse=O,exports.includes=z,exports.indexOf=W,exports.intersection=ce,exports.isEmpty=e=>{switch(y(e)){case"String":case"Array":return 0==H(e);case"Object":for(const r in e)return!1;return!0;default:return null}},exports.isNil=G,exports.join=De,exports.keys=e=>Object.keys(e),exports.last=e=>e[H(e)-1],exports.length=H,exports.lt=F,exports.lte=U,exports.map=Ne,exports.mapKeys=Le,exports.memoize=e=>{let r,t=!1;return()=>t?r:(t=!0,r=e())},exports.mergeDeep=Ie,exports.mergeDeepAdd=$e,exports.mergeDeepX=Ue,exports.mergeShallow=Fe,exports.mirror=Re,exports.multiply=_,exports.noop=()=>{},exports.not=Q,exports.notf=Ze,exports.nth=k,exports.omit=ve,exports.once=e=>{let r,t=!1;return(...s)=>t?r:(t=!0,r=e(...s))},exports.overProp=Ke,exports.path=qe,exports.pathEq=je,exports.pathOr=we,exports.pathsEq=Oe,exports.pick=ze,exports.pickBy=ke,exports.prepend=Z,exports.prop=ye,exports.propEq=ge,exports.propsEq=be,exports.push=er,exports.qappend=tr,exports.qassoc=sr,exports.qassocPath=dr,exports.qempty=e=>{if(f(e))e.splice(0);else for(const r in e)delete e[r];return e},exports.qfilter=ur,exports.qfreeze=fr,exports.qfreezeShallow=hr,exports.qmap=ir,exports.qmapKeys=lr,exports.qmergeDeep=nr,exports.qmergeDeepAdd=cr,exports.qmergeDeepX=xr,exports.qmergeShallow=ar,exports.qprepend=mr,exports.qreduce=or,exports.qreverse=e=>e.reverse(),exports.range=xe,exports.reduce=Ee,exports.reflect=Ve,exports.replace=_e,exports.reverse=e=>S((r=>Ee(((t,s,o)=>tr(e[r-o],t)),[],e)),B(-1),H)(e),exports.sizeof=e=>{if("Object"===y(e)){let r=0;for(let t in e)r++;return r}return H(e)},exports.slice=v,exports.some=rr,exports.sort=$,exports.split=re,exports.subtract=T,exports.tail=N,exports.take=b,exports.tap=V,exports.test=R,exports.toLower=e=>e.toLowerCase(),exports.toPairs=e=>Object.entries(e),exports.toUpper=e=>e.toUpperCase(),exports.trim=e=>e.trim(),exports.type=y,exports.typeIs=g,exports.uncurry=e=>(...r)=>or(((e,r)=>e?e(r):e),e,r),exports.uniq=e=>or(((e,r)=>z(r,e)?e:tr(r,e)),[],e),exports.values=e=>Object.values(e),exports.waitAll=e=>Promise.all(e),exports.waitTap=Je,exports.weakEq=q,exports.when=A,exports.zip=We,exports.zipObj=Xe,exports.zipWith=Ge;
package/dist/bundle.d.ts CHANGED
@@ -1,27 +1,29 @@
1
1
  export { __ }
2
2
 
3
- // Generated by dts-bundle-generator v7.1.0
3
+ // Generated by dts-bundle-generator v8.0.0
4
4
 
5
- export type Cond = (...xs: any[]) => boolean;
5
+ export type Cond = (x1?: any, x2?: any, x3?: any) => boolean;
6
6
  export interface AnyObject {
7
7
  [k: string]: any;
8
8
  }
9
9
  export type AnyArgs = any[];
10
- export type Curried<Args extends AnyArgs = AnyArgs, ReturnT = any> = (arg: Args[number]) => Curried<Args> | ReturnT;
10
+ export type Reducer<T = any> = (accum: T, cur: any, index: number) => T;
11
11
  export type AnyFunc<ReturnT = any, Args extends AnyArgs = AnyArgs> = (...args: Args) => ReturnT;
12
- export type Placeholder = symbol;
12
+ export type TupleFn<ARG1 = any, ARG2 = any, Out = any> = (a: ARG1, b: ARG2) => Out;
13
+ export type Curried<Args extends AnyArgs = AnyArgs, ReturnT = any> = (arg: Args[number]) => Curried<Args> | ReturnT;
14
+ type Placeholder = symbol;
13
15
  declare const __: Placeholder;
14
16
  export declare const curry: (fn: AnyFunc) => (...args: AnyArgs) => any;
15
- export type Func2 = (a: any, b: any) => any;
17
+ type Func2 = (a: any, b: any) => any;
16
18
  export declare function curry2<Func extends Func2>(fn: Func): {
17
19
  (a: Placeholder, b: Parameters<Func>[1]): (a: Parameters<Func>[0]) => ReturnType<Func>;
18
20
  (a: Parameters<Func>[0], b: Placeholder): (b: Parameters<Func>[1]) => ReturnType<Func>;
19
21
  (a: Parameters<Func>[0]): (b: Parameters<Func>[1]) => ReturnType<Func>;
20
22
  (a: Parameters<Func>[0], b: Parameters<Func>[1]): ReturnType<Func>;
21
23
  };
22
- export type Func3 = (a: any, b: any, c: any) => any;
24
+ type Func3 = (a: any, b: any, c: any) => any;
23
25
  export declare function curry3<Func extends Func3>(fn: Func): (...args: AnyArgs) => any;
24
- export declare const uncurry: <Args extends any[] = any[], ReturnT = any>(fn: Curried<Args, any>) => AnyFunc;
26
+ export declare const uncurry: <Args extends any[] = any[], ReturnT = any>(fn: Curried<Args>) => AnyFunc;
25
27
  export declare const toLower: (s: string) => string;
26
28
  export declare const toUpper: (s: string) => string;
27
29
  export declare const type: (s: any) => any;
@@ -32,6 +34,18 @@ export declare const typeIs: {
32
34
  (a: string, b: any): boolean;
33
35
  };
34
36
  export declare const take: (argN: number) => (...args: any[]) => any;
37
+ export declare const eq: {
38
+ (a: symbol, b: any): (a: any) => boolean;
39
+ (a: any, b: symbol): (b: any) => boolean;
40
+ (a: any): (b: any) => boolean;
41
+ (a: any, b: any): boolean;
42
+ };
43
+ export declare const weakEq: {
44
+ (a: symbol, b: any): (a: any) => boolean;
45
+ (a: any, b: symbol): (b: any) => boolean;
46
+ (a: any): (b: any) => boolean;
47
+ (a: any, b: any): boolean;
48
+ };
35
49
  export declare const equals: {
36
50
  (a: symbol, b: any): (a: any) => boolean;
37
51
  (a: any, b: symbol): (b: any) => boolean;
@@ -40,7 +54,7 @@ export declare const equals: {
40
54
  };
41
55
  export declare const ifElse: (...args: AnyArgs) => any;
42
56
  export declare const when: (...args: AnyArgs) => any;
43
- export type Composed<TIn extends any[], TOut> = (...xs: TIn) => TOut;
57
+ type Composed<TIn extends any[], TOut> = (...xs: TIn) => TOut;
44
58
  export declare const compose: <TIn extends any[] = any[], TOut = any>(...fns: AnyFunc[]) => Composed<TIn, TOut>;
45
59
  export declare const bind: {
46
60
  (a: symbol, b: any): (a: any) => any;
@@ -61,7 +75,7 @@ export declare const includes: {
61
75
  (a: unknown, b: unknown[]): boolean;
62
76
  };
63
77
  export declare const slice: (...args: AnyArgs) => any;
64
- export declare const flip: <T extends AnyFunc<any, AnyArgs>>(fn: T) => {
78
+ export declare const flip: <T extends AnyFunc>(fn: T) => {
65
79
  (a: symbol, b: Parameters<T>[0]): (a: Parameters<T>[1]) => any;
66
80
  (a: Parameters<T>[1], b: symbol): (b: Parameters<T>[0]) => any;
67
81
  (a: Parameters<T>[1]): (b: Parameters<T>[0]) => any;
@@ -87,6 +101,54 @@ export declare const multiply: {
87
101
  (a: number): (b: number) => number;
88
102
  (a: number, b: number): number;
89
103
  };
104
+ export declare const gt: {
105
+ (a: symbol, b: number): (a: number) => boolean;
106
+ (a: number, b: symbol): (b: number) => boolean;
107
+ (a: number): (b: number) => boolean;
108
+ (a: number, b: number): boolean;
109
+ };
110
+ export declare const lt: {
111
+ (a: symbol, b: number): (a: number) => boolean;
112
+ (a: number, b: symbol): (b: number) => boolean;
113
+ (a: number): (b: number) => boolean;
114
+ (a: number, b: number): boolean;
115
+ };
116
+ export declare const gte: {
117
+ (a: symbol, b: number): (a: number) => boolean;
118
+ (a: number, b: symbol): (b: number) => boolean;
119
+ (a: number): (b: number) => boolean;
120
+ (a: number, b: number): boolean;
121
+ };
122
+ export declare const lte: {
123
+ (a: symbol, b: number): (a: number) => boolean;
124
+ (a: number, b: symbol): (b: number) => boolean;
125
+ (a: number): (b: number) => boolean;
126
+ (a: number, b: number): boolean;
127
+ };
128
+ export declare const sort: {
129
+ (a: symbol, b: any[]): (a: any) => any[];
130
+ (a: any, b: symbol): (b: any[]) => any[];
131
+ (a: any): (b: any[]) => any[];
132
+ (a: any, b: any[]): any[];
133
+ };
134
+ export declare const find: {
135
+ (a: symbol, b: any[]): (a: Cond) => any;
136
+ (a: Cond, b: symbol): (b: any[]) => any;
137
+ (a: Cond): (b: any[]) => any;
138
+ (a: Cond, b: any[]): any;
139
+ };
140
+ export declare const findIndex: {
141
+ (a: symbol, b: any[]): (a: Cond) => number;
142
+ (a: Cond, b: symbol): (b: any[]) => number;
143
+ (a: Cond): (b: any[]) => number;
144
+ (a: Cond, b: any[]): number;
145
+ };
146
+ export declare const indexOf: {
147
+ (a: symbol, b: any[]): (a: any) => number;
148
+ (a: any, b: symbol): (b: any[]) => number;
149
+ (a: any): (b: any[]) => number;
150
+ (a: any, b: any[]): number;
151
+ };
90
152
  export declare const divide: {
91
153
  (a: symbol, b: number): (a: number) => number;
92
154
  (a: number, b: symbol): (b: number) => number;
@@ -99,9 +161,20 @@ export declare const always: <T = any>(s: T) => () => T;
99
161
  export declare const identity: (s: any) => any;
100
162
  export declare const trim: (s: string) => string;
101
163
  export declare const last: (s: any[] | string) => any;
102
- export declare const not: (o: boolean) => boolean;
103
- export declare const complement: (fn: AnyFunc) => (...args: any) => boolean | any;
104
- export declare const keys: (o: AnyObject | any[]) => string[];
164
+ type NotOverload = {
165
+ (x: true): false;
166
+ (x: false): true;
167
+ (x: any): boolean;
168
+ };
169
+ export declare const not: NotOverload;
170
+ type IndexesOfArray<A> = Exclude<keyof A, keyof [
171
+ ]>;
172
+ type KeysOverload = {
173
+ <T extends any[]>(o: T): string[];
174
+ <T extends readonly any[]>(o: T): IndexesOfArray<T>[];
175
+ <T extends AnyObject>(o: T): (keyof T)[];
176
+ };
177
+ export declare const keys: KeysOverload;
105
178
  export declare const values: (o: AnyObject | any[]) => any[];
106
179
  export declare const toPairs: (o: AnyObject | any[]) => [
107
180
  string,
@@ -125,6 +198,20 @@ export declare const append: {
125
198
  (a: any): (b: any[]) => any[];
126
199
  (a: any, b: any[]): any[];
127
200
  };
201
+ export declare const prepend: {
202
+ (a: symbol, b: any[]): (a: any) => any[];
203
+ (a: any, b: symbol): (b: any[]) => any[];
204
+ (a: any): (b: any[]) => any[];
205
+ (a: any, b: any[]): any[];
206
+ };
207
+ export declare const flat: (xs: any[]) => any[];
208
+ export declare const flatShallow: (xs: any[]) => any[];
209
+ export declare const flatTo: {
210
+ (a: symbol, b: any[]): (a: number) => any[];
211
+ (a: number, b: symbol): (b: any[]) => any[];
212
+ (a: number): (b: any[]) => any[];
213
+ (a: number, b: any[]): any[];
214
+ };
128
215
  export declare const split: {
129
216
  (a: symbol, b: string): (a: string | RegExp) => string[];
130
217
  (a: string | RegExp, b: symbol): (b: string) => string[];
@@ -134,12 +221,18 @@ export declare const split: {
134
221
  export declare const T: (...args: any[]) => true;
135
222
  export declare const F: (...args: any[]) => false;
136
223
  export declare const callWith: {
137
- (a: symbol, b: AnyFunc<any, AnyArgs>): (a: any[]) => any;
138
- (a: any[], b: symbol): (b: AnyFunc<any, AnyArgs>) => any;
139
- (a: any[]): (b: AnyFunc<any, AnyArgs>) => any;
140
- (a: any[], b: AnyFunc<any, AnyArgs>): any;
141
- };
142
- export declare const noop: (..._args: any[]) => void;
224
+ (a: symbol, b: AnyFunc): (a: any[]) => any;
225
+ (a: any[], b: symbol): (b: AnyFunc) => any;
226
+ (a: any[]): (b: AnyFunc) => any;
227
+ (a: any[], b: AnyFunc): any;
228
+ };
229
+ export declare const noop: (...args: any[]) => any;
230
+ /** Calls a func from object.
231
+ * @param {any[]} [args] - arguments for the function.
232
+ * @param {string} [fnName] - property name of the function.
233
+ * @param {AnyObject} [o] - the object with the function. */
234
+ export declare const callFrom: (...args: AnyArgs) => any;
235
+ export declare const complement: (fn: AnyFunc) => (...args: any) => boolean | any;
143
236
  export declare const sizeof: (s: any[] | string | AnyObject) => number;
144
237
  export declare const range: {
145
238
  (a: symbol, b: number): (a: number) => any[];
@@ -160,56 +253,8 @@ export declare const genBy: {
160
253
  (a: (i: number) => any): (b: number) => any[];
161
254
  (a: (i: number) => any, b: number): any[];
162
255
  };
163
- export declare const once: <Func extends AnyFunc<any, AnyArgs>>(fn: Func) => (...args: Parameters<Func>) => any;
256
+ export declare const once: <Func extends AnyFunc>(fn: Func) => (...args: Parameters<Func>) => any;
164
257
  export declare const reverse: (xs: any[]) => any;
165
- export declare const gt: {
166
- (a: symbol, b: number): (a: number) => boolean;
167
- (a: number, b: symbol): (b: number) => boolean;
168
- (a: number): (b: number) => boolean;
169
- (a: number, b: number): boolean;
170
- };
171
- export declare const lt: {
172
- (a: symbol, b: number): (a: number) => boolean;
173
- (a: number, b: symbol): (b: number) => boolean;
174
- (a: number): (b: number) => boolean;
175
- (a: number, b: number): boolean;
176
- };
177
- export declare const gte: {
178
- (a: symbol, b: number): (a: number) => boolean;
179
- (a: number, b: symbol): (b: number) => boolean;
180
- (a: number): (b: number) => boolean;
181
- (a: number, b: number): boolean;
182
- };
183
- export declare const lte: {
184
- (a: symbol, b: number): (a: number) => boolean;
185
- (a: number, b: symbol): (b: number) => boolean;
186
- (a: number): (b: number) => boolean;
187
- (a: number, b: number): boolean;
188
- };
189
- export declare const sort: {
190
- (a: symbol, b: any[]): (a: any) => any[];
191
- (a: any, b: symbol): (b: any[]) => any[];
192
- (a: any): (b: any[]) => any[];
193
- (a: any, b: any[]): any[];
194
- };
195
- export declare const find: {
196
- (a: symbol, b: any[]): (a: Cond) => any;
197
- (a: Cond, b: symbol): (b: any[]) => any;
198
- (a: Cond): (b: any[]) => any;
199
- (a: Cond, b: any[]): any;
200
- };
201
- export declare const findIndex: {
202
- (a: symbol, b: any[]): (a: Cond) => number;
203
- (a: Cond, b: symbol): (b: any[]) => number;
204
- (a: Cond): (b: any[]) => number;
205
- (a: Cond, b: any[]): number;
206
- };
207
- export declare const indexOf: {
208
- (a: symbol, b: any[]): (a: any) => number;
209
- (a: any, b: symbol): (b: any[]) => number;
210
- (a: any): (b: any[]) => number;
211
- (a: any, b: any[]): number;
212
- };
213
258
  export declare const explore: (caption: string, level?: string) => (b: any) => any;
214
259
  export declare const cond: {
215
260
  (a: symbol, b: any): (a: [
@@ -274,6 +319,8 @@ export declare const pathEq: (...args: AnyArgs) => any;
274
319
  export declare const pathsEq: (...args: AnyArgs) => any;
275
320
  export declare const clone: (s: any, shallow?: boolean) => any;
276
321
  export declare const cloneShallow: (s: any) => any;
322
+ export declare const freeze: <T extends AnyObject>(o: T) => Readonly<T>;
323
+ export declare const freezeShallow: <T extends AnyObject>(o: T) => Readonly<T>;
277
324
  /** types T1, T2
278
325
  * @param reducer (accum: T1, current: T2, index: number) => newAccum: T1
279
326
  * @param accum T1
@@ -301,7 +348,9 @@ export declare const omit: {
301
348
  export declare const fromPairs: (pairs: [
302
349
  string,
303
350
  any
304
- ][]) => any;
351
+ ][]) => {
352
+ [k: string]: any;
353
+ };
305
354
  export declare const concat: {
306
355
  (a: symbol, b: string | any[]): (a: string | any[]) => string | any[];
307
356
  (a: string | any[], b: symbol): (b: string | any[]) => string | any[];
@@ -330,7 +379,12 @@ export declare const both: (...args: AnyArgs) => any;
330
379
  export declare const isEmpty: (s: any) => boolean | null;
331
380
  export declare const empty: (s: any) => {} | undefined;
332
381
  export declare const replace: (...args: AnyArgs) => any;
333
- export declare const filter: any;
382
+ export declare const filter: {
383
+ (a: symbol, b: any[] | AnyObject): (a: (v: any, k: string | number) => boolean) => any;
384
+ (a: (v: any, k: string | number) => boolean, b: symbol): (b: any[] | AnyObject) => any;
385
+ (a: (v: any, k: string | number) => boolean): (b: any[] | AnyObject) => any;
386
+ (a: (v: any, k: string | number) => boolean, b: any[] | AnyObject): any;
387
+ };
334
388
  export declare const memoize: (fn: Function) => () => any;
335
389
  export declare const mergeShallow: {
336
390
  (a: symbol, b: AnyObject): (a: AnyObject) => AnyObject;
@@ -360,16 +414,16 @@ export declare const overProp: (...args: AnyArgs) => any;
360
414
  /** mapKeys({ a: 'b' }, { a: 44 }) -> { b: 44 } */
361
415
  export declare const mapKeys: {
362
416
  (a: symbol, b: AnyObject): (a: {
363
- [oldKey: string]: string;
417
+ [oldKey: string]: string | AnyFunc;
364
418
  }) => AnyObject;
365
419
  (a: {
366
- [oldKey: string]: string;
420
+ [oldKey: string]: string | AnyFunc;
367
421
  }, b: symbol): (b: AnyObject) => AnyObject;
368
422
  (a: {
369
- [oldKey: string]: string;
423
+ [oldKey: string]: string | AnyFunc;
370
424
  }): (b: AnyObject) => AnyObject;
371
425
  (a: {
372
- [oldKey: string]: string;
426
+ [oldKey: string]: string | AnyFunc;
373
427
  }, b: AnyObject): AnyObject;
374
428
  };
375
429
  export declare const zip: {
@@ -393,18 +447,23 @@ export declare const zipObj: {
393
447
  export declare const zipWith: (...args: AnyArgs) => any;
394
448
  /** One promise waits for another. */
395
449
  export declare const forEachSerial: {
396
- (a: symbol, b: any[]): (a: AnyFunc<any, AnyArgs>) => Promise<void>;
397
- (a: AnyFunc<any, AnyArgs>, b: symbol): (b: any[]) => Promise<void>;
398
- (a: AnyFunc<any, AnyArgs>): (b: any[]) => Promise<void>;
399
- (a: AnyFunc<any, AnyArgs>, b: any[]): Promise<void>;
450
+ (a: symbol, b: any[]): (a: AnyFunc) => Promise<void>;
451
+ (a: AnyFunc, b: symbol): (b: any[]) => Promise<void>;
452
+ (a: AnyFunc): (b: any[]) => Promise<void>;
453
+ (a: AnyFunc, b: any[]): Promise<void>;
400
454
  };
401
455
  /** Promise.all wrapper for functional pipelining. */
402
456
  export declare const waitAll: (promises: Promise<any>[]) => Promise<any[]>;
457
+ /** Waits for a Promise that been generated by the first arg, then returns an untoched value. Types T.
458
+ * @param {AnyFunc<Promise>} fn - function to wait.
459
+ * @param {T} s - any value to tap and return back
460
+ * @returns {T}
461
+ */
403
462
  export declare const waitTap: {
404
- (a: symbol, b: any): (a: Function) => Promise<any>;
405
- (a: Function, b: symbol): (b: any) => Promise<any>;
406
- (a: Function): (b: any) => Promise<any>;
407
- (a: Function, b: any): Promise<any>;
463
+ (a: symbol, b: any): (a: AnyFunc) => Promise<any>;
464
+ (a: AnyFunc, b: symbol): (b: any) => Promise<any>;
465
+ (a: AnyFunc): (b: any) => Promise<any>;
466
+ (a: AnyFunc, b: any): Promise<any>;
408
467
  };
409
468
  /** Waits for all promises mapped by the fn. */
410
469
  export declare const forEachAsync: {
@@ -414,7 +473,7 @@ export declare const forEachAsync: {
414
473
  (a: (item: any) => Promise<any>, b: any[]): Promise<any[]>;
415
474
  };
416
475
  /** The same as compose, but waits for promises in chains and returns a Promise. */
417
- export declare const composeAsync: <T = any>(...fns: AnyFunc[]) => (data?: any) => Promise<T>;
476
+ export declare const composeAsync: <T = any>(...fns: AnyFunc[]) => (...input: any[]) => Promise<T>;
418
477
  export declare const mirror: (s: any) => any;
419
478
  export declare const reflect: (s: any) => any;
420
479
  export declare const echo: (s: any) => any;
@@ -425,6 +484,12 @@ export declare const push: {
425
484
  (a: any): (b: any[]) => any[];
426
485
  (a: any, b: any[]): any[];
427
486
  };
487
+ export declare const some: {
488
+ (a: symbol, b: any[]): (a: Cond) => boolean;
489
+ (a: Cond, b: symbol): (b: any[]) => boolean;
490
+ (a: Cond): (b: any[]) => boolean;
491
+ (a: Cond, b: any[]): boolean;
492
+ };
428
493
  export declare const qappend: {
429
494
  (a: symbol, b: any[]): (a: any) => any[];
430
495
  (a: any, b: symbol): (b: any[]) => any[];
@@ -436,19 +501,25 @@ export declare const qreduce: (...args: AnyArgs) => any;
436
501
  export declare const qmergeDeep: any;
437
502
  export declare const qmergeDeepX: any;
438
503
  export declare const qmergeDeepAdd: any;
504
+ export declare const qmergeShallow: {
505
+ (a: symbol, b: AnyObject): (a: AnyObject) => AnyObject;
506
+ (a: AnyObject, b: symbol): (b: AnyObject) => AnyObject;
507
+ (a: AnyObject): (b: AnyObject) => AnyObject;
508
+ (a: AnyObject, b: AnyObject): AnyObject;
509
+ };
439
510
  /** qmapKeys({ a: 'b' }, { a: 44 }) -> { b: 44 } */
440
511
  export declare const qmapKeys: {
441
512
  (a: symbol, b: AnyObject): (a: {
442
- [oldKey: string]: string;
513
+ [oldKey: string]: string | AnyFunc;
443
514
  }) => AnyObject;
444
515
  (a: {
445
- [oldKey: string]: string;
516
+ [oldKey: string]: string | AnyFunc;
446
517
  }, b: symbol): (b: AnyObject) => AnyObject;
447
518
  (a: {
448
- [oldKey: string]: string;
519
+ [oldKey: string]: string | AnyFunc;
449
520
  }): (b: AnyObject) => AnyObject;
450
521
  (a: {
451
- [oldKey: string]: string;
522
+ [oldKey: string]: string | AnyFunc;
452
523
  }, b: AnyObject): AnyObject;
453
524
  };
454
525
  export declare const qmap: {
@@ -463,14 +534,18 @@ export declare const qfilter: {
463
534
  (a: (v: any, k: string | number) => boolean): (b: any[] | AnyObject) => any[] | AnyObject;
464
535
  (a: (v: any, k: string | number) => boolean, b: any[] | AnyObject): any[] | AnyObject;
465
536
  };
466
- /** @deprecated */
467
- export declare const qindexOf: {
537
+ export declare const qempty: (o: AnyObject | any[]) => any[] | AnyObject;
538
+ export declare const qfreeze: <T extends AnyObject>(o: T) => Readonly<T>;
539
+ export declare const qfreezeShallow: <T extends AnyObject>(o: T) => Readonly<T>;
540
+ export declare const qprepend: {
468
541
  (a: symbol, b: any[]): (a: any) => number;
469
542
  (a: any, b: symbol): (b: any[]) => number;
470
543
  (a: any): (b: any[]) => number;
471
544
  (a: any, b: any[]): number;
472
545
  };
473
- export type StrTmpl = ((data: AnyObject) => string);
546
+ export declare const qassocPath: any;
547
+ export declare const qreverse: (arr: any[]) => any[];
548
+ type StrTmpl = ((data: AnyObject) => string);
474
549
  export declare const getTmpl: (tmpl: string) => StrTmpl;
475
550
 
476
551
  export {};
package/dist/bundle.mjs CHANGED
@@ -1 +1 @@
1
- const e=Symbol("Placeholder"),r=r=>{let t=0;for(const n of r)n!==e&&t++;return t},t=(r,t)=>{const n=r.length,s=r.slice(),c=t.length;let o=c,u=0;for(;o&&u<n;u++)s[u]===e&&(s[u]=t[c-o],o--);for(u=n;o;u++,o--)s[u]=t[c-o];return s},n=(e,s,c)=>{const o=e.length-s.length-r(c);if(o<1)return e(...t(s,c));{const r=(...r)=>n(e,t(s,c),r);return r.$args_left=o,r}},s=e=>(...t)=>e.length>r(t)?n(e,[],t):e(...t),c=r=>function(t){return t===e?r:r(t)};function o(r){return function(t,n){const s=t===e,o=arguments.length;if(1===o&&s)throw new Error("Senseless placeholder usage.");return arguments.length>1?s?c((e=>r(e,n))):r(t,n):e=>r(t,e)}}function u(e){return s(e)}const a=void 0,i=1/0,l=e=>typeof e,f=e=>null===e,h=e=>"number"==l(e),b=e=>Array.isArray(e),g=e=>"function"===l(e),p={u:"U",b:"B",n:"N",s:"S",f:"F"},y=e=>e.toLowerCase(),d=e=>e.toUpperCase(),j=e=>{const r=l(e);return"object"===r?f(e)?"Null":e.constructor.name:p[r[0]]+r.slice(1)},m=o(((e,r)=>j(r)===e)),w=o(((e,r)=>(r.push(e),r))),O=u(((e,r,t)=>(t[e]=r,t))),A=u(((e,r,t)=>t.reduce(e,r))),S=u(((e,r,t)=>{for(let n in t)switch(j(t[n])){case"Array":if(e>1&&"Array"===j(r[n]))switch(e){case 2:const s=r[n],c=t[n];for(const r in c)s[r]?S(e,s[r],c[r]):s[r]=c[r];break;case 3:r[n].push(...t[n])}else r[n]=t[n];break;case"Object":if("Object"===j(r[n])){S(e,r[n],t[n]);break}default:r[n]=t[n]}return r})),k=S(1),v=S(2),N=S(3),x=o(((e,r)=>{let t,n,s,c;for(t in e)n=e[t],[s,c]=g(n)?n(r):[n,r[t]],r[s]=c,t!==s&&delete r[t];return r})),C=o(((e,r)=>{for(let t in r)r[t]=e(r[t],+t,r);return r})),P=o(((e,r)=>{const t=b(r);for(let n in r)e(r[n],n)||(t?r.splice(n,1):delete r[n]);return r})),$=o(((e,r)=>r.indexOf(e))),B=e=>(...r)=>A(((e,r)=>e?e(r):e),e,r),E=e=>(...r)=>r[e],U=o(((e,r)=>{const t=j(e);if(t===j(r)&&("Object"===t||"Array"==t)){if(f(e)||f(r))return e===r;if(e===r)return!0;for(const t of[e,r])for(const n in t)if(!(t===r&&n in e||t===e&&n in r&&U(e[n],r[n])))return!1;return!0}return e===r})),_=s(((e,r,t,n)=>e(n)?r(n):t(n))),F=u(((e,r,t)=>_(e,r,X,t))),I=(...r)=>(...t)=>{let n,s=!0;for(let c=V(r)-1;c>-1;c--)s?(s=!1,n=r[c](...t)):n=n===e?r[c]():r[c](n);return n},L=o(((e,r)=>e.bind(r))),q=o(((e,r)=>r[e])),z=o(((e,r)=>{if((e=>"string"===l(e))(r))return r.includes(e);for(const t of r)if(U(t,e))return!0;return!1})),D=u(((e,r,t)=>t.slice(e,h(r)?r:i))),G=e=>o(((r,t)=>e(t,r))),H=q(0),J=D(1,i),K=o(((e,r)=>e+r)),M=o(((e,r)=>r-e)),Q=o(((e,r)=>e*r)),R=o(((e,r)=>e/r)),T=e=>f(e)||(e=>e===a)(e),V=e=>e.length,W=e=>()=>e,X=e=>e,Y=e=>e.trim(),Z=e=>e[V(e)-1],ee=e=>!e,re=e=>(...r)=>{const t=e(...r),n=g(t);return!n||n&&t.$args_left<=0?ee(t):re(t)},te=e=>Object.keys(e),ne=e=>Object.values(e),se=e=>Object.entries(e),ce=o(((e,r)=>e.test(r))),oe=o(((e,r)=>(e(r),r))),ue=o(((e,r)=>[...r,e])),ae=o(((e,r)=>r.split(e))),ie=W(!0),le=W(!1),fe=o(((e,r)=>r(...e))),he=(...e)=>{},be=e=>{if("Object"===j(e)){let r=0;for(let t in e)r++;return r}return V(e)},ge=o(((e,r)=>de(K(e),r-e))),pe=e=>A(((e,r)=>z(r,e)?e:w(r,e)),[],e),ye=o(((e,r)=>e.filter(G(z)(r)))),de=o(((e,r)=>[...Array(r)].map(((r,t)=>e(t))))),je=e=>{let r,t=!1;return(...n)=>t?r:(t=!0,r=e(...n))},me=e=>I((r=>Qe(((t,n,s)=>w(e[r-s],t)),[],e)),K(-1),V)(e),we=o(((e,r)=>e>r)),Oe=o(((e,r)=>e<r)),Ae=o(((e,r)=>r>=e)),Se=o(((e,r)=>r<=e)),ke=o(((e,r)=>r.sort(e))),ve=o(((e,r)=>r.find(e))),Ne=o(((e,r)=>r.findIndex(e))),xe=o(((e,r)=>Ne(U(e),r))),Ce=(e,r="log")=>oe((t=>console[r](e,t))),Pe=o(((e,r)=>{for(const[t,n]of e)if(t(r))return n(r)})),$e=u(((e,r,t)=>({...t,[e]:r}))),Be=u(((e,r,t)=>I((n=>{return $e(n,V(e)<2?r:Be(D(1,i,e),r,(s=t[n],f(s)||"object"!==l(s)?{}:t[n])),t);var s}),H)(e))),Ee=o(((e,r)=>r.every(e))),Ue=o(((e,r)=>r.some(e))),_e=o(((e,r)=>e.every((e=>e(r))))),Fe=o(((e,r)=>e.some((e=>e(r))))),Ie=o(((e,r)=>r[e])),Le=u(((e,r,t)=>U(t[e],r))),qe=u(((e,r,t)=>U(r[e],t[e]))),ze=u(((e,r,t)=>_(V,(()=>T(t)?e:I(_(T,W(e),(t=>ze(e,D(1,i,r),t))),G(Ie)(t),H)(r)),W(t),r))),De=ze(a),Ge=u(((e,r,t)=>U(De(e,t),r))),He=u(((e,r,t)=>U(De(e,r),De(e,t)))),Je=/^(.*?)(8|16|32|64)(Clamped)?Array$/,Ke=(e,r=!1)=>{const t=j(e);switch(t){case"Null":case"String":case"Number":case"Boolean":case"Symbol":return e;case"Array":return r?[...e]:Ze(I(Ke,E(0)),e);case"Object":if(r)return{...e};const n={};for(let r in e)n[r]=Ke(e[r]);return n;default:return Je.test(t)?e.constructor.from(e):e}},Me=e=>Ke(e,!0),Qe=u(((e,r,t)=>A(e,Ke(r),t))),Re=o(((e,r)=>cr(e,r))),Te=o(((e,r)=>{const t={};for(const n of e)n in r&&(t[n]=r[n]);return t})),Ve=o(((e,r)=>cr(((r,t)=>!z(t,e)),r))),We=e=>Qe(((e,r)=>$e(...r,e)),{},e),Xe=o(((e,r)=>r.concat(e))),Ye=o(((e,r)=>r.join(e))),Ze=o(((e,r)=>r.map(e))),er=o(((e,r)=>r.forEach(e))),rr=u(((e,r,t)=>r(t)&&e(t))),tr=e=>{switch(j(e)){case"String":case"Array":return 0==V(e);case"Object":for(const r in e)return!1;return!0;default:return null}},nr=e=>{switch(j(e)){case"String":return"";case"Object":return{};case"Array":return[];default:return a}},sr=u(((e,r,t)=>t.replace(e,r))),cr=o(((e,r)=>b(r)?r.filter(e):I(We,cr((([r,t])=>e(t,r))),se)(r))),or=e=>{let r,t=!1;return()=>t?r:(t=!0,r=e())},ur=o(((e,r)=>Object.assign({},e,r))),ar=o(((e,r)=>k(Ke(e),Ke(r)))),ir=o(((e,r)=>v(Ke(e),Ke(r)))),lr=o(((e,r)=>N(Ke(e),Ke(r)))),fr=u(((e,r,t)=>$e(e,r(t[e]),t))),hr=o(((e,r)=>x(e,Object.assign({},r)))),br=o(((e,r)=>Ze(((e,t)=>[e,r[t]]),e))),gr=o(((e,r)=>Qe(((e,t,n)=>$e(t,r[n],e)),{},e))),pr=u(((e,r,t)=>Ze(((r,n)=>e(r,t[n])),r))),yr=(()=>{const e=async(r,t,n)=>{n<t.length&&(await r(t[n]),await e(r,t,++n))};return o(((r,t)=>e(r,t,0)))})(),dr=e=>Promise.all(e),jr=o((async(e,r)=>(await e(r),r))),mr=o(((e,r)=>Promise.all(r.map(e)))),wr=(()=>{const e=async(r,t,n)=>~n?await e(r,await r[n](t),--n):t;return(...r)=>t=>e(r,t,r.length-1)})(),Or=X,Ar=X,Sr=X,kr=re,vr=ue,Nr=e=>{const r=[],t=[],n=e.length;let s,c,o,u=0,a=0,i=!1,l=H(e),f=!1;for(u=0;u<n;u++)switch(s=e[u],s){case"{":if(!l){i=!0,a=u;break}case"}":if(!l){i=!1,r.push(""),t.push(e.slice(a+1,u));break}default:o=e[u+1],f="\\"===s,i||f&&("{"===o||"}"===o)||(c=r.length-1,c<0&&(r.push(""),c++),r[c]+=s),l=f}return e=>{const n=[],s=r.length-1;for(const c in r)u=+c,n.push(r[u]),u!==s&&n.push(De(t[u].split("."),e));return n.join("")}};export{le as F,ie as T,e as __,K as add,Ee as all,_e as allPass,W as always,Ue as any,Fe as anyPass,ue as append,$e as assoc,Be as assocPath,L as bind,rr as both,fe as callWith,Ke as clone,Me as cloneShallow,re as complement,I as compose,wr as composeAsync,Xe as concat,Pe as cond,s as curry,o as curry2,u as curry3,R as divide,Sr as echo,nr as empty,U as equals,Ce as explore,cr as filter,ve as find,Ne as findIndex,G as flip,er as forEach,mr as forEachAsync,yr as forEachSerial,We as fromPairs,de as genBy,Nr as getTmpl,we as gt,Ae as gte,H as head,X as identity,_ as ifElse,z as includes,xe as indexOf,ye as intersection,tr as isEmpty,T as isNil,Ye as join,te as keys,Z as last,V as length,Oe as lt,Se as lte,Ze as map,hr as mapKeys,or as memoize,ar as mergeDeep,lr as mergeDeepAdd,ir as mergeDeepX,ur as mergeShallow,Or as mirror,Q as multiply,he as noop,ee as not,kr as notf,q as nth,Ve as omit,je as once,fr as overProp,De as path,Ge as pathEq,ze as pathOr,He as pathsEq,Te as pick,Re as pickBy,Ie as prop,Le as propEq,qe as propsEq,vr as push,w as qappend,O as qassoc,P as qfilter,$ as qindexOf,C as qmap,x as qmapKeys,k as qmergeDeep,N as qmergeDeepAdd,v as qmergeDeepX,A as qreduce,ge as range,Qe as reduce,Ar as reflect,sr as replace,me as reverse,be as sizeof,D as slice,ke as sort,ae as split,M as subtract,J as tail,E as take,oe as tap,ce as test,y as toLower,se as toPairs,d as toUpper,Y as trim,j as type,m as typeIs,B as uncurry,pe as uniq,ne as values,dr as waitAll,jr as waitTap,F as when,br as zip,gr as zipObj,pr as zipWith};
1
+ const e=Symbol("Placeholder"),r=r=>{let t=0;for(const n of r)n!==e&&t++;return t},t=(r,t)=>{const n=r.length,s=r.slice(),c=t.length;let o=c,l=0;for(;o&&l<n;l++)s[l]===e&&(s[l]=t[c-o],o--);for(l=n;o;l++,o--)s[l]=t[c-o];return s},n=(e,s,c)=>{const o=e.length-s.length-r(c);if(o<1)return e(...t(s,c));{const r=(...r)=>n(e,t(s,c),r);return r.$args_left=o,r}},s=e=>(...t)=>e.length>r(t)?n(e,[],t):e(...t),c=r=>function(t){return t===e?r:r(t)};function o(r){return function(t,n){const s=t===e,o=arguments.length;if(1===o&&s)throw new Error("Senseless placeholder usage.");return arguments.length>1?s?c((e=>r(e,n))):r(t,n):e=>r(t,e)}}function l(e){return s(e)}const i=void 0,u=1/0,a=e=>typeof e,f=e=>null===e,h=e=>"number"==a(e),b=e=>Array.isArray(e),g=e=>"function"===a(e),p=e=>!f(e)&&"object"===a(e),j={u:"U",b:"B",n:"N",s:"S",f:"F"},y=e=>e.toLowerCase(),d=e=>e.toUpperCase(),m=e=>{const r=a(e);return"object"===r?f(e)?"Null":e.constructor.name:j[r[0]]+r.slice(1)},O=o(((e,r)=>m(r)===e)),w=e=>(...r)=>r[e],A=o(((e,r)=>e===r)),S=o(((e,r)=>e==r)),k=o(((e,r)=>{const t=m(e);if(A(t,m(r))&&(A(t,"Object")||A(t,"Array"))){if(f(e)||f(r))return A(e,r);if(A(e,r))return!0;for(const t of[e,r])for(const n in t)if(!(A(t,r)&&n in e||A(t,e)&&n in r&&k(e[n],r[n])))return!1;return!0}return A(e,r)})),v=s(((e,r,t,n)=>e(n)?r(n):t(n))),N=l(((e,r,t)=>v(e,r,W,t))),C=(...r)=>(...t)=>{let n,s=!0;for(let c=T(r)-1;c>-1;c--)s?(s=!1,n=r[c](...t)):n=n===e?r[c]():r[c](n);return n},E=o(((e,r)=>e.bind(r))),P=o(((e,r)=>r[e])),$=o(((e,r)=>{if((e=>"string"===a(e))(r))return r.includes(e);for(const t of r)if(k(t,e))return!0;return!1})),x=l(((e,r,t)=>t.slice(e,h(r)?r:u))),z=e=>o(((r,t)=>e(t,r))),B=P(0),U=x(1,u),_=o(((e,r)=>e+r)),D=o(((e,r)=>r-e)),F=o(((e,r)=>e*r)),I=o(((e,r)=>e>r)),L=o(((e,r)=>e<r)),q=o(((e,r)=>r>=e)),G=o(((e,r)=>r<=e)),H=o(((e,r)=>r.sort(e))),J=o(((e,r)=>r.find(e))),K=o(((e,r)=>r.findIndex(e))),M=o(((e,r)=>K(k(e),r))),Q=o(((e,r)=>e/r)),R=e=>f(e)||(e=>e===i)(e),T=e=>e.length,V=e=>()=>e,W=e=>e,X=e=>e.trim(),Y=e=>e[T(e)-1],Z=e=>!e,ee=e=>Object.keys(e),re=e=>Object.values(e),te=e=>Object.entries(e),ne=o(((e,r)=>e.test(r))),se=o(((e,r)=>(e(r),r))),ce=o(((e,r)=>[...r,e])),oe=o(((e,r)=>[...r,e])),le=e=>e.flat(u),ie=e=>e.flat(),ue=o(((e,r)=>r.flat(e))),ae=o(((e,r)=>r.split(e))),fe=V(!0),he=V(!1),be=o(((e,r)=>r(...e))),ge=()=>{},pe=s(((e,r,t)=>t[r](...e))),je=e=>(...r)=>{const t=e(...r),n=g(t);return!n||n&&t.$args_left<=0?Z(t):je(t)},ye=e=>{if("Object"===m(e)){let r=0;for(let t in e)r++;return r}return T(e)},de=o(((e,r)=>we(_(e),r-e))),me=e=>Cr(((e,r)=>$(r,e)?e:vr(r,e)),[],e),Oe=o(((e,r)=>e.filter(z($)(r)))),we=o(((e,r)=>[...Array(r)].map(((r,t)=>e(t))))),Ae=e=>{let r,t=!1;return(...n)=>t?r:(t=!0,r=e(...n))},Se=e=>C((r=>Ke(((t,n,s)=>vr(e[r-s],t)),[],e)),_(-1),T)(e),ke=(e,r="log")=>se((t=>console[r](e,t))),ve=o(((e,r)=>{for(const[t,n]of e)if(t(r))return n(r)})),Ne=l(((e,r,t)=>({...t,[e]:r}))),Ce=l(((e,r,t)=>C((n=>Ne(n,T(e)<2?r:Ce(x(1,u,e),r,p(t[n])?t[n]:{}),t)),B)(e))),Ee=o(((e,r)=>r.every(e))),Pe=o(((e,r)=>r.some(e))),$e=o(((e,r)=>e.every((e=>e(r))))),xe=o(((e,r)=>e.some((e=>e(r))))),ze=o(((e,r)=>r[e])),Be=l(((e,r,t)=>k(t[e],r))),Ue=l(((e,r,t)=>k(r[e],t[e]))),_e=l(((e,r,t)=>v(T,(()=>R(t)?e:C(v(R,V(e),(t=>_e(e,x(1,u,r),t))),z(ze)(t),B)(r)),V(t),r))),De=_e(i),Fe=l(((e,r,t)=>k(De(e,t),r))),Ie=l(((e,r,t)=>k(De(e,r),De(e,t)))),Le=/^(.*?)(8|16|32|64)(Clamped)?Array$/,qe=(e,r=!1)=>{const t=m(e);switch(t){case"Null":case"String":case"Number":case"Boolean":case"Symbol":return e;case"Array":return r?[...e]:Xe(C(qe,w(0)),e);case"Object":if(r)return{...e};const n={};for(let r in e)n[r]=qe(e[r]);return n;default:return Le.test(t)?e.constructor.from(e):e}},Ge=e=>qe(e,!0),He=e=>Fr(qe(e)),Je=e=>Ir(qe(e)),Ke=l(((e,r,t)=>Cr(e,qe(r),t))),Me=o(((e,r)=>nr(e,r))),Qe=o(((e,r)=>{const t={};for(const n of e)n in r&&(t[n]=r[n]);return t})),Re=o(((e,r)=>nr(((r,t)=>!$(t,e)),r))),Te=e=>Object.fromEntries(e),Ve=o(((e,r)=>r.concat(e))),We=o(((e,r)=>r.join(e))),Xe=o(((e,r)=>r.map(e))),Ye=o(((e,r)=>r.forEach(e))),Ze=l(((e,r,t)=>r(t)&&e(t))),er=e=>{switch(m(e)){case"String":case"Array":return 0==T(e);case"Object":for(const r in e)return!1;return!0;default:return null}},rr=e=>{switch(m(e)){case"String":return"";case"Object":return{};case"Array":return[];default:return i}},tr=l(((e,r,t)=>t.replace(e,r))),nr=o(((e,r)=>b(r)?r.filter(e):_r(e,{...r}))),sr=e=>{let r,t=!1;return()=>t?r:(t=!0,r=e())},cr=o(((e,r)=>Object.assign({},e,r))),or=o(((e,r)=>Pr(qe(e),qe(r)))),lr=o(((e,r)=>$r(qe(e),qe(r)))),ir=o(((e,r)=>xr(qe(e),qe(r)))),ur=l(((e,r,t)=>Ne(e,r(t[e]),t))),ar=o(((e,r)=>Br(e,Object.assign({},r)))),fr=o(((e,r)=>Xe(((e,t)=>[e,r[t]]),e))),hr=o(((e,r)=>Ke(((e,t,n)=>Ne(t,r[n],e)),{},e))),br=l(((e,r,t)=>Xe(((r,n)=>e(r,t[n])),r))),gr=(()=>{const e=async(r,t,n)=>{n<t.length&&(await r(t[n]),await e(r,t,++n))};return o(((r,t)=>e(r,t,0)))})(),pr=e=>Promise.all(e),jr=o((async(e,r)=>(await e(r),r))),yr=o(((e,r)=>Promise.all(r.map(e)))),dr=(()=>{const e=async(r,t,n)=>~n?await e(r,[await r[n](...t)],--n):B(t);return(...r)=>(...t)=>e(r,t,r.length-1)})(),mr=W,Or=W,wr=W,Ar=je,Sr=ce,kr=Pe,vr=o(((e,r)=>(r.push(e),r))),Nr=l(((e,r,t)=>(t[e]=r,t))),Cr=l(((e,r,t)=>t.reduce(e,r))),Er=l(((e,r,t)=>{for(let n in t)switch(m(t[n])){case"Array":if(e>1&&"Array"===m(r[n]))switch(e){case 2:const s=r[n],c=t[n];for(const r in c)s[r]?Er(e,s[r],c[r]):s[r]=c[r];break;case 3:r[n].push(...t[n])}else r[n]=t[n];break;case"Object":if("Object"===m(r[n])){Er(e,r[n],t[n]);break}default:r[n]=t[n]}return r})),Pr=Er(1),$r=Er(2),xr=Er(3),zr=o(((e,r)=>Object.assign(e,r))),Br=o(((e,r)=>{let t,n,s,c;for(t in e)t in r&&(n=e[t],[s,c]=g(n)?n(r[t],t,r):[n,r[t]],r[R(s)?t:s]=c,t!==s&&delete r[t]);return r})),Ur=o(((e,r)=>{for(let t in r)r[t]=e(r[t],+t,r);return r})),_r=o(((e,r)=>{const t=b(r);let n,s;t&&(n=0,s=[]);for(let n in r)e(r[n],n)||(t?s.push(+n):delete r[n]);if(t)for(const e of s)r.splice(e-n++,1);return r})),Dr=e=>{if(b(e))e.splice(0);else for(const r in e)delete e[r];return e},Fr=e=>{let r;for(const t in e)r=e[t],p(r)&&Fr(r);return Object.freeze(e)},Ir=e=>Object.freeze(e),Lr=o(((e,r)=>r.unshift(e))),qr=l(((e,r,t)=>{const n=e[0];return Nr(n,e.length<2?r:qr(e.slice(1),r,p(t[n])?t[n]:{}),t)})),Gr=e=>e.reverse(),Hr=e=>(...r)=>Cr(((e,r)=>e?e(r):e),e,r),Jr=e=>{const r=[],t=[],n=e.length;let s,c,o,l=0,i=0,u=!1,a=B(e),f=!1;for(l=0;l<n;l++)switch(s=e[l],s){case"{":if(!a){u=!0,i=l;break}case"}":if(!a){u=!1,r.push(""),t.push(e.slice(i+1,l));break}default:o=e[l+1],f="\\"===s,u||f&&("{"===o||"}"===o)||(c=r.length-1,c<0&&(r.push(""),c++),r[c]+=s),a=f}return e=>{const n=[],s=r.length-1;for(const c in r)l=+c,n.push(r[l]),l!==s&&n.push(De(t[l].split("."),e));return n.join("")}};export{he as F,fe as T,e as __,_ as add,Ee as all,$e as allPass,V as always,Pe as any,xe as anyPass,ce as append,Ne as assoc,Ce as assocPath,E as bind,Ze as both,pe as callFrom,be as callWith,qe as clone,Ge as cloneShallow,je as complement,C as compose,dr as composeAsync,Ve as concat,ve as cond,s as curry,o as curry2,l as curry3,Q as divide,wr as echo,rr as empty,A as eq,k as equals,ke as explore,nr as filter,J as find,K as findIndex,le as flat,ie as flatShallow,ue as flatTo,z as flip,Ye as forEach,yr as forEachAsync,gr as forEachSerial,He as freeze,Je as freezeShallow,Te as fromPairs,we as genBy,Jr as getTmpl,I as gt,q as gte,B as head,W as identity,v as ifElse,$ as includes,M as indexOf,Oe as intersection,er as isEmpty,R as isNil,We as join,ee as keys,Y as last,T as length,L as lt,G as lte,Xe as map,ar as mapKeys,sr as memoize,or as mergeDeep,ir as mergeDeepAdd,lr as mergeDeepX,cr as mergeShallow,mr as mirror,F as multiply,ge as noop,Z as not,Ar as notf,P as nth,Re as omit,Ae as once,ur as overProp,De as path,Fe as pathEq,_e as pathOr,Ie as pathsEq,Qe as pick,Me as pickBy,oe as prepend,ze as prop,Be as propEq,Ue as propsEq,Sr as push,vr as qappend,Nr as qassoc,qr as qassocPath,Dr as qempty,_r as qfilter,Fr as qfreeze,Ir as qfreezeShallow,Ur as qmap,Br as qmapKeys,Pr as qmergeDeep,xr as qmergeDeepAdd,$r as qmergeDeepX,zr as qmergeShallow,Lr as qprepend,Cr as qreduce,Gr as qreverse,de as range,Ke as reduce,Or as reflect,tr as replace,Se as reverse,ye as sizeof,x as slice,kr as some,H as sort,ae as split,D as subtract,U as tail,w as take,se as tap,ne as test,y as toLower,te as toPairs,d as toUpper,X as trim,m as type,O as typeIs,Hr as uncurry,me as uniq,re as values,pr as waitAll,jr as waitTap,S as weakEq,N as when,fr as zip,hr as zipObj,br as zipWith};
package/package.json CHANGED
@@ -1,80 +1,80 @@
1
- {
2
- "author": {
3
- "name": "Michael houd1ni Akiliev"
4
- },
5
- "bugs": {
6
- "url": "https://github.com/houd1ni/pepka/issues"
7
- },
8
- "deprecated": false,
9
- "description": "An ultra lightweight, async or unsafe-speedy ramda alternative.",
10
- "homepage": "https://houd1ni.github.io/pepka/",
11
- "keywords": [
12
- "ramda",
13
- "functional",
14
- "fp",
15
- "pure",
16
- "strongly-typed",
17
- "typescript",
18
- "d.ts"
19
- ],
20
- "license": "MIT",
21
- "type": "module",
22
- "exports": {
23
- ".": {
24
- "import": "./dist/bundle.mjs",
25
- "require": "./dist/bundle.cjs"
26
- }
27
- },
28
- "name": "pepka",
29
- "repository": {
30
- "type": "git",
31
- "url": "git+https://github.com/houd1ni/pepka.git"
32
- },
33
- "scripts": {
34
- "lint": "tslint src/*.ts",
35
- "test": "npm run gentypes && npm run prod:cjs && ava",
36
- "test:report": "nyc npm test && nyc report --reporter=text-lcov > coverage.lcov && codecov",
37
- "test:lazy": "ava",
38
- "dts-fix": "node dts-fix.js",
39
- "gentypes": "dts-bundle-generator --no-check -o dist/bundle.d.ts src/index.ts && npm run dts-fix",
40
- "dev": "cross-env NODE_ENV=development BUILD=es rollup -c",
41
- "prod:cjs": "cross-env NODE_ENV=production BUILD=cjs rollup -c",
42
- "prod:es": "cross-env NODE_ENV=production BUILD=es rollup -c",
43
- "prod": "npm run gentypes && npm run prod:es && npm run prod:cjs",
44
- "all": "npm run dev && npm run prod"
45
- },
46
- "version": "1.0.0-beta.1",
47
- "ava": {
48
- "files": [
49
- "./test/specs/*.ts"
50
- ],
51
- "failFast": true,
52
- "timeout": "2m",
53
- "extensions": [
54
- "ts"
55
- ],
56
- "require": [
57
- "ts-node/register"
58
- ]
59
- },
60
- "devDependencies": {
61
- "@rollup/plugin-commonjs": "^23.0.3",
62
- "@rollup/plugin-node-resolve": "^15.0.1",
63
- "@rollup/plugin-replace": "^5.0.1",
64
- "@rollup/plugin-terser": "^0.1.0",
65
- "@types/node": "^18.11.11",
66
- "ava": "^5.1.0",
67
- "codecov": "^3.8.2",
68
- "cross-env": "^7.0.3",
69
- "dts-bundle-generator": "^7.1.0",
70
- "nyc": "^15.1.0",
71
- "prepend": "^1.0.2",
72
- "rollup": "^3.6.0",
73
- "rollup-plugin-typescript2": "^0.34.1",
74
- "ts-node": "^10.9.1",
75
- "tslint": "^6.1.0",
76
- "typescript": "^4.9.4"
77
- },
78
- "types": "./dist/bundle.d.ts",
79
- "sideEffects": false
80
- }
1
+ {
2
+ "author": {
3
+ "name": "Michael houd1ni Akiliev"
4
+ },
5
+ "bugs": {
6
+ "url": "https://github.com/houd1ni/pepka/issues"
7
+ },
8
+ "deprecated": false,
9
+ "description": "An ultra lightweight, async or unsafe-speedy ramda alternative.",
10
+ "homepage": "https://houd1ni.github.io/pepka/",
11
+ "keywords": [
12
+ "ramda",
13
+ "functional",
14
+ "fp",
15
+ "pure",
16
+ "strongly-typed",
17
+ "typescript",
18
+ "d.ts"
19
+ ],
20
+ "license": "MIT",
21
+ "type": "module",
22
+ "exports": {
23
+ ".": {
24
+ "import": "./dist/bundle.mjs",
25
+ "require": "./dist/bundle.cjs"
26
+ }
27
+ },
28
+ "name": "pepka",
29
+ "repository": {
30
+ "type": "git",
31
+ "url": "git+https://github.com/houd1ni/pepka.git"
32
+ },
33
+ "scripts": {
34
+ "lint": "tslint src/*.ts",
35
+ "test": "npm run gentypes && npm run prod:es && ava",
36
+ "test:report": "nyc npm test && nyc report --reporter=text-lcov > coverage.lcov && codecov",
37
+ "test:lazy": "ava",
38
+ "dts-fix": "node dts-fix.js",
39
+ "gentypes": "dts-bundle-generator --no-check --export-referenced-types=false -o dist/bundle.d.ts src/index.ts && npm run dts-fix",
40
+ "dev": "cross-env NODE_ENV=development BUILD=es rollup -c",
41
+ "prod:cjs": "cross-env NODE_ENV=production BUILD=cjs rollup -c",
42
+ "prod:es": "cross-env NODE_ENV=production BUILD=es rollup -c",
43
+ "prod": "npm run gentypes && npm run prod:es && npm run prod:cjs",
44
+ "all": "npm run dev && npm run prod"
45
+ },
46
+ "version": "1.0.0-beta.10",
47
+ "ava": {
48
+ "files": [
49
+ "./test/specs/*.ts"
50
+ ],
51
+ "failFast": true,
52
+ "timeout": "2m",
53
+ "extensions": [
54
+ "ts"
55
+ ],
56
+ "require": [
57
+ "ts-node/register"
58
+ ]
59
+ },
60
+ "devDependencies": {
61
+ "@rollup/plugin-commonjs": "^24.0.1",
62
+ "@rollup/plugin-node-resolve": "^15.0.2",
63
+ "@rollup/plugin-replace": "^5.0.2",
64
+ "@rollup/plugin-terser": "^0.4.0",
65
+ "@types/node": "^18.15.11",
66
+ "ava": "^5.2.0",
67
+ "codecov": "^3.8.3",
68
+ "cross-env": "^7.0.3",
69
+ "dts-bundle-generator": "^8.0.0",
70
+ "nyc": "^15.1.0",
71
+ "prepend": "^1.0.2",
72
+ "rollup": "^3.20.2",
73
+ "rollup-plugin-typescript2": "^0.34.1",
74
+ "ts-node": "^10.9.1",
75
+ "tslint": "^6.1.3",
76
+ "typescript": "^5.0.4"
77
+ },
78
+ "types": "./dist/bundle.d.ts",
79
+ "sideEffects": false
80
+ }
package/src/curry.ts CHANGED
@@ -43,7 +43,6 @@ const _curry = (fn: Function, args: AnyArgs, new_args: AnyArgs) => {
43
43
  return curried
44
44
  }
45
45
  }
46
-
47
46
  export const curry = (fn: AnyFunc) => (
48
47
  (...args: AnyArgs) => fn.length>countArgs(args)
49
48
  ? _curry(fn, [], args)
package/src/index.ts CHANGED
@@ -4,4 +4,5 @@ export * from './uncurry'
4
4
  export * from './common'
5
5
  export * from './safe'
6
6
  export * from './quick'
7
- export * from './strings'
7
+ export * from './strings'
8
+ export * from './types'
package/src/quick.ts CHANGED
@@ -1,9 +1,9 @@
1
1
  import { curry2, curry3 } from "./curry"
2
2
  import { type } from "./common"
3
3
  import { AnyObject, Reducer, AnyFunc } from "./types"
4
- import { isFunc, isArray } from "./utils"
5
-
6
- // TODO: qmap, qoverProp, qover array ?
4
+ import { isFunc, isArray, isObj } from "./utils"
5
+ import { isNil } from "./safe"
6
+ // TODO: qoverProp, qover array ?
7
7
 
8
8
  export const qappend = curry2((s: any, xs: any[]) => {xs.push(s); return xs})
9
9
  export const qassoc = curry3(
@@ -13,32 +13,25 @@ export const qassoc = curry3(
13
13
  }
14
14
  )
15
15
  export const qreduce = curry3(
16
- <T>(fn: Reducer, accum: any, arr: T[]) =>
17
- arr.reduce(fn, accum)
16
+ <T>(fn: Reducer, accum: any, arr: T[]) => arr.reduce(fn, accum)
18
17
  )
19
18
  // strategy is for arrays: 1->clean, 2->merge, 3->push.
20
19
  const mergeDeep = curry3((strategy: 1|2|3, o1: AnyObject, o2: AnyObject): AnyObject => {
21
20
  for(let k in o2) {
22
21
  switch(type(o2[k])) {
23
22
  case 'Array':
24
- if(strategy>1 && type(o1[k])==='Array') {
23
+ if(strategy>1 && type(o1[k])==='Array')
25
24
  switch(strategy) {
26
25
  case 2:
27
26
  const o1k = o1[k], o2k = o2[k]
28
- for(const i in o2k) {
29
- if(o1k[i]) {
30
- mergeDeep(strategy, o1k[i], o2k[i])
31
- } else {
32
- o1k[i] = o2k[i]
33
- }
34
- }
27
+ for(const i in o2k)
28
+ if(o1k[i]) mergeDeep(strategy, o1k[i], o2k[i])
29
+ else o1k[i] = o2k[i]
35
30
  break
36
31
  case 3: o1[k].push(...o2[k])
37
32
  default: break
38
33
  }
39
- } else {
40
- o1[k] = o2[k]
41
- }
34
+ else o1[k] = o2[k]
42
35
  break
43
36
  case 'Object':
44
37
  if(type(o1[k])==='Object') {
@@ -55,22 +48,21 @@ const mergeDeep = curry3((strategy: 1|2|3, o1: AnyObject, o2: AnyObject): AnyObj
55
48
  export const qmergeDeep = mergeDeep(1)
56
49
  export const qmergeDeepX = mergeDeep(2)
57
50
  export const qmergeDeepAdd = mergeDeep(3)
51
+ export const qmergeShallow = curry2((o1: AnyObject, o2: AnyObject) => Object.assign(o1, o2))
58
52
  /** qmapKeys({ a: 'b' }, { a: 44 }) -> { b: 44 } */
59
53
  export const qmapKeys = curry2(
60
54
  (
61
- keyMap: {[oldKey: string]: string},
55
+ keyMap: {[oldKey: string]: string | AnyFunc},
62
56
  o: AnyObject
63
57
  ) => {
64
58
  let k: string, mapped: string | AnyFunc, newKey: string, newValue: any
65
- for(k in keyMap) {
59
+ for(k in keyMap) if(k in o) {
66
60
  mapped = keyMap[k]
67
61
  ;[newKey, newValue] = isFunc(mapped)
68
- ? (mapped as unknown as AnyFunc)(o)
62
+ ? (mapped as AnyFunc)(o[k], k, o)
69
63
  : [mapped, o[k]]
70
- o[newKey] = newValue
71
- if(k !== newKey) {
72
- delete o[k]
73
- }
64
+ o[isNil(newKey) ? k : newKey] = newValue
65
+ if(k !== newKey) delete o[k]
74
66
  }
75
67
  return o
76
68
  }
@@ -82,25 +74,47 @@ export const qmap = curry2(
82
74
  }
83
75
  )
84
76
  export const qfilter = curry2(
85
- (
77
+ <T extends any[] | AnyObject>(
86
78
  cond: (v: any, k: string | number) => boolean,
87
- data: any[] | AnyObject
88
- ) => {
79
+ data: T
80
+ ): T => {
89
81
  const isArr = isArray(data)
90
- for(let k in data) {
91
- if(!cond(data[k], k)) {
92
- if(isArr) {
93
- data.splice(k, 1)
94
- } else {
95
- // TODO: handle Maps and Sets ?
96
- delete data[k]
97
- }
98
- }
82
+ let indicies_offset: number, indicies2rm: number[]
83
+ if(isArr) {
84
+ indicies_offset = 0
85
+ indicies2rm = []
99
86
  }
87
+ for(let k in data)
88
+ if(!cond(data[k], k)) // @ts-ignore
89
+ if(isArr) indicies2rm.push(+k)
90
+ else delete data[k]
91
+ if(isArr)// @ts-ignore
92
+ for(const i of indicies2rm) // @ts-ignore
93
+ data.splice(i - indicies_offset++, 1)
100
94
  return data
101
95
  }
102
96
  )
103
- /** @deprecated */
104
- export const qindexOf = curry2(
105
- (x: any, xs: any[]) => xs.indexOf(x)
106
- )
97
+ export const qempty = (o: AnyObject|any[]) => {
98
+ if(isArray(o)) o.splice(0)
99
+ else for(const i in o) delete o[i]
100
+ return o
101
+ }
102
+ export const qfreeze = <T extends AnyObject>(o: T): Readonly<T> => {
103
+ let v: any
104
+ for(const k in o) {
105
+ v = o[k]
106
+ if(isObj(v)) qfreeze(v)
107
+ }
108
+ return Object.freeze(o)
109
+ }
110
+ export const qfreezeShallow = <T extends AnyObject>(o: T): Readonly<T> => Object.freeze(o)
111
+ export const qprepend = curry2((x: any, xs: any[]) => xs.unshift(x))
112
+ export const qassocPath = curry3((_path: string[], v: any, o: AnyObject) => {
113
+ const first = _path[0]
114
+ return qassoc(first, _path.length<2
115
+ ? v
116
+ : qassocPath(_path.slice(1), v, isObj(o[first]) ? o[first] : {}),
117
+ o
118
+ )
119
+ })
120
+ export const qreverse = (arr: any[]) => arr.reverse()
package/src/safe.ts CHANGED
@@ -1,33 +1,27 @@
1
1
  import { __, curry, curry2, curry3 } from './curry'
2
2
  import { isNum, isUndef, undef, isNull, isArray, isFunc, isStr, isObj, inf } from './utils'
3
- import { qmergeDeep, qreduce, qappend, qmapKeys, qmergeDeepX, qmergeDeepAdd } from './quick'
3
+ import { qmergeDeep, qreduce, qappend, qmapKeys, qmergeDeepX, qmergeDeepAdd, qfilter, qfreeze, qfreezeShallow } from './quick'
4
4
  import { AnyFunc, Cond, AnyObject, Reducer } from './types'
5
5
  import { type } from './common'
6
6
  // over, lensProp
7
7
 
8
8
  export const take = (argN: number) => (...args: any[]) => args[argN]
9
+ export const eq = curry2((a: any, b: any) => a===b)
10
+ export const weakEq = curry2((a: any, b: any) => a==b)
9
11
  export const equals = curry2((a: any, b: any) => {
10
12
  const typea = type(a)
11
- if(typea===type(b) && (typea==='Object' || typea=='Array')) {
12
- if(isNull(a) || isNull(b)) {
13
- return a===b
14
- }
15
- if(a===b) {
16
- return true
17
- }
18
- for(const v of [a, b]) {
19
- for(const k in v) {
13
+ if(eq(typea, type(b)) && (eq(typea, 'Object') || eq(typea, 'Array'))) {
14
+ if(isNull(a) || isNull(b)) return eq(a, b)
15
+ if(eq(a, b)) return true
16
+ for(const v of [a, b])
17
+ for(const k in v)
20
18
  if(
21
- !((v===b) && (k in a)) &&
22
- !((v===a) && (k in b) && equals(a[k], b[k]))
23
- ) {
24
- return false
25
- }
26
- }
27
- }
19
+ !((eq(v, b)) && (k in a)) &&
20
+ !((eq(v, a)) && (k in b) && equals(a[k], b[k]))
21
+ ) return false
28
22
  return true
29
23
  }
30
- return a===b
24
+ return eq(a, b)
31
25
  })
32
26
  export const ifElse = curry(
33
27
  (
@@ -60,14 +54,10 @@ export const compose = (
60
54
  return s as any as TOut
61
55
  }
62
56
  )
63
-
64
57
  export const bind = curry2<AnyFunc>(
65
58
  (fn: AnyFunc, context: any) => fn.bind(context)
66
59
  )
67
-
68
- const _nth = <T=any>(i: number, data: T[] | string) => data[i]
69
- export const nth = curry2(_nth)
70
-
60
+ export const nth = curry2(<T=any>(i: number, data: T[] | string) => data[i])
71
61
  export const includes = curry2(
72
62
  <T>(s: T, ss: T[]) => {
73
63
  if(isStr(ss)) return ss.includes(s)
@@ -81,15 +71,22 @@ export const slice = curry3(
81
71
  (from: number, to: number, o: any[] | string) =>
82
72
  o.slice(from, (isNum(to)?to:inf) as number)
83
73
  )
84
- export const flip =
85
- <T extends AnyFunc>(fn: T) => curry2(
86
- (b: Parameters<T>[1], a: Parameters<T>[0]) => fn(a, b)
87
- )
74
+ export const flip = <T extends AnyFunc>(fn: T) => curry2(
75
+ (b: Parameters<T>[1], a: Parameters<T>[0]) => fn(a, b)
76
+ )
88
77
  export const head = nth(0) as <T = any>(xs: T[] | string) => T
89
- export const tail = slice(1, inf) // typeshit.
78
+ export const tail = slice(1, inf)
90
79
  export const add = curry2((n: number, m: number) => n+m)
91
80
  export const subtract = curry2((n: number, m: number) => m-n)
92
81
  export const multiply = curry2((n: number, m: number) => n*m)
82
+ export const gt = curry2( (a: number, b: number) => a>b )
83
+ export const lt = curry2( (a: number, b: number) => a<b )
84
+ export const gte = curry2( (a: number, b: number) => b>=a )
85
+ export const lte = curry2( (a: number, b: number) => b<=a )
86
+ export const sort = curry2((sortFn: any, xs: any[]) => xs.sort(sortFn))
87
+ export const find = curry2((fn: Cond, s: any[]) => s.find(fn))
88
+ export const findIndex = curry2((fn: Cond, s: any[]) => s.findIndex(fn))
89
+ export const indexOf = curry2((x: any, xs: any[]) => findIndex(equals(x), xs))
93
90
  export const divide = curry2((n: number, m: number) => n/m)
94
91
  export const isNil = (s: any) => isNull(s) || isUndef(s)
95
92
  export const length = (s: any[] | string) => s.length
@@ -97,23 +94,44 @@ export const always = <T=any>(s: T) => () => s
97
94
  export const identity = (s: any) => s
98
95
  export const trim = (s: string) => s.trim()
99
96
  export const last = (s: any[] | string) => s[length(s)-1]
100
- export const not = (o: boolean) => !o
101
- export const complement = (fn: AnyFunc) => (...args: any) => {
102
- const out = fn(...args)
103
- const f = isFunc(out)
104
- return !f || f&&out.$args_left<=0 ? not(out) : complement(out)
97
+ type NotOverload = {
98
+ (x: true): false
99
+ (x: false): true
100
+ (x: any): boolean
105
101
  }
106
- export const keys = (o: AnyObject | any[]) => Object.keys(o)
102
+ export const not: NotOverload = (x: any) => !x as any
103
+ type IndexesOfArray<A> = Exclude<keyof A, keyof []>
104
+ type KeysOverload = {
105
+ <T extends any[]>(o: T): string[]
106
+ <T extends readonly any[]>(o: T): IndexesOfArray<T>[]
107
+ <T extends AnyObject>(o: T): (keyof T)[]
108
+ }
109
+ export const keys: KeysOverload = (o: number[]) => Object.keys(o)
110
+
107
111
  export const values = (o: AnyObject | any[]) => Object.values(o)
108
112
  export const toPairs = (o: AnyObject | any[]) => Object.entries(o)
109
113
  export const test = curry2((re: RegExp, s: string) => re.test(s))
110
- export const tap = curry2((fn: Function, s: any) => { fn(s); return s })
111
- export const append = curry2((s: any, xs: any[]) => [...xs, s])
114
+ export const tap = curry2((fn: Function, x: any) => { fn(x); return x })
115
+ export const append = curry2((x: any, xs: any[]) => [...xs, x])
116
+ export const prepend = curry2((x: any, xs: any[]) => [...xs, x])
117
+ export const flat = (xs: any[]) => xs.flat(inf)
118
+ export const flatShallow = (xs: any[]) => xs.flat()
119
+ export const flatTo = curry2((depth: number, xs: any[]) => xs.flat(depth))
112
120
  export const split = curry2((s: string|RegExp, xs: string) => xs.split(s))
113
121
  export const T = always<true>(true) as (...args: any[]) => true
114
122
  export const F = always<false>(false) as (...args: any[]) => false
115
123
  export const callWith = curry2((args: any[], fn: AnyFunc) => fn(...args))
116
- export const noop = (..._args: any[]) => {}
124
+ export const noop = (()=>{}) as (...args: any[]) => any
125
+ /** Calls a func from object.
126
+ * @param {any[]} [args] - arguments for the function.
127
+ * @param {string} [fnName] - property name of the function.
128
+ * @param {AnyObject} [o] - the object with the function. */
129
+ export const callFrom = curry((args: any[], fn: string, o: AnyObject) => o[fn](...args))
130
+ export const complement = (fn: AnyFunc) => (...args: any) => {
131
+ const out = fn(...args)
132
+ const f = isFunc(out)
133
+ return !f || f&&out.$args_left<=0 ? not(out) : complement(out)
134
+ }
117
135
  export const sizeof = (s: any[] | string | AnyObject) => {
118
136
  if(type(s) === 'Object') {
119
137
  let len = 0
@@ -124,6 +142,7 @@ export const sizeof = (s: any[] | string | AnyObject) => {
124
142
  export const range = curry2((from: number, to: number) =>
125
143
  genBy(add(from), to-from)
126
144
  )
145
+ // TODO: make it using equals for deep stuff !
127
146
  export const uniq = (xs: any[]) => qreduce(
128
147
  <T>(accum: any, x: T) =>
129
148
  includes(x, accum) ? accum : qappend(x, accum),
@@ -140,12 +159,9 @@ export const genBy = curry2(
140
159
  export const once = <Func extends AnyFunc>(fn: Func) => {
141
160
  let done = false, cache: any
142
161
  return (...args: Parameters<Func>) => {
143
- if(done) {
144
- return cache
145
- } else {
146
- done = true
147
- return cache = fn(...args)
148
- }
162
+ if(done) return cache
163
+ done = true
164
+ return cache = fn(...args)
149
165
  }
150
166
  }
151
167
  export const reverse = (xs: any[]) => compose(
@@ -156,14 +172,6 @@ export const reverse = (xs: any[]) => compose(
156
172
  add(-1),
157
173
  length
158
174
  )(xs)
159
- export const gt = curry2( (a: number, b: number) => a>b )
160
- export const lt = curry2( (a: number, b: number) => a<b )
161
- export const gte = curry2( (a: number, b: number) => b>=a )
162
- export const lte = curry2( (a: number, b: number) => b<=a )
163
- export const sort = curry2((sortFn: any, xs: any[]) => xs.sort(sortFn))
164
- export const find = curry2((fn: Cond, s: any[]) => s.find(fn))
165
- export const findIndex = curry2((fn: Cond, s: any[]) => s.findIndex(fn))
166
- export const indexOf = curry2((x: any, xs: any[]) => findIndex(equals(x), xs))
167
175
  export const explore = (caption: string, level = 'log') => tap(
168
176
  (v: any) => console[level](caption, v)
169
177
  )
@@ -247,9 +255,7 @@ export const clone = (s: any, shallow = false) => {
247
255
  case 'Object':
248
256
  if(shallow) return {...s}
249
257
  const out = {}
250
- for(let k in s) {
251
- out[k] = clone(s[k])
252
- }
258
+ for(let k in s) out[k] = clone(s[k])
253
259
  return out
254
260
  case 'String': case 'Number':
255
261
  case 'Boolean': case 'Symbol':
@@ -259,6 +265,8 @@ export const clone = (s: any, shallow = false) => {
259
265
  }
260
266
  }
261
267
  export const cloneShallow = (s: any) => clone(s, true)
268
+ export const freeze = <T extends AnyObject>(o: T): Readonly<T> => qfreeze(clone(o))
269
+ export const freezeShallow = <T extends AnyObject>(o: T): Readonly<T> => qfreezeShallow(clone(o))
262
270
 
263
271
  /** types T1, T2
264
272
  * @param reducer (accum: T1, current: T2, index: number) => newAccum: T1
@@ -275,11 +283,8 @@ export const pickBy = curry2(
275
283
  export const pick = curry2(
276
284
  (props: string[], o: AnyObject) => {
277
285
  const out = {}
278
- for(const p of props) {
279
- if(p in o) {
280
- out[p] = o[p]
281
- }
282
- }
286
+ for(const p of props)
287
+ if(p in o) out[p] = o[p]
283
288
  return out
284
289
  }
285
290
  )
@@ -289,10 +294,7 @@ export const omit = curry2(
289
294
  o
290
295
  )
291
296
  )
292
- export const fromPairs = (pairs: [string, any][]) => reduce(
293
- (o: AnyObject, pair: [string, any]) => assoc(...pair, o),
294
- {}, pairs
295
- )
297
+ export const fromPairs = (pairs: [string, any][]) => Object.fromEntries(pairs)
296
298
  type Concat = ((a: string, b: string) => string)
297
299
  | ((a: any[], b: any[]) => any[])
298
300
  export const concat = curry2(
@@ -332,20 +334,17 @@ export const replace = curry3(
332
334
  a: string | RegExp,
333
335
  b: string | ((substring: string, ...ps: any[]) => string),
334
336
  where: string
335
- // @ts-ignore-next Some bug with overload.
337
+ // @ts-ignore Some bug with overload.
336
338
  ) => where.replace(a, b)
337
339
  )
340
+ // FIXME: it thinks cond is a symbol in usage !!!
338
341
  export const filter = curry2(
339
342
  (
340
343
  cond: (v: any, k: string | number) => boolean,
341
344
  data: any[] | AnyObject
342
345
  ) => isArray(data)
343
346
  ? data.filter(cond)
344
- : compose(
345
- fromPairs,
346
- filter(([k, v]) => cond(v, k)),
347
- toPairs
348
- )(data)
347
+ : qfilter(cond, {...data})
349
348
  )
350
349
  export const memoize = (fn: Function) => {
351
350
  let cache: any
@@ -372,7 +371,7 @@ export const overProp = curry3(
372
371
  /** mapKeys({ a: 'b' }, { a: 44 }) -> { b: 44 } */
373
372
  export const mapKeys = curry2(
374
373
  (
375
- keyMap: {[oldKey: string]: string},
374
+ keyMap: {[oldKey: string]: string | AnyFunc},
376
375
  o: AnyObject
377
376
  ) => qmapKeys(keyMap, Object.assign({}, o))
378
377
  )
@@ -411,7 +410,12 @@ export const forEachSerial = (() => {
411
410
  })()
412
411
  /** Promise.all wrapper for functional pipelining. */
413
412
  export const waitAll = (promises: Promise<any>[]) => Promise.all(promises)
414
- export const waitTap = curry2(async (fn: Function, s: any) => { await fn(s); return s })
413
+ /** Waits for a Promise that been generated by the first arg, then returns an untoched value. Types T.
414
+ * @param {AnyFunc<Promise>} fn - function to wait.
415
+ * @param {T} s - any value to tap and return back
416
+ * @returns {T}
417
+ */
418
+ export const waitTap = curry2(async (fn: AnyFunc, s: any) => { await fn(s); return s })
415
419
  /** Waits for all promises mapped by the fn. */
416
420
  export const forEachAsync = curry2(
417
421
  (fn: (item: any) => Promise<any>, items: any[]) =>
@@ -419,15 +423,16 @@ export const forEachAsync = curry2(
419
423
  )
420
424
  /** The same as compose, but waits for promises in chains and returns a Promise. */
421
425
  export const composeAsync = (() => {
422
- const pipe = async (fns: AnyFunc[], data: any, i: number): Promise<any> =>
423
- ~i ? await pipe(fns, await fns[i](data), --i) : data
426
+ const pipe = async (fns: AnyFunc[], input: any[], i: number): Promise<any> =>
427
+ ~i ? await pipe(fns, [await fns[i](...input)], --i) : head(input)
424
428
  return <T = any>(...fns: AnyFunc[]) =>
425
- (data?: any) => pipe(fns, data, fns.length-1) as Promise<T>
426
- })()// as FT.Compose<'async'>
429
+ (...input: any[]) => pipe(fns, input, fns.length-1) as Promise<T>
430
+ })()
427
431
 
428
432
  // ALIASES
429
433
  export const mirror = identity
430
434
  export const reflect = identity
431
435
  export const echo = identity
432
436
  export const notf = complement
433
- export const push = append
437
+ export const push = append
438
+ export const some = any
package/src/timers.ts ADDED
@@ -0,0 +1,18 @@
1
+ import { AnyFunc } from "./types"
2
+
3
+ export const debounce = <T extends AnyFunc>(time: number, fn: T) => {
4
+ let queue: AnyFunc[] = []
5
+ let to: NodeJS.Timeout
6
+ return ((...args: Parameters<T>) => new Promise<ReturnType<T>>((ff) => {
7
+ const qel = async () => {
8
+ clearTimeout(to)
9
+ to = setTimeout(async () => {
10
+ const res = await fn!(...args)
11
+ if(queue.includes(qel)) ff(res)
12
+ }, time)
13
+ }
14
+ queue.splice(0)
15
+ queue.push(qel)
16
+ qel()
17
+ }))
18
+ }
package/src/types.ts CHANGED
@@ -1,15 +1,10 @@
1
- export type Cond = (...xs: any[]) => boolean
2
- export interface AnyObject {
3
- [k: string]: any
4
- }
1
+ export type Cond = (x1?: any, x2?: any, x3?: any) => boolean
2
+ export interface AnyObject { [k: string]: any }
5
3
  export type AnyArgs = any[]
4
+ export type Reducer<T=any> = (accum: T, cur: any, index: number) => T
5
+ export type AnyFunc<ReturnT = any, Args extends AnyArgs = AnyArgs> = (...args: Args) => ReturnT
6
+ export type TupleFn<ARG1=any, ARG2=any, Out=any> = (a: ARG1, b: ARG2) => Out
6
7
  export type Curried<
7
8
  Args extends AnyArgs = AnyArgs,
8
9
  ReturnT = any
9
- > = (arg: Args[number]) => Curried<Args> | ReturnT
10
- export type Reducer<T=any> = (accum: T, cur: any, index: number) => T
11
- export type AnyFunc<
12
- ReturnT = any,
13
- Args extends AnyArgs = AnyArgs
14
- > = (...args: Args) => ReturnT
15
- export type TupleFn<ARG1=any, ARG2=any, Out=any> = (a: ARG1, b: ARG2) => Out
10
+ > = (arg: Args[number]) => Curried<Args> | ReturnT