Security News
Introducing the Socket Python SDK
The initial version of the Socket Python SDK is now on PyPI, enabling developers to more easily interact with the Socket REST API in Python projects.
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.
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
A package that offers deep equality comparison. Unlike 'object-is', which only checks if two values are the same, 'is-equal' can compare objects and arrays deeply, making it suitable for more complex data structures.
This package also provides deep equality checks, similar to 'is-equal'. It compares the contents of objects and arrays recursively, which is more comprehensive than the simple value comparison provided by 'object-is'.
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.
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.notOk(Object.is(arr, [1, 2]));
assert.ok(Object.is(0, 0));
assert.ok(Object.is(-0, -0));
assert.notOk(Object.is(0, -0));
assert.ok(Object.is(NaN, NaN));
assert.ok(Object.is(Infinity, Infinity));
assert.ok(Object.is(-Infinity, -Infinity));
Simply clone the repo, npm install
, and run npm test
v1.1.4 - 2020-11-26
958ab26
shimmed
and implementation
and index
tests; run es-shim-api
in postlint; use tape
runner b918fb8
nyc
on all tests 8f62816
aa419f0
call-bind
instead of es-abstract
4991728
eslint
, @ljharb/eslint-config
, aud
3ce2ef5
d778383
pull_request_target
event e0d9b41
FAQs
ES2015-compliant shim for Object.is - differentiates between -0 and +0
The npm package object-is receives a total of 15,565,832 weekly downloads. As such, object-is popularity was classified as popular.
We found that object-is demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
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.
Security News
The initial version of the Socket Python SDK is now on PyPI, enabling developers to more easily interact with the Socket REST API in Python projects.
Security News
Floating dependency ranges in npm can introduce instability and security risks into your project by allowing unverified or incompatible versions to be installed automatically, leading to unpredictable behavior and potential conflicts.
Security News
A new Rust RFC proposes "Trusted Publishing" for Crates.io, introducing short-lived access tokens via OIDC to improve security and reduce risks associated with long-lived API tokens.