{"id":17150,"library":"amp-is-number","title":"Ampersand.js Is Number Utility","description":"amp-is-number is a small, focused utility function originally developed as part of the Ampersand.js ecosystem. It provides a straightforward method to determine if a given JavaScript value is a number, including numeric strings, consistent with the logic prevalent in projects from the mid-2010s. Ampersand.js itself was a modular, Backbone.js-inspired framework, and `amp-is-number` was one of many atomic modules designed for composability. The package is at version 1.0.1, which appears to be its final release. There is no active development or release cadence for this specific utility, nor for the broader Ampersand.js project, which is considered abandoned. This package exclusively uses CommonJS module syntax, reflecting the standard module patterns of its era, and it lacks explicit support for modern ECMAScript modules (ESM). It differs from more recent `is-number` implementations by not necessarily incorporating newer JavaScript language features or edge case handling, instead focusing on the behavior expected within its original framework context.","status":"abandoned","version":"1.0.1","language":"javascript","source_language":"en","source_url":"git://github.com/ampersandjs/amp","tags":["javascript","amp","util","utils"],"install":[{"cmd":"npm install amp-is-number","lang":"bash","label":"npm"},{"cmd":"yarn add amp-is-number","lang":"bash","label":"yarn"},{"cmd":"pnpm add amp-is-number","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"This package is CommonJS-only. Direct ESM imports like `import ... from 'amp-is-number'` will fail in native ESM environments. Use `require()` or dynamic `import()` for ESM interoperability.","wrong":"import { isNumber } from 'amp-is-number';","symbol":"isNumber","correct":"const isNumber = require('amp-is-number');"},{"note":"When using dynamic import() in an ESM context, CommonJS modules are imported as a module namespace object, where the default export is the `module.exports` value.","symbol":"isNumber (dynamic import)","correct":"const isNumber = await import('amp-is-number');\nconst result = isNumber.default(123);"}],"quickstart":{"code":"const isNumber = require('amp-is-number');\n\nconsole.log('Is 123 a number?', isNumber(123));        // Expected: true\nconsole.log('Is \"456\" a number?', isNumber('456'));    // Expected: true\nconsole.log('Is \"hello\" a number?', isNumber('hello')); // Expected: false\nconsole.log('Is null a number?', isNumber(null));      // Expected: false\nconsole.log('Is undefined a number?', isNumber(undefined)); // Expected: false\nconsole.log('Is NaN a number?', isNumber(NaN));        // Expected: false\n\n// Example of usage in a conditional\nfunction processValue(value) {\n  if (isNumber(value)) {\n    console.log(`Processing number: ${Number(value)}`);\n  } else {\n    console.log(`Value is not a recognized number: ${value}`);\n  }\n}\n\nprocessValue('99.5');\nprocessValue({});","lang":"javascript","description":"Demonstrates how to import and use the `isNumber` function to check various data types."},"warnings":[{"fix":"For ESM environments, use `const isNumber = await import('amp-is-number');` and access the function via `isNumber.default()`, or configure your build system (e.g., Webpack, Rollup) to handle CommonJS modules.","message":"This package is CommonJS-only (uses `module.exports`). It does not provide an ESM export and will cause a `TypeError: require is not a function` error if directly imported in a pure ES Module environment without a CommonJS wrapper or bundler transpilation.","severity":"breaking","affected_versions":"1.0.1"},{"fix":"For new projects, consider using native `Number.isFinite()` or a more modern, actively maintained `is-number` utility package if its specific string-to-number coercion behavior is not strictly required. For existing projects, be aware of its unmaintained status.","message":"The Ampersand.js project, including `amp-is-number`, is no longer actively maintained. Expect no further updates, bug fixes, or security patches. While simple, its implementation might not cover modern JavaScript edge cases or optimizations found in newer utility libraries.","severity":"gotcha","affected_versions":"1.0.1"},{"fix":"Review the source code of `amp-is-number` if precise behavior for edge cases is critical for your application to ensure it aligns with expectations. Consider migrating to `Number.isFinite()` or a modern alternative if a more standard or robust number check is needed.","message":"The logic for determining a 'number' might differ subtly from `Number.isFinite()` or other popular `is-number` libraries, especially regarding whitespace-only strings, `null`, or `NaN`. It was designed for the Ampersand.js ecosystem's specific needs.","severity":"gotcha","affected_versions":"1.0.1"}],"env_vars":null,"last_verified":"2026-04-22T00:00:00.000Z","next_check":"2026-07-21T00:00:00.000Z","problems":[{"fix":"If in an ESM file, use `await import('amp-is-number')` and access the default export: `(await import('amp-is-number')).default(value)`. Alternatively, switch your file to CommonJS if possible, or ensure your build tools are correctly transpiling.","cause":"Attempting to use `require()` in an ECMAScript Module (ESM) file, or importing a CommonJS module (like `amp-is-number`) directly with `import` in a native ESM environment without proper interoperability handling.","error":"TypeError: require is not a function"}],"ecosystem":"npm","meta_description":null}