rubico
Version:
[a]synchronous functional programming
9 lines (7 loc) • 1.81 kB
JavaScript
/**
* rubico v2.6.2
* https://github.com/a-synchronous/rubico
* (c) 2019-2024 Richard Tong
* rubico may be freely distributed under the MIT license.
*/
!function(n,t){"object"==typeof module?module.exports=t:"function"==typeof define?define((()=>t)):n.isDeepEqual=t}("object"==typeof globalThis?globalThis:this,function(){"use strict";const n=Symbol.for("placeholder"),t=Array.isArray,r=n=>null!=n&&"function"==typeof n.then,e=Promise.all.bind(Promise),o=function(t,r,e){return r==n?((n,t)=>function(r){return n(r,t)})(t,e):((n,t)=>function(r){return n(t,r)})(t,r)},u=n=>{let t=0;for(const r in n)t+=1;return t},i=Symbol.iterator,f=function(n,t){return n===t||n!=n&&t!=t},c=function(n,r){const e=t(n),o=t(r);if(e||o)return e&&o&&function(n,t){const r=n.length;if(t.length!=r)return!1;let e=-1;for(;++e<r;)if(!s(n[e],t[e]))return!1;return!0}(n,r);if(null==n||null==r)return f(n,r);const c="string"==typeof n||n.constructor==String,l="string"==typeof r||r.constructor==String;if(c||l)return f(n,r);const y="function"==typeof n[i],p="function"==typeof r[i];if(y||p)return y&&p&&function(n,t){let r=n.next(),e=t.next();if(r.done!=e.done)return!1;for(;!r.done;){if(!s(r.value,e.value))return!1;r=n.next(),e=t.next()}return e.done}(n[i](),r[i]());const h=n.constructor==Object,a=r.constructor==Object;return h||a?h&&a&&function(n,t){if(u(n)!=u(t))return!1;for(const r in n)if(!s(n[r],t[r]))return!1;return!0}(n,r):f(n,r)},s=function(t,u){const i="function"==typeof t,f="function"==typeof u;return i&&f?function(i){const f=t(i),s=u(i),l=r(f),y=r(s);return l&&y?e([f,s]).then((p=c,function([n,t]){return p(n,t)})):l?f.then(o(c,n,s)):y?s.then(o(c,f,n)):c(f,s);var p}:i?function(e){const i=t(e);return r(i)?i.then(o(c,n,u)):c(i,u)}:f?function(e){const i=u(e);return r(i)?i.then(o(c,t,n)):c(t,i)}:c(t,u)};return s}());