{"id":18285917,"url":"https://github.com/exodusmovement/parse-num","last_synced_at":"2025-04-05T08:30:36.941Z","repository":{"id":57147170,"uuid":"52388238","full_name":"ExodusMovement/parse-num","owner":"ExodusMovement","description":"JavaScript component to parse, clean, remove formatting (unformat) numbers in strings.","archived":false,"fork":false,"pushed_at":"2022-11-21T18:07:51.000Z","size":4,"stargazers_count":9,"open_issues_count":0,"forks_count":1,"subscribers_count":36,"default_branch":"master","last_synced_at":"2024-09-17T16:18:45.319Z","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/ExodusMovement.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}},"created_at":"2016-02-23T20:10:53.000Z","updated_at":"2023-01-13T12:41:03.000Z","dependencies_parsed_at":"2023-01-22T01:49:33.996Z","dependency_job_id":null,"html_url":"https://github.com/ExodusMovement/parse-num","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ExodusMovement%2Fparse-num","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ExodusMovement%2Fparse-num/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ExodusMovement%2Fparse-num/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ExodusMovement%2Fparse-num/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ExodusMovement","download_url":"https://codeload.github.com/ExodusMovement/parse-num/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223174747,"owners_count":17100272,"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":"2024-11-05T13:18:10.782Z","updated_at":"2024-11-05T13:18:11.464Z","avatar_url":"https://github.com/ExodusMovement.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"parse-num\n==========\n\nJavaScript component to parse, clean, remove formatting (unformat) numbers in strings.\n\n\nInstall\n-------\n\n    npm install --save parse-num\n\n\nUsage\n-----\n\n### parseNum\n\n**Signature:** `parseNum(value, [decimalSep])`\n\n**Parameters:**\n\n- `value`: Any value to parse a number from. If it's `null` or `undefined`, it will return `NaN`. If it's\na `number`, it will just return the `number`. Otherwise, it will coerce the input `value` to a `string` using\n`toString()`.\n- `decimalSep`: *optional* `string` parameter to specify a decimal separator. Defaults to `\".\"`.\n\n**Returns:**\n\nThe parsed `number`.\n\n**Example:**\n\n```js\nconst parseNum = require('parse-num')\n// import parseNum from 'parse-num' // if using ES6\n\nparseNum('$ 123,456.78')                // =\u003e 123456.78\nparseNum('$ 123,456')                   // =\u003e 123456\nparseNum('\u0026*()$ 123,456')               // =\u003e 123456\nparseNum(';$@#$%^\u0026123,456.78')          // =\u003e 123456.78\nparseNum('$ -123,456')                  // =\u003e -123456\nparseNum('$ -123,456.78')               // =\u003e -123456.78\nparseNum('\u0026*()$ -123,456')              // =\u003e -123456\nparseNum(';$@#$%^\u0026-123,456.78')         // =\u003e -123456.78\nparseNum('$ 123,456', ')')              // =\u003e 123.456\nparseNum('$ 123456|78', '|')            // =\u003e 123456.78\nparseNum('\u0026*()$ 123\u003e456', '\u003e')          // =\u003e 123.456\nparseNum(';$@#$%^\u0026123,456\\'78', '\\'')   // =\u003e 123456.78\n```\n\n### Don't want `NaN`?\n\nDon't ever want to deal with NaN? Do this:\n\n```js\nvar num = parseNum(null)\nif (isNaN(num)) num = 0\n\n// could also coerce to integer \u003c=== BE careful, 'INTEGER', not 'FLOAT'\nvar num = ~~parseNum(null)\nconsole.log(num) // =\u003e 0\n```\n\n\nCredits\n-------\n\nThe basis of this code came from [accounting.js](https://github.com/openexchangerates/accounting.js).\n\n\nLicense\n-------\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fexodusmovement%2Fparse-num","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fexodusmovement%2Fparse-num","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fexodusmovement%2Fparse-num/lists"}