Socket
Socket
Sign inDemoInstall

is-nan

Package Overview
Dependencies
14
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    is-nan

ES2015-compliant shim for Number.isNaN - the global isNaN returns false positives.


Version published
Weekly downloads
4.9M
decreased by-19.27%
Maintainers
1
Install size
152 kB
Created
Weekly downloads
 

Package description

What is is-nan?

The is-nan npm package is a simple utility that provides a reliable way to check if a value is NaN (Not-a-Number) in JavaScript. It is especially useful because it handles some edge cases that the global isNaN() function does not correctly address.

What are is-nan's main functionalities?

Check for NaN

This feature allows you to check if a value is NaN. It is more reliable than the native isNaN function because it correctly identifies only the values that are truly NaN, without coercion.

var isNaN = require('is-nan');
console.log(isNaN(NaN)); // true
console.log(isNaN('NaN')); // false
console.log(isNaN(0/0)); // true

Other packages similar to is-nan

Readme

Source

is-nan Version Badge

dependency status dev dependency status License Downloads

npm badge

ES2015-compliant shim for Number.isNaN - the global isNaN returns false positives.

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

Example

Number.isNaN = require('is-nan');
var assert = require('assert');

assert.notOk(Number.isNaN(undefined));
assert.notOk(Number.isNaN(null));
assert.notOk(Number.isNaN(false));
assert.notOk(Number.isNaN(true));
assert.notOk(Number.isNaN(0));
assert.notOk(Number.isNaN(42));
assert.notOk(Number.isNaN(Infinity));
assert.notOk(Number.isNaN(-Infinity));
assert.notOk(Number.isNaN('foo'));
assert.notOk(Number.isNaN(function () {}));
assert.notOk(Number.isNaN([]));
assert.notOk(Number.isNaN({}));

assert.ok(Number.isNaN(NaN));

Tests

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

Keywords

FAQs

Last updated on 24 Dec 2020

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