You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

19 lines
369 B

4 years ago
  1. "use strict";
  2. /* https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.is */
  3. var NumberIsNaN = function (value) {
  4. return value !== value;
  5. };
  6. module.exports = function is(a, b) {
  7. if (a === 0 && b === 0) {
  8. return 1 / a === 1 / b;
  9. } else if (a === b) {
  10. return true;
  11. } else if (NumberIsNaN(a) && NumberIsNaN(b)) {
  12. return true;
  13. }
  14. return false;
  15. };