Socket
Socket
Sign inDemoInstall

object-is

Package Overview
Dependencies
14
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    object-is

ES2015-compliant shim for Object.is - differentiates between -0 and +0


Version published
Weekly downloads
17M
decreased by-1.78%
Maintainers
1
Install size
291 kB
Created
Weekly downloads
 

Package description

What is object-is?

The 'object-is' npm package provides a utility function for comparing two values, determining if they are the same value. This is particularly useful for edge cases in JavaScript comparisons, such as NaN, +0, and -0, where traditional equality checks (== or ===) might fail or not behave as expected.

What are object-is's main functionalities?

Exact equality comparison

This feature allows for the comparison of two values to determine if they are exactly the same, including more accurate handling of special JavaScript cases like NaN and +/-0.

const objectIs = require('object-is');
console.log(objectIs('foo', 'foo')); // true
console.log(objectIs(window, window)); // true
console.log(objectIs('foo', 'bar')); // false
console.log(objectIs(0, -0)); // false
console.log(objectIs(NaN, NaN)); // true

Other packages similar to object-is

Changelog

Source

v1.1.6 - 2024-02-27

Commits

  • [actions] reuse common workflows f8d0c06
  • [actions] use node/install instead of node/run 90fc019
  • [actions] update workflows 37339d8
  • [meta] use npmignore to autogenerate an npmignore file a257c19
  • [readme] fix badges 50af053
  • [Dev Deps] update eslint, @ljharb/eslint-config, @es-shims/api, safe-publish-latest, tape 86058c6
  • [Dev Deps] update eslint, @ljharb/eslint-config, aud, auto-changelog, functions-have-names, has-symbols, tape d5484eb
  • [actions] update rebase action to use reusable workflow 68075c5
  • [actions] update codecov uploader f12fbb2
  • [Dev Deps] update eslint, @ljharb/eslint-config, aud, auto-changelog, has-symbols, tape 43eb235
  • [Dev Deps] update @es-shims/api, @ljharb/eslint-config, aud, npmignore, tape f306966
  • [readme] add actions and codecov badges e443b4a
  • [readme] remove travis badge 5165adc
  • [Dev Deps] update eslint, @ljharb/eslint-config, tape e7ccf56
  • [Deps] update call-bind, define-properties a3052db
  • [readme] fix URLs ac37ea6
  • [readme] assert.notOk -> assert.equal 7fe769f
  • [Deps] update call-bind b965cd3
  • [Dev Deps] update tape a737830
  • [Deps] update define-properties, es-abstract 441eafb

Readme

Source

object-is Version Badge

github actions coverage License Downloads

npm badge

ES2015-compliant shim for Object.is - differentiates between -0 and +0, and can compare to NaN.

Essentially, Object.is returns the same value as === - but true for NaN, and false for -0 and +0.

This package implements the es-shim API interface. It works in an ES3-supported environment and complies with the spec.

Example

Object.is = require('object-is');
var assert = require('assert');

assert.ok(Object.is());
assert.ok(Object.is(undefined));
assert.ok(Object.is(undefined, undefined));
assert.ok(Object.is(null, null));
assert.ok(Object.is(true, true));
assert.ok(Object.is(false, false));
assert.ok(Object.is('foo', 'foo'));

var arr = [1, 2];
assert.ok(Object.is(arr, arr));
assert.equal(Object.is(arr, [1, 2]), false);

assert.ok(Object.is(0, 0));
assert.ok(Object.is(-0, -0));
assert.equal(Object.is(0, -0), false);

assert.ok(Object.is(NaN, NaN));
assert.ok(Object.is(Infinity, Infinity));
assert.ok(Object.is(-Infinity, -Infinity));

Tests

Simply clone the repo, npm install, and run npm test

Keywords

FAQs

Last updated on 28 Feb 2024

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc