-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.min.cjs
1 lines (1 loc) · 3.77 KB
/
index.min.cjs
1
const e=Object.keys,r=e=>e.length,t=e=>typeof e,n=e=>"object"===t(e),o=Array.isArray,l=e=>null===e,f=e=>l(e)?"null":o(e)?"array":t(e),a=(e,r)=>f(e)!==f(r),s=(t,o)=>{if(t===o)return!0;if(a(t,o))return!1;if(!n(t))return!1;const l=e(t);if(r(l)!==r(e(o)))return!1;for(let e of l)if(!(e in o))return!1;for(let e of l)if(!s(t[e],o[e]))return!1;return!0},u=e=>e,i=e=>(r,...t)=>r[e](...t),c=i("map"),d=e=>{throw new Error(`Invalid value type "${f(e)}": ${e}`)},y=r=>(({array:e=>c(e,y),boolean:u,null:u,number:u,object:r=>((r,t,n)=>{const o={};for(let l of e(r))o[l]=t.apply(n,[r[l],l,r]);return o})(r,y),string:u,undefined:u}[f(r)]||d)(r)),b=e=>(r,t)=>r===t||n(r)&&!a(r,t)&&e(r,t),h=e=>"string"===t(e),p=e=>{const r=new Map,t=new Map,n=n=>{if(!r.has(n)){let o=e(n);h(o)&&(t.has(o)||t.set(o,Symbol(o)),o=t.get(o)),r.set(n,o)}return r.get(n)};return(e,r)=>n(e)===n(r)},g=e=>[e],v=i("flat"),_=e=>0===e,m=e=>void 0===e,j=i("push"),$=i("filter"),w=e=>2===e,M=e=>3===e,q=e=>1===e,A=e=>4===e,x=(e,t)=>o(e)&&r(e)===t,I=e=>x(e,1),O=e=>{return _(e)||q(e)||w(e)||M(e)||A(e)||I(e)||o(t=e)&&r(t)%2==0;var t},S=e=>O(e)&&!A(e),E=e=>x(e,2),N=Number.isInteger,k=e=>N(e)&&e<0||h(e),J=e=>E(e)&&k(e[0])&&S(e[1]),z=e=>N(e)&&e>0,B=(e,r)=>E(e)&&e[1]===r&&x(e[0],2)&&z(e[0][0])&&(e=>z(e)||k(e))(e[0][1]),C=e=>B(e,9),D=e=>B(e,8),F=e=>E(e)&&z(e[0])&&A(e[1]),G=e=>E(e)&&z(e[0])&&S(e[1]),H=e=>o(e[0])?e[0][1]:e[0],K=i("sort"),L=e=>K(e,((e,r)=>H(r)-H(e))),P=e=>[L($(e,C)),L($(e,D)),L($(e,G)),L($(e,F)),L($(e,J))],Q=(e,t)=>{const n=[];for(let r of e)if(!m(r[2]))for(let o of e)!m(o[1])&&m(o[2])&&t(o[1],r[2])&&(j(n,[[o[0],r[0]],8]),r.length=o.length=0);for(let r of e){const e=oe(r[1],r[2],t);_(e)||j(n,[r[0],e])}return r(n)>0?v(P(n),2):0},R=(e,r,t)=>r<0||t<0?-1:e[r][t],T=Array.from,U=Math.max,V=Math.min,W=i("slice"),X=(e,t,n)=>{const o=r(e),l=r(t),f=V(o,l);let a=0;for(;a<f&&n(e[a],t[a]);)a++;let s=0;for(;s<f&&n(e[o-1-s],t[l-1-s]);)s++;const u=((e,t,n)=>{const o=r(e)+1,l=r(t)+1,f=T({length:l},(()=>Array(o).fill(0)));for(let r=1;r<l;r++)for(let l=1;l<o;l++)f[r][l]=n(e[l-1],t[r-1])?f[r-1][l-1]+1:U(f[r][l-1],f[r-1][l]);return f})(W(e,a,o-s),W(t,a,l-s),n),i=[];let c=l-a-s,d=o-a-s;for(;d>0||c>0;){const r=R(u,c,d-1),n=R(u,c-1,d),o=d+a-1,l=c+a-1;r>n?(j(i,[+(o+1),e[o],void 0]),d--):n>r?(j(i,[-(l+1),void 0,t[l]]),c--):(R(u,c,d)===R(u,c-1,d-1)&&j(i,[+(o+1),e[o],t[l]]),d--,c--)}return Q(i,n)},Y=(e,r,t)=>g(r),Z=i("indexOf"),ee=r=>o(r)?T(r,((e,r)=>r)):K(e(r)),re=i("includes"),te=(r,t,n)=>{const o=ee(r);return Q(c($((l=[...e(r),...e(t)],[...new Set(l)]),(e=>!n(r[e],t[e]))),(e=>[re(o,e)?+(Z(o,e)+1):e,r[e],t[e]])),n);var l},ne=(e,r,t)=>g(r),oe=(e,r,t)=>t(e,r)?0:!0===r?1:(e=>!1===e)(r)?2:l(r)?3:m(r)?4:a(e,r)?g(r):({array:X,number:Y,object:te,string:ne}[f(e)]||d)(e,r,t),le=i("join"),fe=JSON.stringify,ae=r=>(({array:e=>`[${le(c(e,fe),",")}]`,boolean:fe,null:fe,number:fe,object:r=>`{${c(K(e(r)),(e=>`"${e}":${ae(r[e])}`))}}`,string:fe,undefined:()=>"undefined"}[f(r)]||d)(r)),se=Math.abs,ue=(e,r)=>h(e)?e:z(e)?r[e-1]:se(e)-1,ie=i("splice"),ce=(e,t)=>{const[n,l,f,a,s]=P(((e,t,n=0)=>{const o=[];for(;n<r(e);)j(o,W(e,n,n+t)),n+=t;return o})(t,2)),u=ee(e);for(let r of[...n,...l]){const t=r[0][0],n=r[0][1];D(r)&&j(a,[t,4]),j(z(n)?f:s,[n,g(e[ue(t,u)])])}L(s),L(a);const i=o(e)?[...e]:{...e};for(let r of f){const t=ue(r[0],u);i[t]=he(e[t],r[1])}for(let e of a){const r=ue(e[0],u);o(i)?ie(i,r,1):delete i[r]}for(let e of s){const r=ue(e[0],u),t=he(void 0,e[1]);o(i)?ie(i,r,0,t):i[r]=t}return i},de=ce,ye=ce,be=(e,r)=>{throw new Error(`Invalid delta for value of type "${f(e)}": ${r}`)},he=(e,r)=>_(r)?e:!!q(r)||!w(r)&&(M(r)?null:A(r)?void 0:I(r)?r[0]:({array:de,object:ye}[f(e)]||be)(e,r));module.exports={are_deep_equal:s,are_strict_equal:(e,r)=>e===r,deep_clone:y,diff:(e,r,{compute_object_hash:t=ae,are_objects_equal:n=p(t),are_equal:o=b(n)}={})=>oe(e,r,o),patch:he,stringify_json_value:ae};