UNPKG

bbo

Version:

bbo is a utility library of zero dependencies for javascript.

19 lines (16 loc) 536 B
'use strict'; /* eslint-disable no-self-compare */ function is(x, y) { // inlined Object.is polyfill to avoid requiring consumers ship their own // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is if (x === y) { // Steps 1-5, 7-10 // Steps 6.b-6.e: +0 != -0 // Added the nonzero y check to make Flow happy, but it is redundant return x !== 0 || y !== 0 || 1 / x === 1 / y; } else { // Step 6.a: NaN == NaN return x !== x && y !== y; } } module.exports = is;