
Security News
Open Source CAI Framework Handles Pen Testing Tasks up to 3,600× Faster Than Humans
CAI is a new open source AI framework that automates penetration testing tasks like scanning and exploitation up to 3,600× faster than humans.
is-number-strict
Advanced tools
Tiny lib to check if passed argument is strictly number. Strings will not pass!
Designed to strictly check if the value is a number. Works with Number objects, hex, and so on. Returns false
for string
and other not numbers like {}
, undefined
, NaN
npm i is-number-strict
JavaScript with require syntax
const isNumber = require('is-number-strict').default;
console.assert(isNumber(5));
console.assert(!isNumber('5'));
JavaScript with import syntax
import isNumber from "is-number-strict";
console.assert(isNumber(5));
console.assert(!isNumber('5'));
This tiny lib tries to make type assertion little bit more predictable and remove NaN from your calculations.
typeof new Number(42);
> 'object'
But it is working as good old number
new Number(5) * new Number(6);
> 30
So:
isNumberStrict(new Number(5));
> true
But:
isNumberStrict('5');
> false
And
isNumberStrict(NaN);
> false
Why didn't you treat '5' as a number? '5' + 5 = 10! Yes, but 5 + '5' = '55' and 5 * '5' = NaN. I don't want to see NaN or '55' in my calculations.
So if you want to have more predictable type checking - check my tests and welcome!
Why do you treat new Number([]) as a number?
Because JS will evaluate it to 0, and 0 is number.
Why do you treat new number({}) as not a number?
Because JS will evaluate it to NaN and NaN is not a number according to my purposes.
FAQs
Tiny lib to check if passed argument is strictly number. Strings will not pass!
We found that is-number-strict demonstrated a not healthy version release cadence and project activity because the last version was released 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
CAI is a new open source AI framework that automates penetration testing tasks like scanning and exploitation up to 3,600× faster than humans.
Security News
Deno 2.4 brings back bundling, improves dependency updates and telemetry, and makes the runtime more practical for real-world JavaScript projects.
Security News
CVEForecast.org uses machine learning to project a record-breaking surge in vulnerability disclosures in 2025.