The `isNumber` package provides a minimal, single-line utility function to determine if a value represents a finite number. Currently at version 1.0.0, this package is highly stable with an extremely infrequent release cadence, reflecting its narrow and well-defined scope (last published 13 years ago). Its key differentiator lies in its approach to type coercion: unlike `Number.isFinite()` which strictly checks the type, `isNumber` uses `parseFloat()` to first attempt to parse the input into a number. It then verifies that the parsed result is a finite number and not `NaN`. This makes it suitable for scenarios where number-like strings (e.g., "123.45") should be treated as valid numbers, but it also introduces specific behaviors for other complex types that are not strictly numbers or strings.
npm install isnumberVerified import paths — ran on the pinned version, not inferred.
Demonstrates `isNumber` with various inputs, highlighting its string parsing and unique handling of single-element arrays.
If strict type checking for `number` primitives is required, use `typeof value === 'number' && Number.isFinite(value)` instead. Understand the `parseFloat()` behavior for non-string/non-number inputs if you intend to use `isNumber`.
Choose the utility that matches your intended coercion behavior. For strict type and value checking, use `Number.isFinite()`. For forgiving string-to-number parsing, `isNumber` is appropriate.
Evaluate newer, similar packages like `is-number` (by jonschlinkert or ultirequiem) which offer more recent updates, broader test coverage, or specific type-guard features, or rely on built-in `Number.isFinite()` and explicit parsing functions.
Change the import statement to `import isNumber from 'isnumber';` to correctly import the default export.
For ESM environments, use `import isNumber from 'isnumber';`. If you must use `require` in ESM, consider a CommonJS wrapper or a bundler that handles interoperability.
No dependency data recorded yet.