{"id":14637,"library":"isnumeric","title":"isNumeric","description":"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.","status":"abandoned","version":"0.3.3","language":"javascript","source_language":"en","source_url":"ssh://git@github.com/leecrossley/isNumeric","tags":["javascript","isnumeric","numeric","number"],"install":[{"cmd":"npm install isnumeric","lang":"bash","label":"npm"},{"cmd":"yarn add isnumeric","lang":"bash","label":"yarn"},{"cmd":"pnpm add isnumeric","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"This package is CommonJS-only, reflecting its age and last publish date.","symbol":"isNumeric","correct":"const isNumeric = require('isnumeric');"},{"note":"While Node.js can interop with CommonJS default exports, named imports (`{ isNumeric }`) will fail. This module does not provide explicit ESM exports.","wrong":"import { isNumeric } from 'isnumeric';","symbol":"isNumeric","correct":"import isNumeric from 'isnumeric';"}],"quickstart":{"code":"const isNumeric = require('isnumeric');\n\nconsole.log('--- Truthy Test Cases ---');\nconsole.log(`isNumeric(1): ${isNumeric(1)}`); // Expected: true\nconsole.log(`isNumeric(-1): ${isNumeric(-1)}`); // Expected: true\nconsole.log(`isNumeric(\"1\"): ${isNumeric(\"1\")}`); // Expected: true\nconsole.log(`isNumeric(\"0xFF\"): ${isNumeric(\"0xFF\")}`); // Expected: true (Hexadecimal string)\nconsole.log(`isNumeric(0144): ${isNumeric(0144)}`); // Expected: true (Octal literal, becomes 100 in decimal)\nconsole.log(`isNumeric(\"1.1\"): ${isNumeric(\"1.1\")}`); // Expected: true (Floating-point string)\nconsole.log(`isNumeric(\"3e5\"): ${isNumeric(\"3e5\")}`); // Expected: true (Exponential string)\nconsole.log(`isNumeric(\"1,1\"): ${isNumeric(\"1,1\")}`); // Expected: true (Decimal comma - unusual behavior)\n\nconsole.log('\\n--- Falsy Test Cases (inferred, as README only shows truthy) ---');\nconsole.log(`isNumeric('abc'): ${isNumeric('abc')}`); // Expected: false\nconsole.log(`isNumeric([]): ${isNumeric([])}`); // Expected: false\nconsole.log(`isNumeric({}): ${isNumeric({})}`); // Expected: false\nconsole.log(`isNumeric(null): ${isNumeric(null)}`); // Expected: false\nconsole.log(`isNumeric(undefined): ${isNumeric(undefined)}`); // Expected: false","lang":"javascript","description":"Demonstrates various numeric and non-numeric values, highlighting the package's broad interpretation of 'numeric' including string parsing and unique decimal comma handling."},"warnings":[{"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).","message":"The 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.","severity":"breaking","affected_versions":">=0.3.3"},{"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.","message":"The `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.","severity":"gotcha","affected_versions":">=0.1.0"},{"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.","message":"This 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.","severity":"gotcha","affected_versions":">=0.1.0"},{"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))`.","message":"The 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.","severity":"gotcha","affected_versions":">=0.1.0"}],"env_vars":null,"last_verified":"2026-04-19T00:00:00.000Z","next_check":"2026-07-18T00:00:00.000Z","problems":[{"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.","cause":"Attempting to use `require('isnumeric')` in a JavaScript file treated as an ES module (e.g., `\"type\": \"module\"` in `package.json`).","error":"ReferenceError: require is not defined in ES module scope"},{"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');`.","cause":"Incorrectly attempting a named ESM import (`import { isNumeric } from 'isnumeric';`) when the underlying module is CommonJS and only exports a default (or `module.exports = ...`).","error":"TypeError: (0 , isnumeric__WEBPACK_IMPORTED_MODULE_0__.isNumeric) is not a function"}],"ecosystem":"npm"}