UNPKG

shallow-equal-jit

Version:

Fast shallow equal with Just-In-Time compiled compare functions.

19 lines (14 loc) 649 B
function shallowEqualJIT(keys, useStrictEq) { if (useStrictEq === void 0) { useStrictEq = false; } var equal = function equal(prev, next) { return useStrictEq ? prev + " === " + next : "Object.is(" + prev + ", " + next + ")"; }; // eslint-disable-next-line no-new-func return new Function('prev', 'next', 'return ' + (keys.length > 0 ? equal('prev', 'next') + " || (" + keys.map(function (k) { k = typeof k === 'number' ? k : JSON.stringify(k); return equal("prev[" + k + "]", "next[" + k + "]"); }).join(' && ') + ')' : 'true') + ';'); } export { shallowEqualJIT }; //# sourceMappingURL=shallow-equal-jit.esm.js.map