function doubleEqual(a, b) { if (typeof a === typeof b) return a === b; if (wantsCoercion(a) && isCoercable(b)) { b = b.valueOf(); } else if (wantsCoercion(b) && isCoercable(a)) { const temp = a.valueOf(); a = b; b = temp; } if (a === b) return true; switch (typeof a) { case "string": if (b === true) return a === "1" || a === 1; if (b === false) return a === "0" || a === 0 || a == ""; if (a === "" && b === 0) return true; return a === String(b); case "boolean": if (a === true) return b === 1 || String(b) === "1"; else return b === false || String(b) === "0" || String(b) === ""; case "number": if (a === 0 && b === false) return true; if (a === 1 && b === true) return true; return a === Number(String(b)); case "undefined": return b === undefined || b === null; case "object": if (a === null) return b === null || b === undefined; default: return false; } }
function wantsCoercion(value) { const type = typeof value; return type === "string" || type === "number" || type === "boolean"; }
function isCoercable(value) { return value !== null && typeof value == "object"; }