UNPKG

shallow-equal-jit

Version:

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

23 lines (16 loc) 755 B
'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); 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') + ';'); } exports.shallowEqualJIT = shallowEqualJIT; //# sourceMappingURL=shallow-equal-jit.cjs.development.js.map