{"version":3,"sources":["../src/helpers.ts","../src/index.ts"],"sourcesContent":["import { AnyObject, Primitive } from './types';\n\n/**\n * Checks if the value is of a specified type.\n */\n// eslint-disable-next-line @typescript-eslint/ban-types\nfunction isOfType(type: string) {\n // eslint-disable-next-line valid-typeof\n return (value: unknown): value is T => typeof value === type;\n}\n\n/**\n * Checks if the value is a JavaScript function.\n */\n// eslint-disable-next-line @typescript-eslint/ban-types\nexport const isFunction = isOfType('function');\n\n/**\n * Check if the value is null.\n */\nexport const isNull = (value: unknown): value is null => {\n return value === null;\n};\n\n/**\n * Checks if the input is a regular expression.\n */\nexport const isRegex = (value: unknown): value is RegExp => {\n return Object.prototype.toString.call(value).slice(8, -1) === 'RegExp';\n};\n\n/**\n * Checks if the value is an object.\n */\nexport const isObject = (value: unknown): value is AnyObject => {\n return !isUndefined(value) && !isNull(value) && (isFunction(value) || typeof value === 'object');\n};\n\n/**\n * Checks if the value is undefined.\n */\nexport const isUndefined = isOfType('undefined');\n","import { isObject, isRegex } from './helpers';\n\n/**\n * Check if arrays are equal.\n */\nfunction equalArray(left: unknown[], right: unknown[]) {\n const { length } = left;\n\n if (length !== right.length) {\n return false;\n }\n\n for (let index = length; index-- !== 0; ) {\n if (!equal(left[index], right[index])) {\n return false;\n }\n }\n\n return true;\n}\n\n/**\n * Check if array buffers are equal.\n */\nfunction equalArrayBuffer(left: ArrayBufferView, right: ArrayBufferView) {\n if (left.byteLength !== right.byteLength) {\n return false;\n }\n\n const view1 = new DataView(left.buffer);\n const view2 = new DataView(right.buffer);\n\n let index = left.byteLength;\n\n while (index--) {\n if (view1.getUint8(index) !== view2.getUint8(index)) {\n return false;\n }\n }\n\n return true;\n}\n\n/**\n * Check if maps are equal.\n */\nfunction equalMap(left: Map, right: Map) {\n if (left.size !== right.size) {\n return false;\n }\n\n for (const index of left.entries()) {\n if (!right.has(index[0])) {\n return false;\n }\n }\n\n for (const index of left.entries()) {\n if (!equal(index[1], right.get(index[0]))) {\n return false;\n }\n }\n\n return true;\n}\n\n/**\n * Check if sets are equal.\n */\nfunction equalSet(left: Set, right: Set) {\n if (left.size !== right.size) {\n return false;\n }\n\n for (const index of left.entries()) {\n if (!right.has(index[0])) {\n return false;\n }\n }\n\n return true;\n}\n\n/**\n * Checks if two values are equal.\n */\nexport default function equal(left: unknown, right: unknown) {\n if (left === right) {\n return true;\n }\n\n if (left && isObject(left) && right && isObject(right)) {\n if (left.constructor !== right.constructor) {\n return false;\n }\n\n if (Array.isArray(left) && Array.isArray(right)) {\n return equalArray(left, right);\n }\n\n if (left instanceof Map && right instanceof Map) {\n return equalMap(left, right);\n }\n\n if (left instanceof Set && right instanceof Set) {\n return equalSet(left, right);\n }\n\n if (ArrayBuffer.isView(left) && ArrayBuffer.isView(right)) {\n return equalArrayBuffer(left, right);\n }\n\n if (isRegex(left) && isRegex(right)) {\n return left.source === right.source && left.flags === right.flags;\n }\n\n if (left.valueOf !== Object.prototype.valueOf) {\n return left.valueOf() === right.valueOf();\n }\n\n if (left.toString !== Object.prototype.toString) {\n return left.toString() === right.toString();\n }\n\n const leftKeys = Object.keys(left);\n const rightKeys = Object.keys(right);\n\n if (leftKeys.length !== rightKeys.length) {\n return false;\n }\n\n for (let index = leftKeys.length; index-- !== 0; ) {\n if (!Object.prototype.hasOwnProperty.call(right, leftKeys[index])) {\n return false;\n }\n }\n\n for (let index = leftKeys.length; index-- !== 0; ) {\n const key = leftKeys[index];\n\n if (key === '_owner' && left.$$typeof) {\n // React-specific: avoid traversing React elements' _owner.\n // _owner contains circular references\n // and is not needed when comparing the actual elements (and not their owners)\n // eslint-disable-next-line no-continue\n continue;\n }\n\n if (!equal(left[key], right[key])) {\n return false;\n }\n }\n\n return true;\n }\n\n if (Number.isNaN(left) && Number.isNaN(right)) {\n return true;\n }\n\n return left === right;\n}\n"],"mappings":";AAMA,SAAS,SAAyC,MAAc;AAE9D,SAAO,CAAC,UAA+B,OAAO,UAAU;AAC1D;AAMO,IAAM,aAAa,SAAmB,UAAU;AAKhD,I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