How jonschlinkert/is-number works
Purpose and principal workflow
is-number is a small CommonJS library that determines whether an input is a finite number, accepting numeric primitives and non-blank numeric strings. The external JavaScript package consumer initiates the workflow by requiring the package and calling its exported predicate, which returns a boolean.
Components
Public predicate API — index.js
Exports the sole function, classifying the input by type, rejecting unsupported values, converting eligible strings with Number, and checking finiteness; this is the documented package entry point and implementation.
Package consumer — external, no repository path
Application code, user-input handling, parsers, or other JavaScript code that requires the package and supplies a value to the predicate.
JavaScript numeric runtime — external, no repository path
Provides typeof, string trim, unary numeric coercion, and either Number.isFinite or the global isFinite used by the implementation.
Relationships
• Package consumer -> Public predicate API: requires the package and calls the exported function; the package metadata identifies index.js as main.
• Public predicate API -> JavaScript numeric runtime: classifies values with typeof; accepts primitive numbers only when subtracting the value from itself yields zero, thereby rejecting NaN and infinities.
• Public predicate API -> JavaScript numeric runtime: trims strings and rejects blank strings before applying unary numeric coercion.
• Public predicate API -> JavaScript numeric runtime: checks coerced string results with Number.isFinite, falling back to global isFinite when unavailable.
• Public predicate API -> Package consumer: returns true for finite numeric numbers or numeric strings and false for unsupported, blank, nonnumeric, or non-finite inputs.
Coverage limits
The sampled repository contains only the package entry implementation and metadata; tests and benchmarks were excluded. No broader application orchestration, persistence, network interface, or runtime call-site behavior can be established.
Main entry points: index.js Numeric Predicate
Components 3
Public API
Documented package entry point and predicate implementation.
- Numeric Predicate · Classifies values as finite numbers or numeric strings.
index.js
External Runtime
Package consumer and JavaScript numeric facilities.
- Package Consumer · JavaScript code that requires the package and supplies a value.
- JavaScript Runtime · Provides type checks, trimming, coercion, and finiteness checks.
Connections 5
- Package Consumer → Numeric Predicate: calls predicate · Requires the package; package metadata identifies index.js as main.
- Numeric Predicate → JavaScript Runtime: classifies values · Uses typeof and self-subtraction to validate primitive numbers.
- Numeric Predicate → JavaScript Runtime: coerces strings · Trims strings, rejects blanks, and applies unary numeric coercion.
- Numeric Predicate → JavaScript Runtime: checks finiteness · Uses Number.isFinite or falls back to global isFinite.
- Numeric Predicate → Package Consumer: returns boolean · Returns true for finite numeric values and false otherwise.