UNPKG

deep-shape-equals

Version:

`deep-shape-equals` is a library that allows you to see if two or more objects have the same shape. Meaning, the keys that they have are the same.

3 lines (2 loc) 900 B
"use strict";function r(t,n,a){if([t,n].includes(void 0)||typeof t!=typeof n||Array.isArray(t)!==Array.isArray(n))return!1;if(n&&Array.isArray(n)&&Array.isArray(t)){if(t.length!==n.length)return!1;var i=[].concat(t),f=!n.map(function(e,n){if(a){var f=i.map(function(t){return r(e,t)}).indexOf(!0);return-1!==f&&(i.splice(f,1),!0)}return r(e,t[n])}).includes(!1);return(!a||0===i.length)&&f}return!n||"object"!=typeof n||e([n,t],a)}function e(e,t){if(e.length<2)return!0;var n=e.pop(),a=Object.keys(n),i=e,f=Array.isArray(i),u=0;for(i=f?i:i[Symbol.iterator]();;){var o;if(f){if(u>=i.length)break;o=i[u++]}else{if((u=i.next()).done)break;o=u.value}var c=o,s=Object.keys(c);if(new Set([].concat(s,a)).size!==a.length)return!1;for(var y=0,l=s;y<l.length;y++){var p=l[y];if(!r(c[p],n[p],t))return!1}}return!0}exports.areObjectsSameShape=e; //# sourceMappingURL=deep-shape-equals.cjs.production.min.js.map