{"id":24079879,"url":"https://github.com/hypersoftllc/qc-to_num","last_synced_at":"2025-08-01T10:37:31.759Z","repository":{"id":65371664,"uuid":"90197771","full_name":"hypersoftllc/qc-to_num","owner":"hypersoftllc","description":"A simple JavaScript utility to convert various value to a number.","archived":false,"fork":false,"pushed_at":"2017-06-02T17:48:37.000Z","size":18,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"develop","last_synced_at":"2025-07-06T10:42:41.778Z","etag":null,"topics":["javascript-utility"],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hypersoftllc.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}},"created_at":"2017-05-03T22:13:17.000Z","updated_at":"2017-05-16T14:31:26.000Z","dependencies_parsed_at":"2023-01-19T22:55:19.295Z","dependency_job_id":null,"html_url":"https://github.com/hypersoftllc/qc-to_num","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/hypersoftllc/qc-to_num","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hypersoftllc%2Fqc-to_num","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hypersoftllc%2Fqc-to_num/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hypersoftllc%2Fqc-to_num/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hypersoftllc%2Fqc-to_num/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hypersoftllc","download_url":"https://codeload.github.com/hypersoftllc/qc-to_num/tar.gz/refs/heads/develop","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hypersoftllc%2Fqc-to_num/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268207662,"owners_count":24213023,"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","status":"online","status_checked_at":"2025-08-01T02:00:08.611Z","response_time":67,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["javascript-utility"],"created_at":"2025-01-09T22:26:11.069Z","updated_at":"2025-08-01T10:37:31.693Z","avatar_url":"https://github.com/hypersoftllc.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# qc-to_num\n\n[![Build Status][travis-svg]][travis-url]\n[![Coverage Status][coverage-image]][coverage-url]\n[![License][license-image]][license-url]\n[![Downloads][downloads-image]][downloads-url]\n\n[![npm badge][npm-badge-png]][package-url]\n\nA simple JavaScript utility to convert various values to a number.\n\n**What it does that `parseFloat` doesn't**\n\n* Allow a default value to be set instead of returning `NaN`.\n* Convert `'-0'` to `0` instead of `-0`.\n* Allow an input with a valueOf function to supply the convertible value.\n\n**What it does that `new Number` doesn't**\n\n* Won't return a `Number` instance.\n* Allow a default value to be set instead of returning `NaN`.\n* Convert `'-0'` to `0` instead of `-0`.\n\n**What it does that `Number` doesn't**\n\n* Allow a default value to be set instead of returning `NaN`.\n* Convert `'-0'` to `0` instead of `-0`.\n\n\n## Installation\n\n```sh\nnpm install --save qc-to_num\n```\n\n\n## Example Usage\n\n```js\nimport { toNum, toNumOrNull } from 'qc-to_num';\n\ntoNum('+3.1459');                            // `3.1459`\ntoNum('2');                                  // `2`\ntoNum(2.6);                                  // `2.6`\ntoNum(1.2);                                  // `1.2`\ntoNum(1);                                    // `1`\ntoNum(-1);                                   // `-1`\ntoNum(-2.6);                                 // `-2.6`\ntoNum({ valueOf() { return 42; } });         // `42`\ntoNum({ valueOf() { return '42'; } });       // `42`\n\ntoNum(\u003cinconvertible\u003e);                      // The inconvertible input\ntoNum(\u003cinconvertible\u003e, undefined);           // The inconvertible input\ntoNum(\u003cinconvertible\u003e, { def: undefined });  // The inconvertible input\n\ntoNum(\u003cinconvertible\u003e, null);                // `null`\ntoNum(\u003cinconvertible\u003e, { def: null });       // `null`\ntoNumOrNull(\u003cinconvertible\u003e);                // `null`\n\ntoNum(\u003cinconvertible\u003e, 0);                   // `0`\ntoNum(\u003cinconvertible\u003e, { def: 0 });          // `0`\n\ntoNum(\u003cinconvertible\u003e, NaN);                 // `NaN`\ntoNum(\u003cinconvertible\u003e, { def: NaN });        // `NaN`\n\ntoNum();                                     // `undefined`\ntoNumOrNull();                               // `null`\n\ntoNum(NaN);                                  // `NaN`\ntoNum(NaN, null);                            // `null`\ntoNumOrNull(NaN);                            // `null`\n\ntoNum('');                                   // `''`\ntoNum('', null);                             // `null`\ntoNumOrNull('');                             // `null`\n```\n\n\n[coverage-image]: https://coveralls.io/repos/github/hypersoftllc/qc-to_num/badge.svg?branch=master\n[coverage-url]: https://coveralls.io/github/hypersoftllc/qc-to_num?branch=master\n[downloads-image]: http://img.shields.io/npm/dm/qc-to_num.svg\n[downloads-url]: http://npm-stat.com/charts.html?package=qc-to_num\n[license-image]: http://img.shields.io/npm/l/qc-to_num.svg\n[license-url]: LICENSE\n[package-url]: https://npmjs.org/package/qc-to_num\n[npm-badge-png]: https://nodei.co/npm/qc-to_num.png?downloads=true\u0026stars=true\n[travis-svg]: https://travis-ci.org/hypersoftllc/qc-to_num.svg?branch=master\n[travis-url]: https://travis-ci.org/hypersoftllc/qc-to_num\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhypersoftllc%2Fqc-to_num","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhypersoftllc%2Fqc-to_num","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhypersoftllc%2Fqc-to_num/lists"}