{"id":15688005,"url":"https://github.com/ultirequiem/is-number","last_synced_at":"2025-07-08T12:08:39.519Z","repository":{"id":39544589,"uuid":"410700927","full_name":"UltiRequiem/is-number","owner":"UltiRequiem","description":"🧵 Check if something is a number","archived":false,"fork":false,"pushed_at":"2024-05-01T00:16:14.000Z","size":46,"stargazers_count":8,"open_issues_count":1,"forks_count":3,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-07-06T05:45:00.828Z","etag":null,"topics":["deno","denoland","javascript","typescript"],"latest_commit_sha":null,"homepage":"https://is-number.js.org","language":"TypeScript","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/UltiRequiem.png","metadata":{"files":{"readme":"readme.md","changelog":null,"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":"2021-09-27T01:04:00.000Z","updated_at":"2023-03-07T04:28:54.000Z","dependencies_parsed_at":"2023-02-18T16:25:13.740Z","dependency_job_id":"4d8fb0df-e545-4936-9f4b-00259236e960","html_url":"https://github.com/UltiRequiem/is-number","commit_stats":{"total_commits":40,"total_committers":3,"mean_commits":"13.333333333333334","dds":0.275,"last_synced_commit":"5d4af04ccc5a6d9610e170fae1f822355a42e0f3"},"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"purl":"pkg:github/UltiRequiem/is-number","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/UltiRequiem%2Fis-number","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/UltiRequiem%2Fis-number/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/UltiRequiem%2Fis-number/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/UltiRequiem%2Fis-number/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/UltiRequiem","download_url":"https://codeload.github.com/UltiRequiem/is-number/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/UltiRequiem%2Fis-number/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264225766,"owners_count":23575854,"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":["deno","denoland","javascript","typescript"],"created_at":"2024-10-03T17:53:11.730Z","updated_at":"2025-07-08T12:08:39.503Z","avatar_url":"https://github.com/UltiRequiem.png","language":"TypeScript","funding_links":["https://patreon.com/UltiRequiem"],"categories":[],"sub_categories":[],"readme":"# is-number\n\n[![Code Coverage](https://codecov.io/gh/ultirequiem/is-number/branch/main/graph/badge.svg)](https://codecov.io/gh/ultirequiem/is-number)\n[![Deno Doc](https://doc.deno.land/badge.svg)](https://doc.deno.land/https/deno.land/x/is_number/mod.ts)\n\nIn JavaScript, it's not always as straightforward as it should be to reliably\ncheck if a value is a number. It's common for devs to use `+`, `-`, or\n`Number()` to cast a string value to a number (for example, when values are\nreturned from user input, regex matches, parsers, etc). But there are many\nnon-intuitive edge cases that yield unexpected results:\n\n```javascript\nconsole.log(+[]); //=\u003e 0\nconsole.log(+\"\"); //=\u003e 0\nconsole.log(+\"   \"); //=\u003e 0\nconsole.log(typeof NaN); //=\u003e 'number'\n```\n\n## Usage\n\n### [Deno 🦕](https://deno.land/x/is_number)\n\n```javascript\nimport { assertIsNumber, isNumber } from \"https://deno.land/x/is_number/mod.ts\";\n\nisNumber(\"hello\"); //=\u003e false\nisNumber(\"678\"); //=\u003e true\nisNumber({}); //=\u003e false\nisNumber(+{ a: \"34\" }); //=\u003e false\nisNumber(345); //=\u003e true\n\nassertIsNumber([123]); //=\u003e throws\nassertIsNumber({}); //=\u003e throws\nassertIsNumber(34); //=\u003e doesn't throws\n```\n\n### [Node.js 🐢](https://npmjs.com/package/@ultirequiem/is-number)\n\n```javascript\nimport { assertIsNumber, isNumber } from \"@ultirequiem/is-number\";\n```\n\n### Browser\n\nYou can use any [CDN](https://en.wikipedia.org/wiki/Content_delivery_network) 🔥\n\nEg. [ESM](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules)\n▶ [SkyPack](https://cdn.skypack.dev/@ultirequiem/is-number) _/_\n[script tag](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script) ▶\n[JSDelivr](https://cdn.jsdelivr.net/npm/@ultirequiem/is-number).\n\n_The API is the same on all this platforms._\n\n## Documentation\n\n[Autogenerated Documentation](https://doc.deno.land/https://deno.land/x/is_number/mod.ts)\n\nIncludes\n[TypeScript type guards](https://www.typescriptlang.org/docs/handbook/2/narrowing.html#using-type-predicates),\nso using it will narrow the type of previously-unknown values.\n\n```javascript\nexport function isEven(n: unknown): boolean {\n  n++ // Error, n is not a number\n\n  assertIsNumber(n);\n\n  return n % 2 === 0; // OK\n}\n```\n\n### True Cases\n\n```javascript\nisNumber(5e3);\nisNumber(0xff);\nisNumber(-1.1);\nisNumber(0);\nisNumber(1);\nisNumber(1.1);\nisNumber(10);\nisNumber(10.1);\nisNumber(100);\nisNumber(\"-1.1\");\nisNumber(\"0\");\nisNumber(\"012\");\nisNumber(\"0xff\");\nisNumber(\"1\");\nisNumber(\"1.1\");\nisNumber(\"10\");\nisNumber(\"10.10\");\nisNumber(\"100\");\nisNumber(\"5e3\");\nisNumber(parseInt(\"012\"));\nisNumber(parseFloat(\"012\"));\n```\n\n### False cases\n\nEverything else is false.\n\n```javascript\nisNumber(Infinity);\nisNumber(NaN);\nisNumber(null);\nisNumber(undefined);\nisNumber(\"\");\nisNumber(\"   \");\nisNumber(\"foo\");\nisNumber([1]);\nisNumber([]);\nisNumber(function () {});\nisNumber({});\n```\n\nSee the [tests](./mod_test.ts) for more examples.\n\n## CLI Tool\n\nWas done mainly as usage example.\n\n### Install\n\n- Node.js 🦍\n\n```sh\nnpm install -g @ultirequiem/is-number\n```\n\n- Deno 🦕\n\n```sh\ndeno install https://deno.land/x/is_number/is-number.ts\n```\n\n### Usage\n\n```sh\nis-number 1 2 hey\ntrue\ntrue\nfalse\n```\n\nOr with the verbose flag 👇\n\n```sh\nis-number 1 2 hey --verbose\n\"1\" is a number? true\n\"2\" is a number? true\n\"hey\" is a number? false\n```\n\n## Support\n\nOpen an Issue, I will check it a soon as possible 👀\n\nIf you want to hurry me up a bit\n[send me a tweet](https://twitter.com/intent/tweet?text=%40UltiRequiem%20) 😆\n\nConsider [supporting me on Patreon](https://patreon.com/UltiRequiem) if you like\nmy work 🚀\n\nDon't forget to star the repo ⭐\n\n## Versioning\n\nWe use [SemVer](http://semver.org) for versioning. For the versions available,\nsee the [tags](https://github.com/UltiRequiem/is-number/tags).\n\n## Authors\n\n[Eliaz Bobadilla (a.k.a UltiRequiem)](https://ultirequiem.com) - Creator and\nMaintainer 💪\n\nSee also the full list of\n[contributors](https://github.com/UltiRequiem/is-number/contributors) who\nparticipated in this project.\n\n## Licence\n\nLicensed under the MIT License.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fultirequiem%2Fis-number","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fultirequiem%2Fis-number","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fultirequiem%2Fis-number/lists"}