partial.lenses
Advanced tools
Comparing version 14.7.0 to 14.8.0
@@ -1,1 +0,1 @@ | ||
!function(n,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports,require("infestines")):"function"==typeof define&&define.amd?define(["exports","infestines"],r):r(n.L={},n.I)}(this,function(n,b){"use strict";function r(n){switch(typeof n){case"boolean":case"number":case"string":return!0;default:return!1}}function e(n,r){for(var t=0,u=r.length;t<u;++t){var e=n(r[t],t);if(void 0!==e)return e}}function i(n){if(!this)return J(new i(n));this.map=n}function o(n,r,t,u){var e=n.map,i=n.ap,o=n.of(yn),c=t.length;if(e===b.sndU){for(var f=0;f<c;++f)o=i(o,r(t[f],f));return o}for(var a=yn(u),v=0;v<c;++v)o=i(e(a,o),r(t[v],v));return e(gn,o)}function a(n,r){var t=r.length-n;if(t<2)return t?gr(r[n]):Tn;for(var e=gr(r[n+--t]),i=function(t,u){return function(n,r){return e(n,r,t,u)}};--t;)i=Sn(gr(r[n+t]),i);var o=gr(r[n]);return function(n,r,t,u){return o(n,r,t,i(t,u))}}function u(n,r,t,u){for(var e,i,o=n.length,c=Array(o),f=0;f<o;++f)switch(c[f]=t,typeof(e=n[f])){case"string":t=An(e,t);break;case"number":t=On(e,t);break;default:t=a(f,n)(t,n[f-1],hr,r||b.always(u)),o=f}for(o===n.length&&(t=r?r(t,n[o-1]):u);0<=--o;)t=b.isString(i=n[o])?jn(i,t,c[o]):wn(i,t,c[o]);return t}function t(n,r,t,u){return dr(n)?cr(n,0,t,u):t.of(n)}function c(n,r,t,u){return b.isArray(n)?cr(n,0,t,u):b.isObject(n)?Hr(n,r,t,u):t.of(n)}function f(n,r,u,e){return function n(r,t){return b.isArray(r)?cr(r,0,u,n):void 0!==r?e(r,t):u.of(r)}(n,r)}function v(r,n){return 1<arguments.length?Mn(E,r,n):function(n){return Mn(E,r,n)}}function s(r,n,t,u){var e=dr(r)?r.length:0;return t.map(function(n){return wn(e,n,r)},u(void 0,e))}function l(o){var c=1<arguments.length?arguments[1]:{hint:0};return function(n,r,t,u){var e=dr(n)?n:"",i=c.hint=function(n,r,t){var u=n.hint,e=t.length;e<=u&&(u=e-1),u<0&&(u=0);for(var i=u-1;0<=i&&u<e;++u,--i){if(r(t[u],u,n))return u;if(r(t[i],i,n))return i}for(;u<e;++u)if(r(t[u],u,n))return u;for(;0<=i;--i)if(r(t[i],i,n))return i;return e}(c,o,e);return t.map(function(n){return wn(i,n,e)},u(e[i],i))}}function d(){for(var n,r=arguments.length,t={},u=0;u<r;++u)t[n=arguments[u]]=n;return Ht(t)}function h(r,n){return 1<arguments.length?kn(r,n,void 0):function(n){return kn(r,n,void 0)}}var y=function(n,r){return n+r},p=function(n,r){return n*r},g=b.curry(y),m=b.curry(p),A=b.curry(function(n,r){return r/n}),j=function(n){return-n},x=function(n,r){return n<r},O=function(n,r){return r<n},w=b.curry(function(n,r){return r instanceof n}),I=Object.create,S=function(n){return b.assign(I(null),n)},U=b.freeze(S(b.object0)),k=b.curry(function(n,r,t){return t.replace(n,r)}),E=function(n){return n},F=function(n){return n},M=function(n){return n},q=function(n,r){return b.isString(n)?new RegExp(k(/[|\\{}()[\]^$+*?.]/g,"\\$&",n),r):n},N=function(r){return M(function(n){try{return r(n)}catch(n){return n}})},R=function(n,r){return null!=r&&b.isFunction(r.then)?r.then(n):n(r)},P=function(n){return void 0!==n?String(n):""},z=function(n,r,t,u){return void 0!==u?Math.min(Math.max(n,u<0?r+u:u),r):t},C=function(r){return function(n){return[n,r]}},D=function(r){return function(n){return void 0!==n?n:r}},L=D(0),T=b.always(!0),W=function(n){return void 0!==n?!n:n},$=function(n){return void 0!==n?[n]:n},B=function(r,t){return M(function(n){return r(n)?t(n):void 0})},J=E,_=function(n){return!(n instanceof Object)||b.isArray(n)},G=E(function(n){if(dr(n)){for(var r=n.length,t=Array(r),u=0;r;)t[u++]=n[--r];return t}}),H=E(function(n,r,t){for(var u=r.length,e=Array(u),i=0,o=!0,c=0;c<u;++c){var f=r[c],a=n(f,c);t!==a&&(e[i++]=a,o&&(o=f===a&&(0!==f||1/f==1/a)||f!=f&&a!=a))}return i!==u?(e.length=i,e):o?r:e}),K=function(n,r){return dr(r)?H(n,r,void 0):void 0},Q=E(function(n,r,t,u,e){for(;u<e;)n[r++]=t[u++];return n}),V=b.inherit(function n(r,t,u){if(!this)return J(new n(r,t,u));i.call(this,r),this.of=t,this.ap=u},i),X=b.inherit(function n(r,t,u,e){if(!this)return J(new n(r,t,u,e));V.call(this,r,t,u),this.chain=e},V),Y="fantasy-land/",Z=Y+"of",nn=Y+"chain",rn=function(t){return F(function(n,r){return r[t](n)})},tn=rn("fantasy-land/map"),un=rn("fantasy-land/ap"),en=rn(nn),on=i(tn),cn=function(n){return V(tn,n[Z],un)},fn=function(n){return X(tn,n[Z],un,en)},an=function(n,r){return V(b.sndU,b.always(r),n)},vn=function(n){return an(n.concat,(0,n.empty)())},sn=an(y,0),ln=function(o){return b.curry(function(u,n,r){var e=void 0,i=void 0;return Mn(function(n,r){var t=u(n,r);void 0===t||void 0!==i&&!o(t,i)||(e=n,i=t)},n,r),e})},dn=function(n,r,t,u){return gr(t)(u,void 0,n,r)},hn=function(e,n){return b.curryN(4,M(function(t,u){return u=n(u),function(n,r){return e(dn(u,t,n,r))}}))},yn=function(t){return function(r){return function(n){return t!==n?[n,r]:r}}},pn=function(n,r){for(;yn!==n;)r.push(n[0]),n=n[1];return r},gn=E(function(n){return pn(n,[]).reverse()}),mn=V(function(n,r){var t=r.p,u=r.x,e=r.c;return u=n(u),b.isFunction(u)||(t=[u,t]),{p:t,x:u,c:e}},function(n){return{p:[],x:n,c:void 0}},function(n,r){var t=void 0!==n.c?n:r;return{p:t.p,x:n.x(r.x),c:t.c}}),bn=function(i,o){return function(e){return function(r,n,t,u){return t.map(function(n){return o(e,n,r)},u(i(e,r),e))}}},An=function(n,r){return r instanceof Object?r[n]:void 0},jn=E(function(n,r,t){return void 0!==r?b.assocPartialU(n,r,t):b.dissocPartialU(n,t)||b.object0}),xn=bn(An,jn),On=function(n,r){return dr(r)?r[n]:void 0},wn=E(function(n,r,t){dr(t)||(t="");var u=t.length;if(void 0!==r){for(var e=Math.max(n+1,u),i=Array(e),o=0;o<e;++o)i[o]=t[o];return i[n]=r,i}if(u<=n)return Q(Array(u),0,t,0,u);for(var c=Array(u-1),f=0;f<n;++f)c[f]=t[f];for(var a=n+1;a<u;++a)c[a-1]=t[a];return c}),In=bn(On,wn),Sn=function(e,n){return function(t,u){return u=n(t,u),function(n,r){return e(n,r,t,u)}}},Un=function(n,r,t){dr(r)||(r="");var u=0;return En(n,function(){return r[u++]},t)},kn=E(function(n,r,t){switch(typeof n){case"string":return jn(n,r,t);case"number":return wn(n,r,t);case"object":return u(n,0,t,r);default:return 4===n.length?n(t,void 0,hr,b.always(r)):t}}),En=E(function(n,r,t){switch(typeof n){case"string":return jn(n,r(An(n,t),n),t);case"number":return wn(n,r(On(n,t),n),t);case"object":return u(n,r,t);default:return 4===n.length?n(t,void 0,hr,r):(r(n(t,void 0),void 0),t)}}),Fn=function(n,r,t){return u=gr(n)(t,void 0,yr,r),Promise.resolve(u);var u},Mn=E(function(n,r,t){switch(typeof r){case"string":return n(An(r,t),r);case"number":return n(On(r,t),r);case"object":for(var u,e=r.length,i=0;i<e;++i)switch(typeof(u=r[i])){case"string":t=An(u,t);break;case"number":t=On(u,t);break;default:return a(i,r)(t,r[i-1],pr,n)}return n(t,r[e-1]);default:return n!==E&&4!==r.length?n(r(t,void 0),void 0):r(t,void 0,pr,n)}}),qn=function(n,r){return Mn(E,n,r)},Nn=function(e,i){return M(function(r,t,n,u){return n.map(function(n){return i(n,r,t)},u(e(r,t),t))})},Rn=function(e,i){return M(function(n,r,t,u){return t.map(i,u(e(n),r))})},Pn=function(n,r){return Rn(B(b.isString,n),B(b.isString,r))},zn=function(n,r){return Rn(B(b.isNumber,n),B(b.isNumber,r))},Cn=E(function(n,r){var t=void 0;for(var u in n){var e=n[u],i=b.isObject(e)?Cn(e,r):Mn(E,e,r);void 0!==i&&(t||(t={}),t[u]=i)}return t}),Dn=E(function(n,r,t){for(var u in n){var e=r&&r[u],i=n[u];t=b.isObject(i)?Dn(i,e,t):kn(i,e,t)}return t}),Ln=function(n){return b.constructorOf(n)!==Object?b.toObject(n):n},Tn=function(n,r,t,u){return u(n,r)},Wn=E(function(e){return function(n){for(var r={},t=e.length;t--;){var u=n[0];void 0!==u&&(r[e[t]]=u),n=n[1]}return r}}),$n=E(function(n,r,t,u,e,i){var o=void 0,c=!0,f={};for(var a in r){o=1;var v=t[a],s=r[a](v,a,e,i);void 0!==s?(f[a]=s,c&&(c=v===s&&(0!==v||1/v==1/s)||v!=v&&s!=s)):c=!1}var l=o;for(var d in t)if(void 0===(l&&r[d])){o=1;var h=t[d],y=n(h,d,e,i);void 0!==y?(f[d]=y,c&&(c=h===y&&(0!==h||1/h==1/y)||h!=h&&y!=y)):c=!1}return o?c&&t===u?u:f:u}),Bn=function(g,m){return function(n,r,t,u){var e=n instanceof Object?Ln(n):b.object0;if(hr===t)return $n(g,m,e,n,t,u);if(pr!==t){var i=t.map,o=t.ap,c=t.of,f=c(C),a=[];for(var v in m)a.push(v),f=o(i(C,f),m[v](e[v],v,t,u));var s=!!a.length||void 0;for(var l in e)void 0===(s&&m[l])&&(a.push(l),f=o(i(C,f),g(e[l],l,t,u)));return a.length?i(Wn(a),f):c(n)}for(var d in m){var h=m[d](e[d],d,t,u);if(void 0!==h)return h}for(var y in e)if(void 0===m[y]){var p=g(e[y],y,t,u);if(void 0!==p)return p}}},Jn=function(n,r,t){return b.acyclicEqualsU(t,n)?r:t},_n=E(function(n,r,t,u){for(var e,i=0,o=r.length;i<o;++i)(n(e=r[i],i)?t:u).push(e)}),Gn=function(n){return n[0]},Hn=function(n){return n.index},Kn=function(n){return Hn(n)+n[0].length},Qn=E(function(n,r){var t=r.lastIndex;r.lastIndex=Kn(n);var u=r.exec(n.input);return r.lastIndex=t,u&&u[0]&&u}),Vn=function(t){return function(r){return function(n){return[t,n,r]}}},Xn=Rn(B(w(Object),E(function(n){n=Ln(n);var r=[];for(var t in n)r.push([t,n[t]]);return r})),B(b.isArray,E(function(n){for(var r={},t=0,u=n.length;t<u;++t){var e=n[t];2===e.length&&(r[e[0]]=e[1])}return r}))),Yn=E(function(n,r){if(r instanceof Object){var t={};for(var u in r=Ln(r)){var e=n(u),i=t[e];void 0===i&&(t[e]=i={}),i[u]=r[u]}return t}}),Zn=E(function(i){return function(n){if(n instanceof Object){var r={};for(var t in n=Ln(n)){var u=n[t];if(u instanceof Object)for(var e in u=Ln(u))i(e)===t&&(r[e]=u[e])}return r}}}),nr=function(n,r,t){return void 0!==n(r,t,pr,E)},rr=function(t){return function(n,r){return nr(t,n,r)}},tr=function(i,o){return function(e){return function(n,r,t,u){return(e(n,r)?i:o)(n,r,t,u)}}},ur=function(e,i){return i=gr(i),e=gr(e),function(n,r,t,u){return(nr(i,n,r)?i:e)(n,r,t,u)}},er=function(i,o){o=gr(o),i=gr(i);var c=function(n){n=b.always(n);var r=o(void 0,void 0,hr,n);return void 0===r?i(void 0,void 0,hr,n):r};return function(n,r,t,u){var e=o(n,r,pr,E);return t.map(c,u(void 0===e?i(n,r,pr,E):e,r))}},ir=function(u){return M(function(n){for(var r=arguments.length,t=arguments[--r];r;)t=u(t,arguments[--r]);return t})},or=function(n,r,t,u){return t.of(n)},cr=function(n,r,t,u){return t===hr?H(u,n,void 0):t===pr?e(u,n):o(t,u,n,void 0)},fr=function(e,i){return function(n,r,t,u){return t.chain(function(n){return i(n,r,t,u)},e(n,r,t,u))}},ar=function(n,r){return[r,Jt(n)]},vr=function(t){return function(n){for(var r=n;void 0!==n;)n=t(r=n);return r}},sr=function(o,c,f){return function(n,r){var t=c.length;if(dr(n)){dr(r)||(r="");for(var u=Math.max(t,n.length,r.length),e=Array(u),i=0;i<u;++i)if(void 0===(e[i]=o(i<t?c[i]:f,n[i],r[i])))return;return e}}},lr=(0,b.curry)(function(n,r){return Nn(sr(qn,r,n),sr(kn,r,n))}),dr=function(n){return n instanceof Object&&(n=n.length)===n>>0&&0<=n||b.isString(n)},hr=X(b.applyU,E,b.applyU,b.applyU),yr=X(R,E,function(n,r){return R(function(r){return R(function(n){return n(r)},n)},r)},R),pr=an(function(n,r){return void 0!==n?n:r}),gr=E(function(n){switch(typeof n){case"string":return xn(n);case"number":return In(n);case"object":return a(0,n);default:return 4===n.length?n:(e=n,M(function(n,r,t,u){return t.map(b.always(n),u(e(n,r),r))}))}var e}),mr=b.curry(function(n,r,t){return kn([n,Gt(r)],r,t)}),br=b.curry(Un),Ar=b.curry(En),jr=b.curry(Fn),xr=b.curry(function(n,r){return kn(n,void 0,r)}),Or=b.curry(kn),wr=b.curry(dn),Ir=ir(ur),Sr=function(e){return M(function(n,r,t,u){return gr(e(n,r))(n,r,t,u)})},Ur=E(function(){for(var n=arguments.length,r=or;n--;){var t=arguments[n];r=t.length<2?gr(t[0]):tr(gr(t[1]),r)(t[0])}return r}),kr=E(function(i){i=gr(i);var o=arguments.length-1;if(!o)return or;var n=arguments[o];n=1===n.length?(--o,gr(n[0])):or;for(var c=Array(o),f=Array(o+1),r=0;r<o;++r){var t=arguments[r+1];c[r]=t[0],f[r]=gr(t[1])}return f[o]=n,function(n,r,t,u){var e=o;return i(n,r,pr,function(n,r){for(var t=0;t<e;++t)if(c[t](n,r)){if(0===(e=t))return 0;break}}),f[e](n,r,t,u)}}),Er=b.curry(function(n,r,t){return tr(gr(r),gr(t))(n)}),Fr=b.curry(ur),Mr=b.curry(function(t,n){return[n,Sr(function(n,r){return void 0!==n?t(n,r):or})]}),qr=tr(or,Tn),Nr=tr(Tn,or),Rr=Nr(b.isDefined),Pr=b.curry(function(e,i){return i=gr(i),M(function(n,t,r,u){return i(n,t,r,function(n,r){return u(n,e(r,t))})})}),zr=F(Pr(function(n,r){return void 0!==r?void 0!==n?[r,n]:r:n})),Cr=F(Pr(b.sndU)),Dr=b.curry(function(n,r){return En(n,E,r)}),Lr=b.curry(function(n,r){return Fn(n,E,r)}),Tr=E(function(){var n=arguments.length,r=or;if(n)for(r=gr(arguments[--n]);n;)r=fr(gr(arguments[--n]),r);return r}),Wr=function(e){return function(n,r,t,u){return t.of(e)}},$r=Wr(),Br=E(b.curryN(2,function(r){return r=gr(r),function(n){return function n(r,t){var u=I(null);for(var e in t){var i=t[e];u[e]=b.isObject(i)?n(r,i):gr(i)}return Bn(r,u)}(r,n)}})),Jr=Br(or),_r=F(gr([Xn,t])),Gr=F(gr([Xn,t,0])),Hr=F(Bn(Tn,U)),Kr=function(i){return function(n,r,u,e){return function n(r,t){return i(r,t)?e(r,t):c(r,t,u,n)}(n,r)}},Qr=Kr(function(n){return void 0!==n&&!b.isArray(n)&&!b.isObject(n)}),Vr=b.curry(function(t,n,r){return!Mn(function(n,r){if(!t(n,r))return!0},n,r)}),Xr=Vr(E),Yr=b.curry(function(t,n,r){var u=!1;return Mn(function(n,r){if(!t(n,r))return u=!1;u=!0},n,r),u}),Zr=Yr(E),nt=b.curry(function(t,n,r){return!!Mn(function(n,r){if(t(n,r))return!0},n,r)}),rt=(0,b.curry)(function(u,n,r){var e=[];return Mn(function(n,r){var t=u(n,r);void 0!==t&&e.push(t)},n,r),e}),tt=rt(E),ut=(0,b.curry)(function(t,n,r){var u=[];return Mn(function(n,r){u.push(t(n,r))},n,r),u}),et=ut(E),it=hn(E,vn),ot=it(E),ct=b.curry(function(t,n,r){return dn(sn,function(n,r){return t(n,r)?1:0},n,r)}),ft=ct(b.isDefined),at=b.curry(function(e,n,r){var i=new Map;return Mn(function(n,r){var t=e(n,r),u=i.get(t);i.set(t,void 0!==u?u+1:1)},n,r),i}),vt=at(E),st=b.curry(function(t,u,n,r){return Mn(function(n,r){u=t(u,n,r)},n,r),u}),lt=b.curry(function(n,r,t,u){var e=[],i=[];Mn(function(n,r){i.push(n),e.push(r)},t,u);for(var o=i.length-1;0<=o;--o)r=n(r,i[o],e[o]);return r}),dt=b.curry(function(t,n,r){return Mn(function(n,r){t(n,r)},n,r)}),ht=b.curry(function(n,t,r,u){var e=n();return Mn(function(n,r){t(e,n,r)},r,u),e}),yt=b.curry(Mn),pt=b.curry(function(n,r){return void 0!==Mn(E,n,r)}),gt=b.curry(function(n,r){return!Mn(T,n,r)}),mt=hn(P,E(function(t){return an(function(n,r){return void 0!==n?void 0!==r?n+t+r:n:r})})),bt=mt(E),At=ln(O),jt=At(E),xt=b.curry(function(u,n,r){var e=0,i=0;return Mn(function(n,r){var t=u(n,r);void 0!==t&&(i+=1,e+=t)},n,r),e/i}),Ot=xt(E),wt=ln(x),It=wt(E),St=b.curry(function(t,n,r){return!Mn(function(n,r){if(t(n,r))return!0},n,r)}),Ut=nt(E),kt=wr(an(p,1)),Et=kt(D(1)),Ft=v,Mt=yt,qt=wr(sn),Nt=qt(L),Rt=b.curry(function(n,r){return Nn(n(r),Or(r))}),Pt=b.curry(Nn),zt=Pt(E),Ct=function(e){return function(n,r,t,u){return u(void 0!==n?e(n,r):n,r)}},Dt=function(e){return function(n,r,t,u){return t.map(function(n){return void 0!==n?e(n,r):n},u(n,r))}},Lt=F(lr($r)),Tt=E(function(o){return function(n,r,t,u){var e=void 0,i=b.array0;return dr(n)&&_n(o,n,e=[],i=[]),t.map(function(n){var r=n?n.length:0,t=i.length,u=r+t;return u===t?i:Q(Q(Array(u),0,n,0,r),r,i,0,t)},u(e,r))}}),Wt=E,$t=Sr(function(n){return dr(n)&&n.length?n.length-1:0}),Bt=(0,b.curry)(function(f,a){return function(u,n,r,t){var e=dr(u),i=e&&u.length,o=z(0,i,0,f),c=z(o,i,i,a);return r.map(function(n){var r=n?n.length:0,t=o+r;return Q(Q(Q(Array(i-c+t),0,u,0,o),o,n,0,r),t,u,c,i)},t(e?Q(Array(Math.max(0,c-o)),0,u,o,c):void 0,n))}}),Jt=function(n){return b.isObject(n)?Ht(Ar(Hr,ar,n)):n},_t=E,Gt=function(n){return d.apply(null,b.keys(n))},Ht=E(function(e){return function(r,n,t,u){return t.map(function(n){return Dn(e,n,r)},u(Cn(e,r),n))}}),Kt=b.curry(function(e,i){function o(n){return Jn(i,e,n)}return function(n,r,t,u){return t.map(o,u(Jn(e,i,n),r))}}),Qt=b.curry(Rn),Vt=ir(er),Xt=function(n){var r=h(n),e=v(n),i=function(n){return K(r,n)};return function(n,r,t,u){return t.map(i,u(K(e,n),r))}},Yt=function(e){return function(n,r,t,u){return t.map(function(n){return Mn(E,e,n)},u(kn(e,n,void 0),r))}},Zt=b.curry(er),nu=Rn(W,W),ru=Rn(B(dr,E(function(n){for(var r=n.length,t=Array(r),u=0;u<r;++u)t[u]=[u,n[u]];return t})),B(b.isArray,E(function(n){for(var r=n.length,t=Array(r),u=0;u<r;++u){var e=n[u];2===e.length&&(t[e[0]]=e[1])}r=t.length;for(var i=0,o=0;o<r;++o){var c=t[o];void 0!==c&&(o!==i&&(t[i]=c),++i)}return t.length=i,t}))),tu=Rn(G,G),uu=E(function(n,r,t,u){return t.map($,u((n instanceof Object||b.isString(n))&&1===n.length?n[0]:void 0,r))}),eu=Rn(B(w(Object),E(function(n){n=Ln(n);var r=[];for(var t in n){var u=n[t];if(b.isArray(u))for(var e=0,i=u.length;e<i;++e)r.push([t,u[e]]);else r.push([t,u])}return r})),B(b.isArray,E(function(n){for(var r=I(null),t=0,u=n.length;t<u;++t){var e=n[t];if(2===e.length){var i=e[0],o=e[1],c=r[i];void 0===c?r[i]=o:b.isArray(c)?c.push(o):r[i]=[c,o]}}return b.assign({},r)}))),iu=E(function(n){var r=n||b.object0,t=r.reviver,u=r.replacer,e=r.space;return Rn(B(b.isString,N(function(n){return JSON.parse(n,t)})),B(b.isDefined,function(n){return JSON.stringify(n,u,e)}))}),ou=Pn(N(decodeURI),encodeURI),cu=Rn(B(b.isString,N(decodeURIComponent)),B(r,encodeURIComponent)),fu=b.curry(function(n,r){return Pn(k(q(n,"g"),r),k(q(r,"g"),n))}),au=E(function(r){var t=1<arguments.length?arguments[1]:r;return Rn(B(b.isString,function(n){return n.split(t)}),B(b.isArray,function(n){return n.join(r)}))}),vu=E(function(u){var t=q(1<arguments.length?arguments[1]:u,"");return Rn(B(b.isString,function(n){var r=t.exec(n);return r?[n.slice(0,Hn(r)),n.slice(Kn(r))]:[n,""]}),function(n){if(b.isArray(n)&&2===n.length){var r=n[0],t=n[1];return t?r+u+t:r}})}),su=gr([Ct(function(n){return b.isString(n)?n.replace(/\+/g,"%20"):n}),au("&"),Xt([vu("="),Xt(cu)]),Yt(eu)]),lu=zn(j,j);n.seemsArrayLike=dr,n.Identity=hr,n.IdentityAsync=yr,n.Select=pr,n.toFunction=gr,n.assign=mr,n.disperse=br,n.modify=Ar,n.modifyAsync=jr,n.remove=xr,n.set=Or,n.traverse=wr,n.compose=function(){var n=arguments.length;if(n<2)return n?arguments[0]:Tn;for(var r=Array(n);n--;)r[n]=arguments[n];return r},n.flat=function(){for(var n=[f],r=0,t=arguments.length;r<t;++r)n.push(arguments[r],f);return n},n.lazy=function(e){function i(n,r,t,u){return o(n,r,t,u)}var o=function(n,r,t,u){return(o=gr(e(i)))(n,r,t,u)};return i},n.choices=Ir,n.choose=Sr,n.cond=Ur,n.condOf=kr,n.ifElse=Er,n.orElse=Fr,n.chain=Mr,n.choice=function(){for(var n=arguments.length,r=Array(n),t=0;t<n;t++)r[t]=arguments[t];return r.reduceRight(ur,or)},n.unless=qr,n.when=Nr,n.optional=Rr,n.zero=or,n.mapIx=function(e){return function(n,r,t,u){return u(n,e(r,n))}},n.setIx=function(e){return function(n,r,t,u){return u(n,e)}},n.tieIx=Pr,n.joinIx=zr,n.skipIx=Cr,n.getLog=function(n,r){var t=dn(mn,function(n){return{p:[n,yn],x:n,c:n}},n,r),u=t.p,e=t.c;u=pn(u,["%O"]);for(var i=2;i<u.length;++i)u[0]+=" <= %O";return console.log.apply(console,u),e},n.log=function(){var n=b.curry(function(n,r){return console.log.apply(console,Q([],0,arguments,0,arguments.length).concat([n,r])),r});return Rn(n("get"),n("set"))},n.transform=Dr,n.transformAsync=Lr,n.seq=Tr,n.assignOp=function(n){return[Gt(n),Wr(n)]},n.modifyOp=function(e){return function(n,r,t,u){return t.of(e(n,r))}},n.setOp=Wr,n.removeOp=$r,n.branchOr=Br,n.branch=Jr,n.branches=function(){for(var n=arguments.length,r={},t=0;t<n;++t)r[arguments[t]]=Tn;return Jr(r)},n.elems=t,n.elemsTotal=function(n,r,t,u){return dr(n)?t===hr?H(u,n,H):t===pr?e(u,n):o(t,u,n,o):t.of(n)},n.entries=_r,n.keys=Gr,n.matches=function(f){return function(r,n,t,u){if(b.isString(r)){var e=t.map;if(f.global){var i=[""];return i.input=r,i.index=0,pr===t?function(n,r,t){for(;t=Qn(t,r);){var u=n(Gn(t),Hn(t));if(void 0!==u)return u}}(u,f,i):e((c=r,function(n){for(var r="",t=0,u=function(n){for(var r=[];Vn!==n;)r.push(n[0],n[1]),n=n[2];return r}(n),e=u.length-2;-2!==e;e+=-2){var i=u[e];r+=c.slice(t,Hn(i));var o=u[e+1];void 0!==o&&(r+=o),t=Kn(i)}return r+c.slice(t)}),function(n,r,t,u,e,i){for(var o=t(Vn);i=Qn(i,e);)o=r(r(n(Vn,t(i)),o),u(Gn(i),Hn(i)));return o}(e,t.ap,t.of,u,f,i))}var o=r.match(f);if(o)return e(function(n){return r.replace(f,void 0!==n?n:"")},u(o[0],Hn(o)))}var c;return t.of(r)}},n.values=Hr,n.children=c,n.flatten=f,n.query=function(){for(var n=[],r=0,t=arguments.length;r<t;++r){var u=gr(arguments[r]);n.push(Kr(rr(u)),u)}return n},n.satisfying=Kr,n.leafs=Qr,n.all=Vr,n.and=Xr,n.all1=Yr,n.and1=Zr,n.any=nt,n.collectAs=rt,n.collect=tt,n.collectTotalAs=ut,n.collectTotal=et,n.concatAs=it,n.concat=ot,n.countIf=ct,n.count=ft,n.countsAs=at,n.counts=vt,n.foldl=st,n.foldr=lt,n.forEach=dt,n.forEachWith=ht,n.get=v,n.getAs=yt,n.isDefined=pt,n.isEmpty=gt,n.joinAs=mt,n.join=bt,n.maximumBy=At,n.maximum=jt,n.meanAs=xt,n.mean=Ot,n.minimumBy=wt,n.minimum=It,n.none=St,n.or=Ut,n.productAs=kt,n.product=Et,n.select=Ft,n.selectAs=Mt,n.sumAs=qt,n.sum=Nt,n.foldTraversalLens=Rt,n.getter=function(e){return function(n,r,t,u){return u(e(n,r),r)}},n.lens=Pt,n.partsOf=function(e){return function(r,n,t,u){return t.map(function(n){return Un(e,n,r)},u(et(e,r),n))}},n.setter=zt,n.defaults=function(e){function i(n){return Jn(e,void 0,n)}return function(n,r,t,u){return t.map(i,u(void 0!==n?n:e,r))}},n.define=function(e){var i=D(e);return function(n,r,t,u){return t.map(i,u(void 0!==n?n:e,r))}},n.normalize=function(n){return[Ct(n),Dt(n)]},n.required=function(n){return Kt(n,void 0)},n.reread=Ct,n.rewrite=Dt,n.append=s,n.cross=Lt,n.filter=Tt,n.find=l,n.findWith=function(n){var r=gr(n),t=rr(r);return[1<arguments.length?l(t,arguments[1]):l(t),r]},n.first=0,n.index=Wt,n.last=$t,n.prefix=function(n){return Bt(0,n)},n.slice=Bt,n.suffix=function(n){return Bt(0===n?1/0:n?-n:0,void 0)},n.pickIn=Jt,n.prop=_t,n.props=d,n.propsOf=Gt,n.removable=function(){function e(n){if(!(n instanceof Object))return n;for(var r=0,t=u.length;r<t;++r)if(b.hasU(u[r],n))return n}for(var n=arguments.length,u=Array(n),r=0;r<n;r++)u[r]=arguments[r];return function(n,r,t,u){return t.map(e,u(n,r))}},n.valueOr=function(e){return function(n,r,t,u){return u(null!=n?n:e,r)}},n.pick=Ht,n.replace=Kt,n.getInverse=h,n.iso=Qt,n.alternatives=Vt,n.array=Xt,n.inverse=Yt,n.iterate=function(n){return Rn(vr(v(n)),vr(h(n)))},n.orAlternatively=Zt,n.complement=nu,n.identity=Tn,n.is=function(r){return Rn(function(n){return b.acyclicEqualsU(r,n)},function(n){return!0===n?r:void 0})},n.subset=function(n){var r,t=(r=n,function(n){return r(n)?n:void 0});return Rn(t,t)},n.indexed=ru,n.reverse=tu,n.singleton=uu,n.disjoint=function(i){return function(n,r,t,u){var e=Zn(i);return t.map(e,u(Yn(i,n),r))}},n.keyed=Xn,n.multikeyed=eu,n.json=iu,n.uri=ou,n.uriComponent=cu,n.dropPrefix=function(r){return Pn(function(n){return n.startsWith(r)?n.slice(r.length):void 0},function(n){return r+n})},n.dropSuffix=function(r){return Pn(function(n){return n.endsWith(r)?n.slice(0,n.length-r.length):void 0},function(n){return n+r})},n.replaces=fu,n.split=au,n.uncouple=vu,n.querystring=su,n.add=function(n){return zn(g(n),g(-n))},n.divide=function(n){return zn(A(n),m(n))},n.multiply=function(n){return zn(m(n),A(n))},n.negate=lu,n.subtract=function(n){return zn(g(-n),g(n))},n.FantasyFunctor=on,n.fromFantasy=function(n){return n.prototype[nn]?fn(n):n[Z]?cn(n):on},n.fromFantasyApplicative=cn,n.fromFantasyMonad=fn,n.pointer=function(n){"#"===n[0]&&(n=decodeURIComponent(n));for(var r=n.split("/"),t=r.length,u=1;u<t;++u){var e=r[u];r[u-1]=/^(0|[1-9]\d*)$/.test(e)?Er(_,Number(e),e):"-"===e?Er(_,s,e):e.replace("~1","/").replace("~0","~")}return r.length=t-1,r},Object.defineProperty(n,"__esModule",{value:!0})}); | ||
!function(n,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports,require("infestines")):"function"==typeof define&&define.amd?define(["exports","infestines"],r):r(n.L={},n.I)}(this,function(n,b){"use strict";function r(n){switch(typeof n){case"boolean":case"number":case"string":return!0;default:return!1}}function e(n,r){for(var t=0,u=r.length;t<u;++t){var e=n(r[t],t);if(void 0!==e)return e}}function i(n){if(!this)return V(new i(n));this.map=n}function o(n,r,t,u){var e=n.map,i=n.ap,o=n.of(On),c=t.length;if(e===b.sndU){for(var f=0;f<c;++f)o=i(o,r(t[f],f));return o}for(var a=On(u),v=0;v<c;++v)o=i(e(a,o),r(t[v],v));return e(wn,o)}function a(n,r){var t=r.length-n;if(t<2)return t?Pr(r[n]):Hn;for(var e=Pr(r[n+--t]),i=function(t,u){return function(n,r){return e(n,r,t,u)}};--t;)i=zn(Pr(r[n+t]),i);var o=Pr(r[n]);return function(n,r,t,u){return o(n,r,t,i(t,u))}}function u(n,r,t,u){for(var e,i,o=n.length,c=Array(o),f=0;f<o;++f)switch(c[f]=t,typeof(e=n[f])){case"string":t=Sn(e,t);break;case"number":t=Fn(e,t);break;default:t=a(f,n)(t,n[f-1],zr,r||b.always(u)),o=f}for(o===n.length&&(t=r?r(t,n[o-1]):u);0<=--o;)t=b.isString(i=n[o])?kn(i,t,c[o]):qn(i,t,c[o]);return t}function t(n){this[Ar]=n,b.freeze(this)}function c(n){for(;R(Ir)<n;)Ir.push(new xr(R(Ir)));return Ir}function h(n,r,t,u){if(void 0!==u){if(r in t)return b.acyclicEqualsU(t[r],u);t[r]=u;var e=n[r];return!e||e(u)}}function f(i,n){if(!jr(n)){if(gt(Ur,ht,i))return b.always(i);if(wr(i)){var r=i[Ar][0][Ar];return function(n){return n[r]}}if(b.isArray(i)){for(var a=[],v=[],s=void 0,t=R(i),u=0;u<t;++u){var e=i[u];Or(e)?s=e[Ar]:(void 0!==s?v:a).push(f(e))}return X(function(n){for(var r=[],t=0,u=a.length;t<u;++t)Fr(r,a[t](n));if(0<=s){var e=n[s];if(e)for(var i=0,o=e.length;i<o;++i)Fr(r,e[i])}for(var c=0,f=v.length;c<f;++c)Fr(r,v[c](n));return r})}var o=i[Ar];return o&&(o=o[0][Ar]),i=Lr(lt,f,i),X(function(n){var r={};for(var t in i)Er(r,t,i[t](n));if(0<=o){var u=n[o];if(u)for(var e in u)Er(r,e,u[e])}return r})}}function v(n,r,t,u){return Mr(n)?hr(n,0,t,u):t.of(n)}function s(n,r,t,u){return b.isArray(n)?hr(n,0,t,u):b.isObject(n)?lt(n,r,t,u):t.of(n)}function l(n,r,u,e){return function n(r,t){return b.isArray(r)?hr(r,0,u,n):void 0!==r?e(r,t):u.of(r)}(n,r)}function d(r,n){return 1<arguments.length?Dn(P,r,n):function(n){return Dn(P,r,n)}}function p(r,n,t,u){var e=Mr(r)?r.length:0;return t.map(function(n){return qn(e,n,r)},u(void 0,e))}function y(o){var c=1<arguments.length?arguments[1]:{hint:0};return function(n,r,t,u){var e=Mr(n)?n:"",i=c.hint=function(n,r,t){var u=n.hint,e=t.length;e<=u&&(u=e-1),u<0&&(u=0);for(var i=u-1;0<=i&&u<e;++u,--i){if(r(t[u],u,n))return u;if(r(t[i],i,n))return i}for(;u<e;++u)if(r(t[u],u,n))return u;for(;0<=i;--i)if(r(t[i],i,n))return i;return e}(c,o,e);return t.map(function(n){return qn(i,n,e)},u(e[i],i))}}function g(){for(var n,r=arguments.length,t={},u=0;u<r;++u)t[n=arguments[u]]=n;return lu(t)}function m(r,n){return 1<arguments.length?Rn(r,n,void 0):function(n){return Rn(r,n,void 0)}}function A(n){var r=0;b.isFunction(n)&&(n=n.apply(null,c(r=n.length)));var t=Array(r),u=n.map(function(n){return function t(c,o){if(gt(Ur,ht,o))return function(n,r){return b.acyclicEqualsU(o,r)};if(wr(o)){var u=o[Ar][0][Ar];return u<0?P:function(n,r){return h(c,u,n,r)}}if(b.isArray(o)){for(var f=[],a=[],v=void 0,s=R(o),n=0;n<s;++n){var r=o[n];Or(r)?c[v=r[Ar]]=Sr:(void 0!==v?a:f).push(t(c,r))}return function(n,r){if(Mr(r)){var t=r.length;if(!(void 0!==v?t<s-1:t!==s)){for(var u=f.length,e=0;e<u;++e)if(!f[e](n,r[e]))return;var i=a.length;t-=i;for(var o=0;o<i;++o)if(!a[o](n,r[t+o]))return;return!(0<=v)||h(c,v,n,tn(Array(t-u),0,r,u,t))}}}}var l=o[Ar];l&&(c[l=l[0][Ar]]=kr),o=Lr(lt,function(n,r){return jr(r)?void 0:t(c,n)},o);var d=St(lt,o);return function(n,r){if(!Ur(r)&&!b.isArray(r)){r=Gn(r);var t=0<=l&&{},u=0;for(var e in r){var i=o[e];if(i){if(!i(n,r[e]))return;u++}else{if(void 0===l)return;t&&(t[e]=r[e])}}return u===d&&(!t||h(c,l,n,V(t)))}}}(t,n)}),e=n.map(f);return Wn(qr(r,u[0],e[1]),qr(r,u[1],e[0]))}var j=function(n,r){return n+r},O=function(n,r){return n*r},x=b.curry(j),w=b.curry(O),I=b.curry(function(n,r){return r/n}),U=function(n){return-n},S=function(n,r){return n<r},k=function(n,r){return r<n},E=b.curry(function(n,r){return r instanceof n}),F=Object.create,q=function(n){return b.assign(F(null),n)},M=b.freeze(q(b.object0)),z=b.curry(function(n,r,t){return t.replace(n,r)}),N=Symbol.iterator,R=function(n){return n.length},P=function(n){return n},C=function(n){return n},D=function(n){return n},L=function(n,r){return b.isString(n)?new RegExp(z(/[|\\{}()[\]^$+*?.]/g,"\\$&",n),r):n},T=function(r){return D(function(n){try{return r(n)}catch(n){return n}})},W=function(n,r){return null!=r&&b.isFunction(r.then)?r.then(n):n(r)},$=function(n){return void 0!==n?String(n):""},_=function(n,r,t,u){return void 0!==u?Math.min(Math.max(n,u<0?r+u:u),r):t},B=function(r){return function(n){return[n,r]}},J=function(r){return function(n){return void 0!==n?n:r}},G=J(0),H=b.always(!0),K=function(n){return void 0!==n?!n:n},Q=function(r,t){return D(function(n){return r(n)?t(n):void 0})},V=P,X=P,Y=function(n){return!(n instanceof Object)||b.isArray(n)},Z=P(function(n){if(Mr(n)){for(var r=n.length,t=Array(r),u=0;r;)t[u++]=n[--r];return t}}),nn=P(function(n,r,t){for(var u=r.length,e=Array(u),i=0,o=!0,c=0;c<u;++c){var f=r[c],a=n(f,c);t!==a&&(e[i++]=a,o&&(o=f===a&&(0!==f||1/f==1/a)||f!=f&&a!=a))}return i!==u?(e.length=i,e):o?r:e}),rn=function(n,r){return Mr(r)?nn(n,r,void 0):void 0},tn=P(function(n,r,t,u,e){for(;u<e;)n[r++]=t[u++];return n}),un=b.inherit(function n(r,t,u){if(!this)return V(new n(r,t,u));i.call(this,r),this.of=t,this.ap=u},i),en=b.inherit(function n(r,t,u,e){if(!this)return V(new n(r,t,u,e));un.call(this,r,t,u),this.chain=e},un),on="fantasy-land/",cn=on+"of",fn=on+"chain",an=function(t){return C(function(n,r){return r[t](n)})},vn=an("fantasy-land/map"),sn=an("fantasy-land/ap"),ln=an(fn),dn=i(vn),hn=function(n){return un(vn,n[cn],sn)},pn=function(n){return en(vn,n[cn],sn,ln)},yn=function(n,r){return un(b.sndU,b.always(r),n)},gn=function(n){return yn(n.concat,(0,n.empty)())},mn=yn(j,0),bn=function(o){return b.curry(function(u,n,r){var e=void 0,i=void 0;return Dn(function(n,r){var t=u(n,r);void 0===t||void 0!==i&&!o(t,i)||(e=n,i=t)},n,r),e})},An=function(n,r,t,u){return Pr(t)(u,void 0,n,r)},jn=function(e,n){return b.curryN(4,D(function(t,u){return u=n(u),function(n,r){return e(An(u,t,n,r))}}))},On=function(t){return function(r){return function(n){return t!==n?[n,r]:r}}},xn=function(n,r){for(;On!==n;)r.push(n[0]),n=n[1];return r},wn=P(function(n){return xn(n,[]).reverse()}),In=un(function(n,r){var t=r.p,u=r.x,e=r.c;return u=n(u),b.isFunction(u)||(t=[u,t]),{p:t,x:u,c:e}},function(n){return{p:[],x:n,c:void 0}},function(n,r){var t=void 0!==n.c?n:r;return{p:t.p,x:n.x(r.x),c:t.c}}),Un=function(i,o){return function(e){return function(r,n,t,u){return t.map(function(n){return o(e,n,r)},u(i(e,r),e))}}},Sn=function(n,r){return r instanceof Object?r[n]:void 0},kn=P(function(n,r,t){return void 0!==r?b.assocPartialU(n,r,t):b.dissocPartialU(n,t)||b.object0}),En=Un(Sn,kn),Fn=function(n,r){return Mr(r)?r[n]:void 0},qn=P(function(n,r,t){Mr(t)||(t="");var u=t.length;if(void 0!==r){for(var e=Math.max(n+1,u),i=Array(e),o=0;o<e;++o)i[o]=t[o];return i[n]=r,i}if(u<=n)return tn(Array(u),0,t,0,u);for(var c=Array(u-1),f=0;f<n;++f)c[f]=t[f];for(var a=n+1;a<u;++a)c[a-1]=t[a];return c}),Mn=Un(Fn,qn),zn=function(e,n){return function(t,u){return u=n(t,u),function(n,r){return e(n,r,t,u)}}},Nn=function(n,r,t){Mr(r)||(r="");var u=0;return Pn(n,function(){return r[u++]},t)},Rn=P(function(n,r,t){switch(typeof n){case"string":return kn(n,r,t);case"number":return qn(n,r,t);case"object":return u(n,0,t,r);default:return 4===n.length?n(t,void 0,zr,b.always(r)):t}}),Pn=P(function(n,r,t){switch(typeof n){case"string":return kn(n,r(Sn(n,t),n),t);case"number":return qn(n,r(Fn(n,t),n),t);case"object":return u(n,r,t);default:return 4===n.length?n(t,void 0,zr,r):(r(n(t,void 0),void 0),t)}}),Cn=function(n,r,t){return u=Pr(n)(t,void 0,Nr,r),Promise.resolve(u);var u},Dn=P(function(n,r,t){switch(typeof r){case"string":return n(Sn(r,t),r);case"number":return n(Fn(r,t),r);case"object":for(var u,e=r.length,i=0;i<e;++i)switch(typeof(u=r[i])){case"string":t=Sn(u,t);break;case"number":t=Fn(u,t);break;default:return a(i,r)(t,r[i-1],Rr,n)}return n(t,r[e-1]);default:return n!==P&&4!==r.length?n(r(t,void 0),void 0):r(t,void 0,Rr,n)}}),Ln=function(n,r){return Dn(P,n,r)},Tn=function(e,i){return D(function(r,t,n,u){return n.map(function(n){return i(n,r,t)},u(e(r,t),t))})},Wn=function(e,i){return D(function(n,r,t,u){return t.map(i,u(e(n),r))})},$n=function(n,r){return Wn(Q(b.isString,n),Q(b.isString,r))},_n=function(n,r){return Wn(Q(b.isNumber,n),Q(b.isNumber,r))},Bn=P(function(n,r){var t=void 0;for(var u in n){var e=n[u],i=b.isObject(e)?Bn(e,r):Dn(P,e,r);void 0!==i&&(t||(t={}),t[u]=i)}return t}),Jn=P(function(n,r,t){for(var u in n){var e=r&&r[u],i=n[u];t=b.isObject(i)?Jn(i,e,t):Rn(i,e,t)}return t}),Gn=function(n){return b.constructorOf(n)!==Object?b.toObject(n):n},Hn=function(n,r,t,u){return u(n,r)},Kn=P(function(e){return function(n){for(var r={},t=e.length;t--;){var u=n[0];void 0!==u&&(r[e[t]]=u),n=n[1]}return r}}),Qn=P(function(n,r,t,u,e,i){var o=void 0,c=!0,f={};for(var a in r){o=1;var v=t[a],s=r[a](v,a,e,i);void 0!==s?(f[a]=s,c&&(c=v===s&&(0!==v||1/v==1/s)||v!=v&&s!=s)):c=!1}var l=o;for(var d in t)if(void 0===(l&&r[d])){o=1;var h=t[d],p=n(h,d,e,i);void 0!==p?(f[d]=p,c&&(c=h===p&&(0!==h||1/h==1/p)||h!=h&&p!=p)):c=!1}return o?c&&t===u?u:f:u}),Vn=function(g,m){return function(n,r,t,u){var e=n instanceof Object?Gn(n):b.object0;if(zr===t)return Qn(g,m,e,n,t,u);if(Rr!==t){var i=t.map,o=t.ap,c=t.of,f=c(B),a=[];for(var v in m)a.push(v),f=o(i(B,f),m[v](e[v],v,t,u));var s=!!a.length||void 0;for(var l in e)void 0===(s&&m[l])&&(a.push(l),f=o(i(B,f),g(e[l],l,t,u)));return a.length?i(Kn(a),f):c(n)}for(var d in m){var h=m[d](e[d],d,t,u);if(void 0!==h)return h}for(var p in e)if(void 0===m[p]){var y=g(e[p],p,t,u);if(void 0!==y)return y}}},Xn=function(n,r,t){return b.acyclicEqualsU(t,n)?r:t},Yn=P(function(n,r,t,u){for(var e,i=0,o=r.length;i<o;++i)(n(e=r[i],i)?t:u).push(e)}),Zn=function(n){return n[0]},nr=function(n){return n.index},rr=function(n){return nr(n)+n[0].length},tr=P(function(n,r){var t=r.lastIndex;r.lastIndex=rr(n);var u=r.exec(n.input);return r.lastIndex=t,u&&u[0]&&u}),ur=function(t){return function(r){return function(n){return[t,n,r]}}},er=Wn(Q(E(Object),P(function(n){n=Gn(n);var r=[];for(var t in n)r.push([t,n[t]]);return r})),Q(b.isArray,P(function(n){for(var r={},t=0,u=n.length;t<u;++t){var e=n[t];2===e.length&&(r[e[0]]=e[1])}return r}))),ir=P(function(n,r){if(r instanceof Object){var t={};for(var u in r=Gn(r)){var e=n(u),i=t[e];void 0===i&&(t[e]=i={}),i[u]=r[u]}return t}}),or=P(function(i){return function(n){if(n instanceof Object){var r={};for(var t in n=Gn(n)){var u=n[t];if(u instanceof Object)for(var e in u=Gn(u))i(e)===t&&(r[e]=u[e])}return r}}}),cr=function(n,r,t){return void 0!==n(r,t,Rr,P)},fr=function(t){return function(n,r){return cr(t,n,r)}},ar=function(i,o){return function(e){return function(n,r,t,u){return(e(n,r)?i:o)(n,r,t,u)}}},vr=function(e,i){return i=Pr(i),e=Pr(e),function(n,r,t,u){return(cr(i,n,r)?i:e)(n,r,t,u)}},sr=function(i,o){o=Pr(o),i=Pr(i);var c=function(n){n=b.always(n);var r=o(void 0,void 0,zr,n);return void 0===r?i(void 0,void 0,zr,n):r};return function(n,r,t,u){var e=o(n,r,Rr,P);return t.map(c,u(void 0===e?i(n,r,Rr,P):e,r))}},lr=function(u){return D(function(n){for(var r=arguments.length,t=arguments[--r];r;)t=u(t,arguments[--r]);return t})},dr=function(n,r,t,u){return t.of(n)},hr=function(n,r,t,u){return t===zr?nn(u,n,void 0):t===Rr?e(u,n):o(t,u,n,void 0)},pr=function(e,i){return function(n,r,t,u){return t.chain(function(n){return i(n,r,t,u)},e(n,r,t,u))}},yr=function(n,r){return[r,au(n)]},gr=function(t){return function(n){for(var r=n;void 0!==n;)n=t(r=n);return r}},mr=function(o,c,f){return function(n,r){var t=c.length;if(Mr(n)){Mr(r)||(r="");for(var u=Math.max(t,n.length,r.length),e=Array(u),i=0;i<u;++i)if(void 0===(e[i]=o(i<t?c[i]:f,n[i],r[i])))return;return e}}},br=(0,b.curry)(function(n,r){return Tn(mr(Ln,r,n),mr(Rn,r,n))}),Ar="珳襱댎纚䤤鬖罺좴",jr=function(n){return b.isString(n)&&0===n.indexOf(Ar)},Or=E(t),xr=b.inherit(function(n){this[Ar+n]=this[Ar]=b.freeze([new t(n)]),b.freeze(this)},Object,b.assocPartialU(N,function(){return this[Ar][N]()})),wr=E(xr),Ir=[],Ur=function(n){return null==n||"object"!=typeof n},Sr=function(n){return void 0===n||b.isArray(n)},kr=function(n){return void 0===n||E(Object)},Er=function(n,r,t){void 0!==t&&(n[r]=t)},Fr=function(n,r){void 0!==r&&n.push(r)},qr=function(t,u,e){return function(n){var r=Array(t);if(u(r,n))return e(r)}},Mr=function(n){return n instanceof Object&&(n=n.length)===n>>0&&0<=n||b.isString(n)},zr=en(b.applyU,P,b.applyU,b.applyU),Nr=en(W,P,function(n,r){return W(function(r){return W(function(n){return n(r)},n)},r)},W),Rr=yn(function(n,r){return void 0!==n?n:r}),Pr=P(function(n){switch(typeof n){case"string":return En(n);case"number":return Mn(n);case"object":return a(0,n);default:return 4===n.length?n:(e=n,D(function(n,r,t,u){return t.map(b.always(n),u(e(n,r),r))}))}var e}),Cr=b.curry(function(n,r,t){return Rn([n,su(r)],r,t)}),Dr=b.curry(Nn),Lr=b.curry(Pn),Tr=b.curry(Cn),Wr=b.curry(function(n,r){return Rn(n,void 0,r)}),$r=b.curry(Rn),_r=b.curry(An),Br=lr(vr),Jr=function(e){return D(function(n,r,t,u){return Pr(e(n,r))(n,r,t,u)})},Gr=P(function(){for(var n=arguments.length,r=dr;n--;){var t=arguments[n];r=t.length<2?Pr(t[0]):ar(Pr(t[1]),r)(t[0])}return r}),Hr=P(function(i){i=Pr(i);var o=arguments.length-1;if(!o)return dr;var n=arguments[o];n=1===n.length?(--o,Pr(n[0])):dr;for(var c=Array(o),f=Array(o+1),r=0;r<o;++r){var t=arguments[r+1];c[r]=t[0],f[r]=Pr(t[1])}return f[o]=n,function(n,r,t,u){var e=o;return i(n,r,Rr,function(n,r){for(var t=0;t<e;++t)if(c[t](n,r)){if(0===(e=t))return 0;break}}),f[e](n,r,t,u)}}),Kr=b.curry(function(n,r,t){return ar(Pr(r),Pr(t))(n)}),Qr=b.curry(vr),Vr=b.curry(function(t,n){return[n,Jr(function(n,r){return void 0!==n?t(n,r):dr})]}),Xr=ar(dr,Hn),Yr=ar(Hn,dr),Zr=Yr(b.isDefined),nt=b.curry(function(e,i){return i=Pr(i),D(function(n,t,r,u){return i(n,t,r,function(n,r){return u(n,e(r,t))})})}),rt=C(nt(function(n,r){return void 0!==r?void 0!==n?[r,n]:r:n})),tt=C(nt(b.sndU)),ut=b.curry(function(n,r){return Pn(n,P,r)}),et=b.curry(function(n,r){return Cn(n,P,r)}),it=P(function(){var n=arguments.length,r=dr;if(n)for(r=Pr(arguments[--n]);n;)r=pr(Pr(arguments[--n]),r);return r}),ot=function(e){return function(n,r,t,u){return t.of(e)}},ct=ot(),ft=P(b.curryN(2,function(r){return r=Pr(r),function(n){return function n(r,t){var u=F(null);for(var e in t){var i=t[e];u[e]=b.isObject(i)?n(r,i):Pr(i)}return Vn(r,u)}(r,n)}})),at=ft(dr),vt=C(Pr([er,v])),st=C(Pr([er,v,0])),lt=C(Vn(Hn,M)),dt=function(i){return function(n,r,u,e){return function n(r,t){return i(r,t)?e(r,t):s(r,t,u,n)}(n,r)}},ht=dt(function(n){return void 0!==n&&!b.isArray(n)&&!b.isObject(n)}),pt=b.curry(function(t,n,r){return!Dn(function(n,r){if(!t(n,r))return!0},n,r)}),yt=pt(P),gt=b.curry(function(t,n,r){var u=!1;return Dn(function(n,r){if(!t(n,r))return u=!1;u=!0},n,r),u}),mt=gt(P),bt=b.curry(function(t,n,r){return!!Dn(function(n,r){if(t(n,r))return!0},n,r)}),At=(0,b.curry)(function(u,n,r){var e=[];return Dn(function(n,r){var t=u(n,r);void 0!==t&&e.push(t)},n,r),e}),jt=At(P),Ot=(0,b.curry)(function(t,n,r){var u=[];return Dn(function(n,r){u.push(t(n,r))},n,r),u}),xt=Ot(P),wt=jn(P,gn),It=wt(P),Ut=b.curry(function(t,n,r){return An(mn,function(n,r){return t(n,r)?1:0},n,r)}),St=Ut(b.isDefined),kt=b.curry(function(e,n,r){var i=new Map;return Dn(function(n,r){var t=e(n,r),u=i.get(t);i.set(t,void 0!==u?u+1:1)},n,r),i}),Et=kt(P),Ft=b.curry(function(t,u,n,r){return Dn(function(n,r){u=t(u,n,r)},n,r),u}),qt=b.curry(function(n,r,t,u){var e=[],i=[];Dn(function(n,r){i.push(n),e.push(r)},t,u);for(var o=i.length-1;0<=o;--o)r=n(r,i[o],e[o]);return r}),Mt=b.curry(function(t,n,r){return Dn(function(n,r){t(n,r)},n,r)}),zt=b.curry(function(n,t,r,u){var e=n();return Dn(function(n,r){t(e,n,r)},r,u),e}),Nt=b.curry(Dn),Rt=b.curry(function(n,r){return void 0!==Dn(P,n,r)}),Pt=b.curry(function(n,r){return!Dn(H,n,r)}),Ct=jn($,P(function(t){return yn(function(n,r){return void 0!==n?void 0!==r?n+t+r:n:r})})),Dt=Ct(P),Lt=bn(k),Tt=Lt(P),Wt=b.curry(function(u,n,r){var e=0,i=0;return Dn(function(n,r){var t=u(n,r);void 0!==t&&(i+=1,e+=t)},n,r),e/i}),$t=Wt(P),_t=bn(S),Bt=_t(P),Jt=b.curry(function(t,n,r){return!Dn(function(n,r){if(t(n,r))return!0},n,r)}),Gt=bt(P),Ht=_r(yn(O,1)),Kt=Ht(J(1)),Qt=d,Vt=Nt,Xt=_r(mn),Yt=Xt(G),Zt=b.curry(function(n,r){return Tn(n(r),$r(r))}),nu=b.curry(Tn),ru=nu(P),tu=function(e){return function(n,r,t,u){return u(void 0!==n?e(n,r):n,r)}},uu=function(e){return function(n,r,t,u){return t.map(function(n){return void 0!==n?e(n,r):n},u(n,r))}},eu=C(br(ct)),iu=P(function(o){return function(n,r,t,u){var e=void 0,i=b.array0;return Mr(n)&&Yn(o,n,e=[],i=[]),t.map(function(n){var r=n?n.length:0,t=i.length,u=r+t;return u===t?i:tn(tn(Array(u),0,n,0,r),r,i,0,t)},u(e,r))}}),ou=P,cu=Jr(function(n){return Mr(n)&&n.length?n.length-1:0}),fu=(0,b.curry)(function(f,a){return function(u,n,r,t){var e=Mr(u),i=e&&u.length,o=_(0,i,0,f),c=_(o,i,i,a);return r.map(function(n){var r=n?n.length:0,t=o+r;return tn(tn(tn(Array(i-c+t),0,u,0,o),o,n,0,r),t,u,c,i)},t(e?tn(Array(Math.max(0,c-o)),0,u,o,c):void 0,n))}}),au=function(n){return b.isObject(n)?lu(Lr(lt,yr,n)):n},vu=P,su=function(n){return g.apply(null,b.keys(n))},lu=P(function(e){return function(r,n,t,u){return t.map(function(n){return Jn(e,n,r)},u(Bn(e,r),n))}}),du=b.curry(function(e,i){function o(n){return Xn(i,e,n)}return function(n,r,t,u){return t.map(o,u(Xn(e,i,n),r))}}),hu=b.curry(Wn),pu=new xr(-1),yu=lr(sr),gu=function(n){var r=m(n),e=d(n),i=function(n){return rn(r,n)};return function(n,r,t,u){return t.map(i,u(rn(e,n),r))}},mu=function(e){return function(n,r,t,u){return t.map(function(n){return Dn(P,e,n)},u(Rn(e,n,void 0),r))}},bu=b.curry(sr),Au=Wn(K,K),ju=Wn(Q(Mr,P(function(n){for(var r=n.length,t=Array(r),u=0;u<r;++u)t[u]=[u,n[u]];return t})),Q(b.isArray,P(function(n){for(var r=n.length,t=Array(r),u=0;u<r;++u){var e=n[u];2===e.length&&(t[e[0]]=e[1])}r=t.length;for(var i=0,o=0;o<r;++o){var c=t[o];void 0!==c&&(o!==i&&(t[i]=c),++i)}return t.length=i,t}))),Ou=Wn(Z,Z),xu=A(function(n){return[[n],n]}),wu=Wn(Q(E(Object),P(function(n){n=Gn(n);var r=[];for(var t in n){var u=n[t];if(b.isArray(u))for(var e=0,i=u.length;e<i;++e)r.push([t,u[e]]);else r.push([t,u])}return r})),Q(b.isArray,P(function(n){for(var r=F(null),t=0,u=n.length;t<u;++t){var e=n[t];if(2===e.length){var i=e[0],o=e[1],c=r[i];void 0===c?r[i]=o:b.isArray(c)?c.push(o):r[i]=[c,o]}}return b.assign({},r)}))),Iu=P(function(n){var r=n||b.object0,t=r.reviver,u=r.replacer,e=r.space;return Wn(Q(b.isString,T(function(n){return JSON.parse(n,t)})),Q(b.isDefined,function(n){return JSON.stringify(n,u,e)}))}),Uu=$n(T(decodeURI),encodeURI),Su=Wn(Q(b.isString,T(decodeURIComponent)),Q(r,encodeURIComponent)),ku=b.curry(function(n,r){return $n(z(L(n,"g"),r),z(L(r,"g"),n))}),Eu=P(function(r){var t=1<arguments.length?arguments[1]:r;return Wn(Q(b.isString,function(n){return n.split(t)}),Q(b.isArray,function(n){return n.join(r)}))}),Fu=P(function(u){var t=L(1<arguments.length?arguments[1]:u,"");return Wn(Q(b.isString,function(n){var r=t.exec(n);return r?[n.slice(0,nr(r)),n.slice(rr(r))]:[n,""]}),function(n){if(b.isArray(n)&&2===n.length){var r=n[0],t=n[1];return t?r+u+t:r}})}),qu=Pr([tu(function(n){return b.isString(n)?n.replace(/\+/g,"%20"):n}),Eu("&"),gu([Fu("="),gu(Su)]),mu(wu)]),Mu=_n(U,U);n.seemsArrayLike=Mr,n.Identity=zr,n.IdentityAsync=Nr,n.Select=Rr,n.toFunction=Pr,n.assign=Cr,n.disperse=Dr,n.modify=Lr,n.modifyAsync=Tr,n.remove=Wr,n.set=$r,n.traverse=_r,n.compose=function(){var n=arguments.length;if(n<2)return n?arguments[0]:Hn;for(var r=Array(n);n--;)r[n]=arguments[n];return r},n.flat=function(){for(var n=[l],r=0,t=arguments.length;r<t;++r)n.push(arguments[r],l);return n},n.lazy=function(e){function i(n,r,t,u){return o(n,r,t,u)}var o=function(n,r,t,u){return(o=Pr(e(i)))(n,r,t,u)};return i},n.choices=Br,n.choose=Jr,n.cond=Gr,n.condOf=Hr,n.ifElse=Kr,n.orElse=Qr,n.chain=Vr,n.choice=function(){for(var n=arguments.length,r=Array(n),t=0;t<n;t++)r[t]=arguments[t];return r.reduceRight(vr,dr)},n.unless=Xr,n.when=Yr,n.optional=Zr,n.zero=dr,n.mapIx=function(e){return function(n,r,t,u){return u(n,e(r,n))}},n.setIx=function(e){return function(n,r,t,u){return u(n,e)}},n.tieIx=nt,n.joinIx=rt,n.skipIx=tt,n.getLog=function(n,r){var t=An(In,function(n){return{p:[n,On],x:n,c:n}},n,r),u=t.p,e=t.c;u=xn(u,["%O"]);for(var i=2;i<u.length;++i)u[0]+=" <= %O";return console.log.apply(console,u),e},n.log=function(){var n=b.curry(function(n,r){return console.log.apply(console,tn([],0,arguments,0,arguments.length).concat([n,r])),r});return Wn(n("get"),n("set"))},n.transform=ut,n.transformAsync=et,n.seq=it,n.assignOp=function(n){return[su(n),ot(n)]},n.modifyOp=function(e){return function(n,r,t,u){return t.of(e(n,r))}},n.setOp=ot,n.removeOp=ct,n.branchOr=ft,n.branch=at,n.branches=function(){for(var n=arguments.length,r={},t=0;t<n;++t)r[arguments[t]]=Hn;return at(r)},n.elems=v,n.elemsTotal=function(n,r,t,u){return Mr(n)?t===zr?nn(u,n,nn):t===Rr?e(u,n):o(t,u,n,o):t.of(n)},n.entries=vt,n.keys=st,n.matches=function(f){return function(r,n,t,u){if(b.isString(r)){var e=t.map;if(f.global){var i=[""];return i.input=r,i.index=0,Rr===t?function(n,r,t){for(;t=tr(t,r);){var u=n(Zn(t),nr(t));if(void 0!==u)return u}}(u,f,i):e((c=r,function(n){for(var r="",t=0,u=function(n){for(var r=[];ur!==n;)r.push(n[0],n[1]),n=n[2];return r}(n),e=u.length-2;-2!==e;e+=-2){var i=u[e];r+=c.slice(t,nr(i));var o=u[e+1];void 0!==o&&(r+=o),t=rr(i)}return r+c.slice(t)}),function(n,r,t,u,e,i){for(var o=t(ur);i=tr(i,e);)o=r(r(n(ur,t(i)),o),u(Zn(i),nr(i)));return o}(e,t.ap,t.of,u,f,i))}var o=r.match(f);if(o)return e(function(n){return r.replace(f,void 0!==n?n:"")},u(o[0],nr(o)))}var c;return t.of(r)}},n.values=lt,n.children=s,n.flatten=l,n.query=function(){for(var n=[],r=0,t=arguments.length;r<t;++r){var u=Pr(arguments[r]);n.push(dt(fr(u)),u)}return n},n.satisfying=dt,n.leafs=ht,n.all=pt,n.and=yt,n.all1=gt,n.and1=mt,n.any=bt,n.collectAs=At,n.collect=jt,n.collectTotalAs=Ot,n.collectTotal=xt,n.concatAs=wt,n.concat=It,n.countIf=Ut,n.count=St,n.countsAs=kt,n.counts=Et,n.foldl=Ft,n.foldr=qt,n.forEach=Mt,n.forEachWith=zt,n.get=d,n.getAs=Nt,n.isDefined=Rt,n.isEmpty=Pt,n.joinAs=Ct,n.join=Dt,n.maximumBy=Lt,n.maximum=Tt,n.meanAs=Wt,n.mean=$t,n.minimumBy=_t,n.minimum=Bt,n.none=Jt,n.or=Gt,n.productAs=Ht,n.product=Kt,n.select=Qt,n.selectAs=Vt,n.sumAs=Xt,n.sum=Yt,n.foldTraversalLens=Zt,n.getter=function(e){return function(n,r,t,u){return u(e(n,r),r)}},n.lens=nu,n.partsOf=function(e){return function(r,n,t,u){return t.map(function(n){return Nn(e,n,r)},u(xt(e,r),n))}},n.setter=ru,n.defaults=function(e){function i(n){return Xn(e,void 0,n)}return function(n,r,t,u){return t.map(i,u(void 0!==n?n:e,r))}},n.define=function(e){var i=J(e);return function(n,r,t,u){return t.map(i,u(void 0!==n?n:e,r))}},n.normalize=function(n){return[tu(n),uu(n)]},n.required=function(n){return du(n,void 0)},n.reread=tu,n.rewrite=uu,n.append=p,n.cross=eu,n.filter=iu,n.find=y,n.findWith=function(n){var r=Pr(n),t=fr(r);return[1<arguments.length?y(t,arguments[1]):y(t),r]},n.first=0,n.index=ou,n.last=cu,n.prefix=function(n){return fu(0,n)},n.slice=fu,n.suffix=function(n){return fu(0===n?1/0:n?-n:0,void 0)},n.pickIn=au,n.prop=vu,n.props=g,n.propsOf=su,n.removable=function(){function e(n){if(!(n instanceof Object))return n;for(var r=0,t=u.length;r<t;++r)if(b.hasU(u[r],n))return n}for(var n=arguments.length,u=Array(n),r=0;r<n;r++)u[r]=arguments[r];return function(n,r,t,u){return t.map(e,u(n,r))}},n.valueOr=function(e){return function(n,r,t,u){return u(null!=n?n:e,r)}},n.pick=lu,n.replace=du,n.getInverse=m,n.iso=hu,n._=pu,n.mapping=A,n.mappings=function(n){return b.isFunction(n)&&(n=n.apply(null,c(n.length))),yu.apply(null,n.map(A))},n.alternatives=yu,n.array=gu,n.inverse=mu,n.iterate=function(n){return Wn(gr(d(n)),gr(m(n)))},n.orAlternatively=bu,n.complement=Au,n.identity=Hn,n.is=function(r){return Wn(function(n){return b.acyclicEqualsU(r,n)},function(n){return!0===n?r:void 0})},n.subset=function(n){var r,t=(r=n,function(n){return r(n)?n:void 0});return Wn(t,t)},n.indexed=ju,n.reverse=Ou,n.singleton=xu,n.disjoint=function(i){return function(n,r,t,u){var e=or(i);return t.map(e,u(ir(i,n),r))}},n.keyed=er,n.multikeyed=wu,n.json=Iu,n.uri=Uu,n.uriComponent=Su,n.dropPrefix=function(r){return $n(function(n){return n.startsWith(r)?n.slice(r.length):void 0},function(n){return r+n})},n.dropSuffix=function(r){return $n(function(n){return n.endsWith(r)?n.slice(0,n.length-r.length):void 0},function(n){return n+r})},n.replaces=ku,n.split=Eu,n.uncouple=Fu,n.querystring=qu,n.add=function(n){return _n(x(n),x(-n))},n.divide=function(n){return _n(I(n),w(n))},n.multiply=function(n){return _n(w(n),I(n))},n.negate=Mu,n.subtract=function(n){return _n(x(-n),x(n))},n.FantasyFunctor=dn,n.fromFantasy=function(n){return n.prototype[fn]?pn(n):n[cn]?hn(n):dn},n.fromFantasyApplicative=hn,n.fromFantasyMonad=pn,n.pointer=function(n){"#"===n[0]&&(n=decodeURIComponent(n));for(var r=n.split("/"),t=r.length,u=1;u<t;++u){var e=r[u];r[u-1]=/^(0|[1-9]\d*)$/.test(e)?Kr(Y,Number(e),e):"-"===e?Kr(Y,p,e):e.replace("~1","/").replace("~0","~")}return r.length=t-1,r},Object.defineProperty(n,"__esModule",{value:!0})}); |
{ | ||
"name": "partial.lenses", | ||
"version": "14.7.0", | ||
"version": "14.8.0", | ||
"description": "Partial lenses is a comprehensive, high-performance optics library for JavaScript", | ||
@@ -67,2 +67,3 @@ "module": "dist/partial.lenses.es.js", | ||
"babel-plugin-transform-es2015-unicode-regex": "^6.24.1", | ||
"babel-plugin-transform-object-rest-spread": "^6.26.0", | ||
"babel-polyfill": "^6.26.0", | ||
@@ -79,3 +80,3 @@ "babel-register": "^6.26.0", | ||
"ramda": "^0.25.0", | ||
"rollup": "^0.66.0", | ||
"rollup": "^0.66.1", | ||
"rollup-plugin-babel": "^3.0.7", | ||
@@ -82,0 +83,0 @@ "rollup-plugin-node-resolve": "^3.4.0", |
@@ -36,1 +36,5 @@ import * as I from 'infestines' | ||
} | ||
export const iterator = Symbol.iterator | ||
export const length = x => x.length |
@@ -60,4 +60,2 @@ import * as I from './ext/infestines' | ||
const singletonPartial = x => (void 0 !== x ? [x] : x) | ||
const expect = (p, f) => copyName(x => (p(x) ? f(x) : void 0), f) | ||
@@ -67,13 +65,19 @@ | ||
function deepFreeze(x) { | ||
if (I.isArray(x)) { | ||
x.forEach(deepFreeze) | ||
I.freeze(x) | ||
} else if (I.isObject(x)) { | ||
for (const k in x) deepFreeze(x[k]) | ||
I.freeze(x) | ||
} | ||
return x | ||
} | ||
const freezeResultInDev = | ||
process.env.NODE_ENV === 'production' ? id : C.res(I.freeze) | ||
const deepFreezeInDev = | ||
process.env.NODE_ENV === 'production' | ||
? id | ||
: function deepFreezeInDev(x) { | ||
if (I.isArray(x)) { | ||
x.forEach(deepFreezeInDev) | ||
I.freeze(x) | ||
} else if (I.isObject(x)) { | ||
for (const k in x) deepFreezeInDev(x[k]) | ||
I.freeze(x) | ||
} | ||
return x | ||
} | ||
function freezeObjectOfObjects(xs) { | ||
@@ -968,2 +972,230 @@ if (xs) for (const k in xs) I.freeze(xs[k]) | ||
// | ||
const PAYLOAD = '珳襱댎纚䤤鬖罺좴' | ||
const isPayload = k => I.isString(k) && k.indexOf(PAYLOAD) === 0 | ||
function Spread(i) { | ||
this[PAYLOAD] = i | ||
I.freeze(this) | ||
} | ||
const isSpread = I.isInstanceOf(Spread) | ||
const Variable = I.inherit( | ||
function Variable(i) { | ||
this[PAYLOAD + i] = this[PAYLOAD] = I.freeze([new Spread(i)]) | ||
I.freeze(this) | ||
}, | ||
Object, | ||
I.assocPartialU(I.iterator, function() { | ||
return this[PAYLOAD][I.iterator]() | ||
}) | ||
) | ||
const isVariable = I.isInstanceOf(Variable) | ||
const vars = [] | ||
function nVars(n) { | ||
while (I.length(vars) < n) vars.push(new Variable(I.length(vars))) | ||
return vars | ||
} | ||
const isPrimitive = x => x == null || typeof x !== 'object' | ||
function match1(kinds, i, e, x) { | ||
if (void 0 !== x) { | ||
if (i in e) return I.acyclicEqualsU(e[i], x) | ||
e[i] = x | ||
const k = kinds[i] | ||
return !k || k(x) | ||
} | ||
} | ||
function checkKind(kinds, i, kind) { | ||
if (0 <= i) { | ||
if (kinds[i]) { | ||
if (kinds[i] !== kind) | ||
throw Error( | ||
'Spread patterns must be used consistently either as arrays or as objects.' | ||
) | ||
} else { | ||
kinds[i] = kind | ||
} | ||
} | ||
} | ||
const arrayKind = x => void 0 === x || I.isArray(x) | ||
const objectKind = x => void 0 === x || I.isInstanceOf(Object) | ||
function checkPattern(kinds, p) { | ||
if (isSpread(p)) { | ||
throw Error('Spread patterns must be inside objects or arrays.') | ||
} else if (I.isArray(p)) { | ||
let nSpread = 0 | ||
for (let i = 0, n = I.length(p); i < n; ++i) { | ||
const pi = p[i] | ||
if (isSpread(pi)) { | ||
if (nSpread++) | ||
throw Error('At most one spread is allowed in an array or object.') | ||
checkKind(kinds, pi[PAYLOAD], arrayKind) | ||
} else { | ||
checkPattern(kinds, pi) | ||
} | ||
} | ||
} else if (I.isObject(p)) { | ||
let spread = p[PAYLOAD] | ||
if (spread) { | ||
spread = spread[0][PAYLOAD] | ||
checkKind(kinds, spread, objectKind) | ||
} | ||
let n = 0 | ||
for (const k in p) { | ||
if (isPayload(k)) { | ||
if (2 < ++n) | ||
throw Error('At most one spread is allowed in an array or object.') | ||
} else { | ||
checkPattern(kinds, p[k]) | ||
} | ||
} | ||
} else if (!isPrimitive(p) && !isVariable(p)) { | ||
throw Error('Only plain arrays and objects are allowed in patterns.') | ||
} | ||
} | ||
const checkPatternPairInDev = | ||
process.env.NODE_ENV === 'production' | ||
? id | ||
: ps => { | ||
const kinds = [] | ||
checkPattern(kinds, ps[0]) | ||
checkPattern(kinds, ps[1]) | ||
return deepFreezeInDev(ps) | ||
} | ||
const setDefined = (o, k, x) => { | ||
if (void 0 !== x) o[k] = x | ||
} | ||
const pushDefined = (xs, x) => { | ||
if (void 0 !== x) xs.push(x) | ||
} | ||
function toMatch(kinds, p) { | ||
if (all1(isPrimitive, leafs, p)) { | ||
return (e, x) => I.acyclicEqualsU(p, x) | ||
} else if (isVariable(p)) { | ||
const i = p[PAYLOAD][0][PAYLOAD] | ||
return i < 0 ? id : (e, x) => match1(kinds, i, e, x) | ||
} else if (I.isArray(p)) { | ||
const init = [] | ||
const rest = [] | ||
let spread = void 0 | ||
const n = I.length(p) | ||
for (let i = 0; i < n; ++i) { | ||
const x = p[i] | ||
if (isSpread(x)) { | ||
spread = x[PAYLOAD] | ||
kinds[spread] = arrayKind | ||
} else { | ||
const side = void 0 !== spread ? rest : init | ||
side.push(toMatch(kinds, x)) | ||
} | ||
} | ||
return (e, x) => { | ||
if (!seemsArrayLike(x)) return | ||
let l = x.length | ||
if (void 0 !== spread ? l < n - 1 : l !== n) return | ||
const j = init.length | ||
for (let i = 0; i < j; ++i) if (!init[i](e, x[i])) return | ||
const k = rest.length | ||
l -= k | ||
for (let i = 0; i < k; ++i) if (!rest[i](e, x[l + i])) return | ||
return ( | ||
!(0 <= spread) || | ||
match1(kinds, spread, e, copyToFrom(Array(l - j), 0, x, j, l)) | ||
) | ||
} | ||
} else { | ||
let spread = p[PAYLOAD] | ||
if (spread) { | ||
spread = spread[0][PAYLOAD] | ||
kinds[spread] = objectKind | ||
} | ||
p = modify(values, (p, k) => (isPayload(k) ? void 0 : toMatch(kinds, p)), p) | ||
const n = count(values, p) | ||
return (e, x) => { | ||
if (isPrimitive(x) || I.isArray(x)) return | ||
x = toObject(x) | ||
const rest = 0 <= spread && {} | ||
let i = 0 | ||
for (const k in x) { | ||
const m = p[k] | ||
if (m) { | ||
if (!m(e, x[k])) return | ||
i++ | ||
} else if (void 0 !== spread) { | ||
if (rest) rest[k] = x[k] | ||
} else { | ||
return | ||
} | ||
} | ||
return i === n && (!rest || match1(kinds, spread, e, freezeInDev(rest))) | ||
} | ||
} | ||
} | ||
function toSubst(p, k) { | ||
if (isPayload(k)) { | ||
return void 0 | ||
} else if (all1(isPrimitive, leafs, p)) { | ||
return I.always(p) | ||
} else if (isVariable(p)) { | ||
const i = p[PAYLOAD][0][PAYLOAD] | ||
return e => e[i] | ||
} else if (I.isArray(p)) { | ||
const init = [] | ||
const rest = [] | ||
let spread = void 0 | ||
const n = I.length(p) | ||
for (let i = 0; i < n; ++i) { | ||
const x = p[i] | ||
if (isSpread(x)) { | ||
spread = x[PAYLOAD] | ||
} else { | ||
const side = void 0 !== spread ? rest : init | ||
side.push(toSubst(x)) | ||
} | ||
} | ||
return freezeResultInDev(e => { | ||
const r = [] | ||
for (let i = 0, n = init.length; i < n; ++i) pushDefined(r, init[i](e)) | ||
if (0 <= spread) { | ||
const xs = e[spread] | ||
if (xs) for (let i = 0, n = xs.length; i < n; ++i) pushDefined(r, xs[i]) | ||
} | ||
for (let i = 0, n = rest.length; i < n; ++i) pushDefined(r, rest[i](e)) | ||
return r | ||
}) | ||
} else { | ||
let spread = p[PAYLOAD] | ||
if (spread) spread = spread[0][PAYLOAD] | ||
p = modify(values, toSubst, p) | ||
return freezeResultInDev(e => { | ||
const r = {} | ||
for (const k in p) setDefined(r, k, p[k](e)) | ||
if (0 <= spread) { | ||
const x = e[spread] | ||
if (x) for (const k in x) setDefined(r, k, x[k]) | ||
} | ||
return r | ||
}) | ||
} | ||
} | ||
const oneway = (n, m, s) => x => { | ||
const e = Array(n) | ||
if (m(e, x)) return s(e) | ||
} | ||
// Auxiliary | ||
@@ -1798,2 +2030,19 @@ | ||
export const _ = new Variable(-1) | ||
export function mapping(ps) { | ||
let n = 0 | ||
if (I.isFunction(ps)) ps = ps.apply(null, nVars((n = ps.length))) | ||
checkPatternPairInDev(ps) | ||
const kinds = Array(n) | ||
const ms = ps.map(p => toMatch(kinds, p)) | ||
const ss = ps.map(toSubst) | ||
return isoU(oneway(n, ms[0], ss[1]), oneway(n, ms[1], ss[0])) | ||
} | ||
export function mappings(ps) { | ||
if (I.isFunction(ps)) ps = ps.apply(null, nVars(ps.length)) | ||
return alternatives.apply(null, ps.map(mapping)) | ||
} | ||
// Isomorphism combinators | ||
@@ -1877,20 +2126,4 @@ | ||
export const singleton = (process.env.NODE_ENV === 'production' | ||
? id | ||
: iso => copyName(toFunction([isoU(id, I.freeze), iso]), iso))( | ||
function singleton(x, i, F, xi2yF) { | ||
return F.map( | ||
singletonPartial, | ||
xi2yF( | ||
(x instanceof Object || I.isString(x)) && x.length === 1 | ||
? x[0] | ||
: void 0, | ||
i | ||
) | ||
) | ||
} | ||
) | ||
export const singleton = mapping(x => [[x], x]) | ||
// Object isomorphisms | ||
export const disjoint = groupOf => | ||
@@ -1947,3 +2180,3 @@ function disjoint(x, i, F, xi2yF) { | ||
? id | ||
: C.res(iso => toFunction([iso, isoU(deepFreeze, id)])))(function json( | ||
: C.res(iso => toFunction([iso, isoU(deepFreezeInDev, id)])))(function json( | ||
options | ||
@@ -1950,0 +2183,0 @@ ) { |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
595574
8655
5854
42
144