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.
is-negative-zero
Advanced tools
The is-negative-zero npm package is a utility that provides a simple function to check if a given number is -0. In JavaScript, -0 and +0 are considered distinct values (due to IEEE 754 floating point), and this package helps in identifying if a number is specifically -0.
Check if a number is -0
This feature allows you to check if a given number is exactly -0. It returns true if the number is -0, and false otherwise. This can be particularly useful in mathematical computations and graphics programming where the distinction between -0 and +0 can have implications.
const isNegativeZero = require('is-negative-zero');
console.log(isNegativeZero(-0)); // true
console.log(isNegativeZero(0)); // false
console.log(isNegativeZero(-1)); // false
Similar to is-negative-zero, is-zero is a utility for checking if a number is 0. However, it does not distinguish between -0 and +0, making it less specific for cases where the sign of zero matters.
While not specifically designed for checking -0, lodash's isEqual function can accurately compare -0 and +0, among many other complex equality checks. It's more versatile but also much larger and more complex than is-negative-zero, which is focused solely on the -0 check.
Is this value negative zero? === will lie to you.
var isNegativeZero = require('is-negative-zero');
var assert = require('assert');
assert.notOk(isNegativeZero(undefined));
assert.notOk(isNegativeZero(null));
assert.notOk(isNegativeZero(false));
assert.notOk(isNegativeZero(true));
assert.notOk(isNegativeZero(0));
assert.notOk(isNegativeZero(42));
assert.notOk(isNegativeZero(Infinity));
assert.notOk(isNegativeZero(-Infinity));
assert.notOk(isNegativeZero(NaN));
assert.notOk(isNegativeZero('foo'));
assert.notOk(isNegativeZero(function () {}));
assert.notOk(isNegativeZero([]));
assert.notOk(isNegativeZero({}));
assert.ok(isNegativeZero(-0));
Simply clone the repo, npm install
, and run npm test
v2.0.1 - 2020-12-04
5b92482
node
v11.7
, v10.15
, v9.11
, v8.15
, v7.10
, v6.16
, v5.12
, v4.9
; use nvm install-latest-npm
; fix test scripts 0f5d2f8
b80f05a
jscs
7ccaf41
992bdde
80fd18d
nyc
on all tests df26f14
tape
, jscs
, eslint
, @ljharb/eslint-config
d7723aa
eslint
, @ljharb/eslint-config
, aud
, auto-changelog
, tape
9fdaabe
eslint
, @ljharb/eslint-config
, covert
, tape
f07eeb2
tape
, jscs
, eslint
, @ljharb/eslint-config
bd5c751
5666a91
auto-changelog
f70fb2b
2b040a8
eslint
, @ljharb/eslint-config
, tape
; add safe-publish-latest
09e2e53
npm audit
instead of nsp
7df2669
io.js
v3.3
, node
v4.1
4ff97c5
eslint
, @ljharb/eslint-config
, aud
, auto-changelog
9e8cb7b
jscs
, eslint
, @ljharb/eslint-config
, nsp
70b9888
jscs
59d0c42
npm run security
eb418ed
eslint
, @ljharb/eslint-config
, tape
86a758d
a0ab621
npx aud
instead of nsp
or npm audit
with hoops 5c51349
funding
field 1d0b2f4
pull_request_target
event 9b12367
auto-changelog
, tape
6d98b8d
tape
, eslint
a258cdb
auto-changelog
; add aud
2ca2afb
io.js
v3.0
1254ae8
auto-changelog
4b54722
86d298b
tape
3a47e27
128d9bd
FAQs
Is this value negative zero? === will lie to you
The npm package is-negative-zero receives a total of 24,359,452 weekly downloads. As such, is-negative-zero popularity was classified as popular.
We found that is-negative-zero 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.