{"id":26497707,"url":"https://github.com/bugwheels94/math-expression-evaluator","last_synced_at":"2025-12-12T05:50:37.617Z","repository":{"id":34387267,"uuid":"38314103","full_name":"bugwheels94/math-expression-evaluator","owner":"bugwheels94","description":" Math JS library. Super advanced \u0026 efficient Math expression evaluator","archived":false,"fork":false,"pushed_at":"2025-06-16T15:22:11.000Z","size":1026,"stargazers_count":220,"open_issues_count":22,"forks_count":36,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-12-05T22:44:59.443Z","etag":null,"topics":["math-expression-evaluator","math-expressions","math-library","mathematics"],"latest_commit_sha":null,"homepage":"","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/bugwheels94.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,"zenodo":null}},"created_at":"2015-06-30T14:32:01.000Z","updated_at":"2025-11-29T11:49:12.000Z","dependencies_parsed_at":"2024-06-18T12:29:26.559Z","dependency_job_id":"6a8c0fd0-e772-487a-99cb-64577854485a","html_url":"https://github.com/bugwheels94/math-expression-evaluator","commit_stats":{"total_commits":98,"total_committers":13,"mean_commits":7.538461538461538,"dds":0.5816326530612245,"last_synced_commit":"6990333867de0279917468293b1e6eec63d2bfa5"},"previous_names":["redhivesoftware/math-expression-evaluator","ankit31894/math-expression-evaluator","ankit2038/math-expression-evaluator"],"tags_count":16,"template":false,"template_full_name":null,"purl":"pkg:github/bugwheels94/math-expression-evaluator","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bugwheels94%2Fmath-expression-evaluator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bugwheels94%2Fmath-expression-evaluator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bugwheels94%2Fmath-expression-evaluator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bugwheels94%2Fmath-expression-evaluator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bugwheels94","download_url":"https://codeload.github.com/bugwheels94/math-expression-evaluator/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bugwheels94%2Fmath-expression-evaluator/sbom","scorecard":{"id":197213,"data":{"date":"2025-08-11","repo":{"name":"github.com/bugwheels94/math-expression-evaluator","commit":"df5d5e5e9fc1ab4848f5e6222b53a60bdea39485"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3,"checks":[{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Code-Review","score":0,"reason":"Found 1/27 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Maintained","score":2,"reason":"3 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 2","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/semantic-release.yaml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Packaging","score":10,"reason":"packaging workflow detected","details":["Info: Project packages its releases by way of GitHub Actions.: .github/workflows/semantic-release.yaml:12"],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Pinned-Dependencies","score":2,"reason":"dependency not pinned by hash detected -- score normalized to 2","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/semantic-release.yaml:16: update your workflow using https://app.stepsecurity.io/secureworkflow/bugwheels94/math-expression-evaluator/semantic-release.yaml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/semantic-release.yaml:17: update your workflow using https://app.stepsecurity.io/secureworkflow/bugwheels94/math-expression-evaluator/semantic-release.yaml/master?enable=pin","Warn: containerImage not pinned by hash: Dockerfile:1: pin your Docker image by updating node:12.14-alpine3.11 to node:12.14-alpine3.11@sha256:1dd4309479f031295f3dfb61cf3afc3efeb1a991b012e105d1a95efc038b72f6","Warn: npmCommand not pinned by hash: Dockerfile:5","Info:   0 out of   2 GitHub-owned GitHubAction dependencies pinned","Info:   0 out of   1 containerImage dependencies pinned","Info:   1 out of   2 npmCommand dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Signed-Releases","score":0,"reason":"Project has not signed or included provenance with any releases.","details":["Warn: release artifact v2.0.7 not signed: https://api.github.com/repos/bugwheels94/math-expression-evaluator/releases/223634522","Warn: release artifact v2.0.6 not signed: https://api.github.com/repos/bugwheels94/math-expression-evaluator/releases/185862157","Warn: release artifact v2.0.5 not signed: https://api.github.com/repos/bugwheels94/math-expression-evaluator/releases/139873967","Warn: release artifact v2.0.4 not signed: https://api.github.com/repos/bugwheels94/math-expression-evaluator/releases/126162000","Warn: release artifact v2.0.3 not signed: https://api.github.com/repos/bugwheels94/math-expression-evaluator/releases/107998895","Warn: release artifact v2.0.7 does not have provenance: https://api.github.com/repos/bugwheels94/math-expression-evaluator/releases/223634522","Warn: release artifact v2.0.6 does not have provenance: https://api.github.com/repos/bugwheels94/math-expression-evaluator/releases/185862157","Warn: release artifact v2.0.5 does not have provenance: https://api.github.com/repos/bugwheels94/math-expression-evaluator/releases/139873967","Warn: release artifact v2.0.4 does not have provenance: https://api.github.com/repos/bugwheels94/math-expression-evaluator/releases/126162000","Warn: release artifact v2.0.3 does not have provenance: https://api.github.com/repos/bugwheels94/math-expression-evaluator/releases/107998895"],"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 4 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Vulnerabilities","score":0,"reason":"34 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GHSA-968p-4wvh-cqc8","Warn: Project is vulnerable to: GHSA-67hx-6x53-jw92","Warn: Project is vulnerable to: GHSA-h5c3-5r3r-rr8q","Warn: Project is vulnerable to: GHSA-rmvr-2pp2-xj38","Warn: Project is vulnerable to: GHSA-xx4v-prfh-6cgc","Warn: Project is vulnerable to: GHSA-93q8-gq69-wqmw","Warn: Project is vulnerable to: GHSA-v6h2-p8h4-qcjw","Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg","Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275","Warn: Project is vulnerable to: GHSA-9vvw-cc9w-f27h","Warn: Project is vulnerable to: GHSA-gxpj-cx7g-858c","Warn: Project is vulnerable to: GHSA-h6ch-v84p-w6p9","Warn: Project is vulnerable to: GHSA-qh2h-chj9-jffq","Warn: Project is vulnerable to: GHSA-rc47-6667-2j5j","Warn: Project is vulnerable to: GHSA-78xj-cgh5-2h22","Warn: Project is vulnerable to: GHSA-2p57-rm9w-gvfp","Warn: Project is vulnerable to: GHSA-9c47-m6qq-7p4h","Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv","Warn: Project is vulnerable to: GHSA-hxm2-r34f-qmc5","Warn: Project is vulnerable to: GHSA-f8q6-p94x-37v3","Warn: Project is vulnerable to: GHSA-vh95-rmgr-6w4m","Warn: Project is vulnerable to: GHSA-xvch-5gv4-984h","Warn: Project is vulnerable to: GHSA-w9mr-4mfr-499f","Warn: Project is vulnerable to: GHSA-hj9c-8jmm-8c52","Warn: Project is vulnerable to: GHSA-gcx4-mw62-g8wm","Warn: Project is vulnerable to: GHSA-x2pg-mjhr-2m5x","Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw","Warn: Project is vulnerable to: GHSA-4x5v-gmq8-25ch","Warn: Project is vulnerable to: GHSA-76p7-773f-r4q5","Warn: Project is vulnerable to: GHSA-f5x3-32g6-xq36","Warn: Project is vulnerable to: GHSA-52f5-9888-hmc6","Warn: Project is vulnerable to: GHSA-hc6q-2mpp-qw7j","Warn: Project is vulnerable to: GHSA-4vvj-4cpr-p986","Warn: Project is vulnerable to: GHSA-j8xg-fqg3-53r7"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-16T22:02:13.324Z","repository_id":34387267,"created_at":"2025-08-16T22:02:13.324Z","updated_at":"2025-08-16T22:02:13.324Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":27633098,"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-12-10T02:00:12.818Z","response_time":54,"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":["math-expression-evaluator","math-expressions","math-library","mathematics"],"created_at":"2025-03-20T13:57:28.894Z","updated_at":"2025-12-12T05:50:37.600Z","avatar_url":"https://github.com/bugwheels94.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# math-expression-evaluator\nAn extremely efficient, flexible and amazing evaluator for Math expression in Javascript.\n\n## Use cases\n|Input|Result|Explanation|\n|:---:|:---:| --- |\n|**2+3-1**|4| Addition and Subtraction operator |\n|**2\\*5/10**|1| Multiplication and Division operator |\n|**tan45** *or* **tan(45)**|1| Trigonometric Function (tan in Degree mode) |\n|**tan45** *or* **tan(45)**|1.619775190543862| Trigonometric Function (tan in Radian mode) |\n|**Pi1,15,n** *or* **Pi(1,15,n)**|1307674368000| Product of Sequence |\n|**Sigma1,15,n** *or* **Sigma(1,15,n)**|120| Sum of Sequence (also called summation)  |\n|**2^3**|8| Exponent (note this operator is left associative like MS Office) |\n|**5P3**|60| Permutaion Method to calculate all the permutaions |\n|**sincostan90** *or* **sin(cos(tan(90)))**|0.017261434031253| Multiple functions with or without parenthesis (both works) |\n\n### [Fiddle Yourself](https://jsbin.com/romatuc/edit?html,output)\n\n## Installation\n### Node JS\n **Using npm**\n\n    npm install math-expression-evaluator\n\n### Browser\n **Using bower**\n\n    bower install math-expression-evaluator\n\n## Usage\n\n### Using eval method of mexp object\n\nconst mexp = new Mexp()\nvar value = mexp.eval(exp);  // 2 + 2\n\n### Using constituents of eval methods of mexp object\n\n1. Create mexp object\n\n        const mexp = new Mexp\n   \n2. Parse an expression and then add additional detail to the tokens using\n\n        var lexed = mexp.lex(\"expression\");\n    which returns an array of token which will be further processed by methods toPostfix and postfixEval\n\n3. Now, that array is needed to be converted to postfix notation using\n\n        var postfixed = mexp.toPostfix(lexed);  \n    which converts the array to postfix notation and return new array\n\n4. Now to get the value of expression use postfixEval\n\n        var result = mexp.postfixEval(postfixed);  \n    where result contains the result.\n\n\n### Extending tokens\n\n1. Defining a token\n\n    A token is defined similar way as [1.x version](http://bugwheels94.github.io/math-expression-evaluator/). You may refer to test file on examples on how to add tokens. Since this package is TS compatible, you will get autocomplete on `mexp.addToken`\n\n\n2. Adding tokens using addToken method of mexp object\n\n        const mexp = new Mexp()\n        mexp.addToken([token1, token2]) // tokens once added will be preserved in later evaluations\n\n3. Adding tokens using eval method of mexp object\n\n        const mexp = new Mexp()\n        mexp.eval(\"expression\", [token1, token2]) // tokens once added will be preserved in later evaluations\n\n4. Adding token using constituents of eval method of mexp object\n\n        const mexp = new Mexp()\n        const answer = mexp.postfixEval(mexp.toPostfix(mexp.lexed(\"expression\", [token1, token2]))) // tokens once added will be preserved in later evaluations\n        console.log(answer)\n## How to run test\n\n    npm test\n\n## Supported symbols\n\n|Symbol|Explanation|\n|:---:|:---:|\n|**+**| Addition Operator eg. 2+3 results 5 |\n|**-**| Subtraction Operator eg. 2-3 results -1 |\n|**/**| Division operator eg 3/2 results 1.5 |\n|**\\***| Multiplication Operator eg. 2\\*3 results 6 |\n|**Mod**| Modulus Operator eg. 3 Mod 2 results 1 |\n|**(**| Opening Parenthesis |\n|**)**| Closing Parenthesis |\n|**\u0026**| Bitwise AND eg. 3\u00261 results 1 |\n|**Sigma**| Summation eg. Sigma(1,100,n) results 5050 |\n|**Pi**| Product eg. Pi(1,10,n) results 3628800 |\n|**n**| Variable for Summation or Product |\n|**pi**| Math constant pi returns 3.14 |\n|**e**| Math constant e returns 2.71 |\n|**C**| Combination operator eg. 4C2 returns 6 |\n|**P**| Permutation operator eg. 4P2 returns 12 |\n|**!**| factorial operator eg. 4! returns 24 |\n|**log**| logarithmic function with base 10 eg. log 1000 returns 3 |\n|**ln**| natural log function with base e eg. ln 2 returns .3010 |\n|**pow**| power function with two operator pow(2,3) returns 8 |\n|**^**| power operator eg. 2^3 returns 8 |\n|**root**| underroot function root 4 returns 2 |\n|**sin**| Sine function |\n|**cos**| Cosine function |\n|**tan**| Tangent function |\n|**asin**| Inverse Sine function |\n|**acos**| Inverse Cosine function |\n|**atan**| Inverse Tangent function |\n|**sinh**| Hyperbolic Sine function |\n|**cosh**| Hyperbolic Cosine function |\n|**tanh**| Hyperbolic Tangent function |\n|**asinh**| Inverse Hyperbolic Sine function |\n|**acosh**| Inverse Hyperbolic Cosine function |\n|**atanh**| Inverse Hyperbolic Tangent function |\n\n## Features\n\n### Amazing support for Sigma and Pi\nThis is a fantastic feature of this calculator that it is capable of evaluating expressions containing **Sigma and Pi**.\nPassing `Sigma(1,100,n)` will evaluate to 5050 as n is summationed from 1 to 100.\nand Pi(1,15,n) will evaluate to 1307674368000 as n is multiplied from 1 to 15 which is equal to 15!\n\n### Parenthesis less expression\nIf a expression is readable by human then it is readable by this evaluator. There is no need to wrap every function inside parenthesis.\nFor eg. sin90 will work totally fine instead of sin(90)\n\n##Changelog\n\n### Removed lodash.indexof and used native Array.prototype.indexOf hence dropping suppports for IE8 and below.\nThis will reflect in next release named v1.2.16\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbugwheels94%2Fmath-expression-evaluator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbugwheels94%2Fmath-expression-evaluator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbugwheels94%2Fmath-expression-evaluator/lists"}