Ampersand.js Is Number Utility

1.0.1 · abandoned · verified Wed Apr 22

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.

Common errors

Warnings

Install

Imports

Quickstart

Demonstrates how to import and use the `isNumber` function to check various data types.

const isNumber = require('amp-is-number');

console.log('Is 123 a number?', isNumber(123));        // Expected: true
console.log('Is "456" a number?', isNumber('456'));    // Expected: true
console.log('Is "hello" a number?', isNumber('hello')); // Expected: false
console.log('Is null a number?', isNumber(null));      // Expected: false
console.log('Is undefined a number?', isNumber(undefined)); // Expected: false
console.log('Is NaN a number?', isNumber(NaN));        // Expected: false

// Example of usage in a conditional
function processValue(value) {
  if (isNumber(value)) {
    console.log(`Processing number: ${Number(value)}`);
  } else {
    console.log(`Value is not a recognized number: ${value}`);
  }
}

processValue('99.5');
processValue({});

view raw JSON →