{"id":28365326,"url":"https://github.com/toolbuilder/isnumber","last_synced_at":"2025-06-24T11:32:26.349Z","repository":{"id":57167186,"uuid":"203218907","full_name":"toolbuilder/isnumber","owner":"toolbuilder","description":"Well tested 'is number' checks, that can accept number-like strings, and non-finite values as desired.","archived":false,"fork":false,"pushed_at":"2024-11-09T02:06:22.000Z","size":778,"stargazers_count":0,"open_issues_count":7,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-11T14:59:40.520Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/toolbuilder.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-08-19T17:28:47.000Z","updated_at":"2024-11-09T02:06:26.000Z","dependencies_parsed_at":"2024-12-09T09:05:49.134Z","dependency_job_id":null,"html_url":"https://github.com/toolbuilder/isnumber","commit_stats":{"total_commits":21,"total_committers":1,"mean_commits":21.0,"dds":0.0,"last_synced_commit":"8b07e3840e9bd1f10b1cb4f160ccb5681425e495"},"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"purl":"pkg:github/toolbuilder/isnumber","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/toolbuilder%2Fisnumber","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/toolbuilder%2Fisnumber/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/toolbuilder%2Fisnumber/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/toolbuilder%2Fisnumber/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/toolbuilder","download_url":"https://codeload.github.com/toolbuilder/isnumber/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/toolbuilder%2Fisnumber/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261304246,"owners_count":23138294,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-05-28T21:10:38.002Z","updated_at":"2025-06-24T11:32:26.341Z","avatar_url":"https://github.com/toolbuilder.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# IsNumber\n\nWell tested 'is number' checks, that can accept number-like strings, and non-finite values as desired.\n\nThere are a lot of `is number` tests out there. Many of them don't work quite right. Others use a different\ndefinition of `is number` than you might want. So after spending way too much time for such a simple thing,\nhere are four checks:\n\n|Function        |number literals|number-like strings|Infinity and NaN|Infinity and NaN strings|other strings|\n|----------------|---------------|-------------------|----------------|------------------------|-------------|\n|isNumeric       |true           |true               |true            |true                    |false        |\n|isNumber        |true           |false              |true            |false                   |false        |\n|isFiniteNumeric |true           |true               |false           |false                   |false        |\n|isFiniteNumber  |true           |false              |false           |false                   |false        |\n\n## Table of Contents\n\n\u003c!-- !toc (minlevel=2 omit=\"Features;Table of Contents\") --\u003e\n\n* [Installation](#installation)\n* [Getting Started](#getting-started)\n* [API](#api)\n  * [isNumber](#isnumber-1)\n  * [isNumeric](#isnumeric)\n  * [isFiniteNumber](#isfinitenumber)\n  * [isFiniteNumeric](#isfinitenumeric)\n* [Credits](#credits)\n* [Contributing](#contributing)\n* [Issues](#issues)\n* [License](#license)\n\n\u003c!-- toc! --\u003e\n\n## Installation\n\n```bash\nnpm install --save @toolbuilder/isnumber\n```\n\n## Getting Started\n\nThis is a [dual package](https://nodejs.org/dist/latest-v14.x/docs/api/packages.html#packages_dual_commonjs_es_module_packages),\nso named exports are available for both CommonJS and ES modules.\n\n```javascript\nimport { isNumeric, isFiniteNumeric, isNumber, isFiniteNumber } from '@toolbuilder/isnumber'\n\nconsole.log(isNumeric('1.234')) // true because it looks like a number\nconsole.log(isFiniteNumeric(42.54)) // true\nconsole.log(isNumber('1.234')) // false because it is a string\nconsole.log(isFiniteNumber(-Infinity)) // false\n```\n\n## API\n\nAPI documentation follows.\n\n\u003c!-- include (api.md) --\u003e\n\u003c!-- Generated by documentation.js. Update this documentation by updating the source code. --\u003e\n\n### isNumber\n\nTest if n is a number.\n\nIncludes Infinities and NaN, does not include strings that look like numbers\n\nParameters:\n\n* `n` **any** value to test\n\n\n\n```javascript\nisNumber(1.23) // true\nisNumber(Infinity) // true\nisNumber(NaN) // true\nisNumber('1.23') // false\n```\n\nReturns **[boolean][1]** true if is number, false otherwise\n\n### isNumeric\n\nTest if n is a number, or string that parses to a number. Includes infinities and NaN.\n\nNon-finite strings are: 'Infinity', '-Infinity', and 'NaN'.\n\nParameters:\n\n* `n` **any** value to test\n\n\n\n```javascript\nisNumeric(1.23) // true\nisNumeric('Infinity') // true\nisNumeric(NaN) // true\nisNumeric('1.23') // true\nisNumeric('hi') // false\n```\n\nReturns **[boolean][1]** true if is numeric, false otherwise\n\n### isFiniteNumber\n\nTest if n is a finite number.\n\nDoes not include infinities, NaN, or strings that look like numbers.\n\nParameters:\n\n* `n` **any** value to test\n\n\n\n```javascript\nisFiniteNumber(1.23) // true\nisFiniteNumber(Infinity) // false\nisFiniteNumber(NaN) // false\nisFiniteNumber('1.23') // false\n```\n\nReturns **[boolean][1]** true if is a finite number, false otherwise\n\n### isFiniteNumeric\n\nTest if n is a finite number, or string that parses to a finite number.\n\nDoes not include infinities, NaN\n\nParameters:\n\n* `n` **any** value to test\n\n\n\n```javascript\nisFiniteNumeric(1.23) // true\nisFiniteNumeric('Infinity') // false\nisFiniteNumeric(NaN) // false\nisFiniteNumeric('1.23') // true\nisFiniteNumeric('hi') // false\n```\n\nReturns **[boolean][1]** true if is a finite number, false otherwise\n\n[1]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean\n\u003c!-- /include --\u003e\n\n## Credits\n\nThe `isFiniteNumeric` implementation, and the most of the tests were copied from this\n[site](http://run.plnkr.co/plunks/93FPpacuIcXqqKMecLdk/). I found these tests on Stack Overflow\nin an [answer](https://stackoverflow.com/questions/18082/validate-decimal-numbers-in-javascript-isnumeric) by 'CMS'. Thanks!\n\n## Contributing\n\nContributions are welcome. Please create a pull request.\n\n* I use [pnpm](https://pnpm.js.org/) instead of npm.\n* Run the unit tests with `pnpm test`\n* Package verification requires [pnpm](https://pnpm.io/) to be installed globally.\n  * `npm install -g pnpm`\n  * `pnpm install`\n  * `pnpm build` to build cjs, docs, and *.d.ts\n  * `pnpm run check:packfile` to test against ES and CommonJS projects, as well as Electron\n  * `pnpm run check` to validate the package is ready for commit\n\n## Issues\n\nThis project uses Github issues.\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftoolbuilder%2Fisnumber","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftoolbuilder%2Fisnumber","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftoolbuilder%2Fisnumber/lists"}