Registry / serialization / isnumeric

isnumeric

JSON →
library0.3.3jsnpmunverified

The `isNumeric` package provides a utility function to determine if a given JavaScript object represents a numeric value. It's designed to be more permissive than standard JavaScript's `Number.isFinite()` or `isNaN()`, accepting various string representations of numbers, including integers, floating-points, octals (e.g., `0144`), hexadecimals (e.g., `0xFF`), and scientific notation (e.g., `3e5`). This package is currently at version 0.3.3 and was last published over 8 years ago, indicating it is no longer actively maintained. Its key differentiator is its broad interpretation of what constitutes a 'numeric' value, especially its handling of string inputs, which includes unusual parsing of 'decimal commas' (e.g., '1,1') that deviates from standard JavaScript number parsing. Given its abandonment, users might consider more modern, actively maintained alternatives or native `Number` methods for stricter validation.

npm install isnumeric
INSTALL
IMPORT
SIG · ISNUMERIC
I
isnumeric
serializationjavascriptv0.3.3
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

isNumeric
const isNumeric = require('isnumeric');
This package is CommonJS-only, reflecting its age and last publish date.
isNumeric
import isNumeric from 'isnumeric';
import { isNumeric } from 'isnumeric';
While Node.js can interop with CommonJS default exports, named imports (`{ isNumeric }`) will fail. This module does not provide explicit ESM exports.

Demonstrates various numeric and non-numeric values, highlighting the package's broad interpretation of 'numeric' including string parsing and unique decimal comma handling.

const isNumeric = require('isnumeric'); console.log('--- Truthy Test Cases ---'); console.log(`isNumeric(1): ${isNumeric(1)}`); // Expected: true console.log(`isNumeric(-1): ${isNumeric(-1)}`); // Expected: true console.log(`isNumeric("1"): ${isNumeric("1")}`); // Expected: true console.log(`isNumeric("0xFF"): ${isNumeric("0xFF")}`); // Expected: true (Hexadecimal string) console.log(`isNumeric(0144): ${isNumeric(0144)}`); // Expected: true (Octal literal, becomes 100 in decimal) console.log(`isNumeric("1.1"): ${isNumeric("1.1")}`); // Expected: true (Floating-point string) console.log(`isNumeric("3e5"): ${isNumeric("3e5")}`); // Expected: true (Exponential string) console.log(`isNumeric("1,1"): ${isNumeric("1,1")}`); // Expected: true (Decimal comma - unusual behavior) console.log('\n--- Falsy Test Cases (inferred, as README only shows truthy) ---'); console.log(`isNumeric('abc'): ${isNumeric('abc')}`); // Expected: false console.log(`isNumeric([]): ${isNumeric([])}`); // Expected: false console.log(`isNumeric({}): ${isNumeric({})}`); // Expected: false console.log(`isNumeric(null): ${isNumeric(null)}`); // Expected: false console.log(`isNumeric(undefined): ${isNumeric(undefined)}`); // Expected: false
Debug
Known issues
breakingThe package `isnumeric` is no longer actively maintained, with its last publish date being over 8 years ago. This means it will not receive updates for new JavaScript features, bug fixes, or security vulnerabilities. It is highly recommended to migrate to an actively maintained alternative.
fix
Evaluate alternatives like `Number.isFinite()`, `parseFloat()`, `Number.isNaN()`, or well-maintained third-party libraries (`is-number` by jonschlinkert, or `lodash.isnumber` if using Lodash).
affects: >=0.3.3
gotchaThe `isNumeric` function considers strings with decimal commas (e.g., `"1,1"`) as numeric and returns `true`. This behavior is non-standard in JavaScript's `Number` parsing (`parseFloat("1,1")` would return `1`) and can lead to unexpected results, particularly in internationalized applications where commas are used as thousands separators, not decimal points, or where strictly numeric input is expected.
fix
Be aware of this specific behavior. If standard JavaScript numeric parsing is required, avoid `isNumeric` or implement custom validation for such strings. Consider using `Number.parseFloat(value.replace(',', '.'))` for explicit decimal handling in locales that use commas for decimals.
affects: >=0.1.0
gotchaThis package is a CommonJS (CJS) module and does not officially support ES Modules (ESM). While Node.js can sometimes interop, direct named ESM imports (`import { isNumeric } from 'isnumeric';`) will fail. Default ESM imports (`import isNumeric from 'isnumeric';`) might work but rely on Node.js's CJS compatibility layer.
fix
For Node.js environments, use `const isNumeric = require('isnumeric');`. For browser or modern ESM-only environments, a build step (e.g., Webpack, Rollup) might be required to bundle CJS modules, or preferably, migrate to an ESM-native alternative.
affects: >=0.1.0
gotchaThe definition of 'numeric' used by `isNumeric` is very broad, including various string formats (octal, hexadecimal, exponential). This is distinct from stricter checks like `Number.isFinite()` which only considers actual `number` primitives that are finite. Relying on `isNumeric` might allow values that are not suitable for mathematical operations without further explicit type coercion and validation.
fix
Understand the full range of values that `isNumeric` considers true. If strict numerical validation or finite number checks are needed, combine `isNumeric` with `Number.isFinite()` or directly use `Number.isFinite(parseFloat(value))`.
affects: >=0.1.0
Errors
Common errors & fixes
ReferenceError: require is not defined in ES module scope
Attempting to use `require('isnumeric')` in a JavaScript file treated as an ES module (e.g., `"type": "module"` in `package.json`).
fix
For CommonJS modules in an ES module environment, you typically need to use `import { createRequire } from 'module'; const require = createRequire(import.meta.url); const isNumeric = require('isnumeric');` or migrate to an ESM-compatible library.
TypeError: (0 , isnumeric__WEBPACK_IMPORTED_MODULE_0__.isNumeric) is not a function
Incorrectly attempting a named ESM import (`import { isNumeric } from 'isnumeric';`) when the underlying module is CommonJS and only exports a default (or `module.exports = ...`).
fix
If using ESM syntax, try importing as a default: `import isNumeric from 'isnumeric';`. If this still causes issues, or if in a CJS context, revert to `const isNumeric = require('isnumeric');`.
Upgrade
Version history
0.3.3latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
4 hits · last 30 days
node
4
Resources