{"id":15042744,"url":"https://github.com/sindresorhus/math-sum","last_synced_at":"2025-10-19T19:31:06.880Z","repository":{"id":34625821,"uuid":"38575380","full_name":"sindresorhus/math-sum","owner":"sindresorhus","description":"Sum numbers","archived":false,"fork":false,"pushed_at":"2023-11-04T18:23:07.000Z","size":6,"stargazers_count":9,"open_issues_count":0,"forks_count":4,"subscribers_count":7,"default_branch":"main","last_synced_at":"2024-04-14T06:09:33.306Z","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/sindresorhus.png","metadata":{"funding":{"github":"sindresorhus","open_collective":"sindresorhus","custom":"https://sindresorhus.com/donate"},"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}},"created_at":"2015-07-05T16:16:05.000Z","updated_at":"2024-01-31T03:25:32.000Z","dependencies_parsed_at":"2023-12-02T09:41:49.776Z","dependency_job_id":null,"html_url":"https://github.com/sindresorhus/math-sum","commit_stats":{"total_commits":8,"total_committers":2,"mean_commits":4.0,"dds":0.125,"last_synced_commit":"381768debb1d94c7eddb71b96ba470d5a76516b6"},"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sindresorhus%2Fmath-sum","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sindresorhus%2Fmath-sum/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sindresorhus%2Fmath-sum/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sindresorhus%2Fmath-sum/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sindresorhus","download_url":"https://codeload.github.com/sindresorhus/math-sum/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":215780680,"owners_count":15929851,"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-09-24T20:47:55.708Z","updated_at":"2025-10-19T19:31:06.872Z","avatar_url":"https://github.com/sindresorhus.png","language":"JavaScript","readme":"# math-sum\n\n\u003e Sum numbers\n\n## Install\n\n```sh\nnpm install math-sum\n```\n\n## Usage\n\n```js\nimport sum from 'math-sum';\n\nsum(5, 5);\n//=\u003e 10\n\nsum([1, 2, 3, 4]);\n//=\u003e 10\n```\n\n### BigInt\n\n```js\nimport sum from 'math-sum';\n\nsum.bigInt(5, 5);\n//=\u003e 10n\n\nsum.bigInt([1, 2, 3, 4]);\n//=\u003e 10n\n\nsum.bigInt(1, 2n, 3);\n//=\u003e 6n\n\nconst largeNumber = 9_007_199_254_740_993n; // Number.MAX_SAFE_INTEGER + 2\nsum.bigInt(largeNumber, largeNumber);\n//=\u003e 18_014_398_509_481_986n\n```\n\nThe `sum.bigInt()` method accepts both regular numbers and BigInts and always returns a BigInt. Regular numbers are converted to BigInts automatically. This is useful when you need to sum numbers that exceed JavaScript's safe integer range.\n\n\u003e [!NOTE]\n\u003e The method throws a `RangeError` if any value is a non-integer number (e.g., `3.14`).\n\n## Related\n\n- [math-average](https://github.com/sindresorhus/math-average) - Get the average of numbers\n- [math-clamp](https://github.com/sindresorhus/math-clamp) - Clamp a number\n","funding_links":["https://github.com/sponsors/sindresorhus","https://opencollective.com/sindresorhus","https://sindresorhus.com/donate"],"categories":["Packages","Number"],"sub_categories":["Math"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsindresorhus%2Fmath-sum","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsindresorhus%2Fmath-sum","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsindresorhus%2Fmath-sum/lists"}