{"id":16409891,"url":"https://github.com/juliandavidmr/sylver","last_synced_at":"2025-03-23T06:31:02.670Z","repository":{"id":57376178,"uuid":"96634508","full_name":"juliandavidmr/sylver","owner":"juliandavidmr","description":"❄️A lightweight math library for JavaScript","archived":false,"fork":false,"pushed_at":"2017-07-11T03:06:14.000Z","size":46,"stargazers_count":24,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-18T13:38:33.496Z","etag":null,"topics":["library","math"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/sylver","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/juliandavidmr.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-07-08T17:42:47.000Z","updated_at":"2022-02-22T11:36:52.000Z","dependencies_parsed_at":"2022-09-05T18:10:49.829Z","dependency_job_id":null,"html_url":"https://github.com/juliandavidmr/sylver","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/juliandavidmr%2Fsylver","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/juliandavidmr%2Fsylver/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/juliandavidmr%2Fsylver/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/juliandavidmr%2Fsylver/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/juliandavidmr","download_url":"https://codeload.github.com/juliandavidmr/sylver/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245066496,"owners_count":20555402,"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":["library","math"],"created_at":"2024-10-11T06:22:01.180Z","updated_at":"2025-03-23T06:31:02.234Z","avatar_url":"https://github.com/juliandavidmr.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Sylver\n\n[![npm version](https://img.shields.io/npm/v/sylver.svg)](https://www.npmjs.com/package/sylver)\n\n❄️A lightweight math library for JavaScript. It features a flexible expression parser comes with a large set of built-in functions and constants. Powerful and easy to use.\n\n\u003e In active development, any pull request will be welcome :)\n\n## Features\n\n- Minimal and fast\n- Supports numbers, complex numbers, fractions, conditions.\n- Compatible with JavaScript.\n- Contains a flexible expression parser.\n- Dynamic creation of variables, multivalue. _(Experimental)_\n- Comes with a large set of built-in functions and constants.\n- Has no dependencies. Runs on any JavaScript engine. \n- Can be used as a command line application as well. _(Experimental)_\n- Open source.\n\n## Usage\n\n```bash\nnpm install --save sylver \n# or \nyarn add sylver\n```\n\n```js\n// load sylver\nvar sylver = require('sylver');\n\n// basic\nsylver(\"(3*2)+6\")           // 12\nsylver(\"~16\")               // -16\nsylver(\"7!\")                // 5040\n\n// compare (0 = false; 1 = true)\nsylver(\"32\u003c\u003e32\")            // 0\nsylver(\"(10*2)\u003c=(40+3)\")    // 1\nsylver(\"11 eq 11\")          // 1\nsylver(\"4\u003c=9\")              // 1\n\n// conditions\nsylver(\"if(3+8\u003c=23)12:3\")   // 12\n\n// intervals\nsylver(\"2 to 8\")            // [2, 3, 4, 5, 6, 7, 8]\nsylver(\"(4*PI) to (23/2)\")  // [11.5, 12.5]\nsylver(\"2 * (6 to 10)\")     // [ 12, 14, 16, 18, 20 ]\n\n// list\nsylver(\"[2, 3, 5, 1] * [6, 3, 5, 4, 102]\")     // [ 12, 9, 25, 4, 102 ]\n\n// algebra\nsylver(\"cos(4)\")            // -0.6536436208636119\nsylver(\"atan(7)\")           // 1.4288992721907328\nsylver(\"atanh(-0.4)\")       // -0.4236489301936018\n// See: test/algebra1.js\n\n// Other\nsylver(\"abs(ln(2)*(4^3))*(if(3\u003c\u003e6) 2:5)\")  // 88.722839111673\n```\n\n### Usage globally _(Available in the next versions)_\n\n```bash\nnpm i -g sylver\n\n# or\nyarn global add sylver\n```\nEnter from the command terminal:\n```bash\nsylver --help\n```\n\n## Documentation\n\n### Mathematical operators\n  \n| Operator | Description |\n| -------- | ----------- |\n| + \t   | addition    |\n| - \t   | subtraction |\n| ∗ \t   | multiplication |\n| / \t   | right division, i.e. `x/y` |\n| ˆ \t   | power, i.e. `x^y`\t\t  |\n\n\n### Mathematical functions: trigonometry\n  \n| functions |\n| ----------- |\n| log log10 log1p log2 sqrt, cos, tan, sin, atan, asin, acos, atanh, acosh, asinh |\n\n### Intervals\n\nSylver is able to generate lists of numbers from a range:\n````js\nsylver(\"1 to 7\")                  // [ 1, 2, 3, 4, 5, 6, 7 ]\nsylver(\"2 * (6 to 10)\")           // [12, 14, 16, 18, 20]\nsylver(\"(1 to 4) * [2, 4, 6, 7]\") // [ 2, 8, 18, 28 ]\nsylver(\"(1 to 4) * 3\")            // [ 3, 6, 9, 12 ]\nsylver(\"1 to (10/2) + 10\")        // [11, 12, 13, 14, 15]\n````\n\nThe order of the operators is important:\n````js\nsylver(\"10 / [2, 5, 4]\")          // [5, 2, 2.5]\n\n// This is different from:\nsylver(\"[2, 5, 4] / 10\")          // [0.2, 0.5, 0.4]\n````\n\n### Conditions\nEvaluate expressions and returns a decision:\n```js\nsylver(`if((5*2)\u003e(6*2)) 80 : 35 `)    // 35\n```\nYou can use the returned result to operate with other expressions:\n```js\nsylver(\"(if(3\u003e0)1:2)*5)\")            // 5\n```\n\n### Constants\n\nCurrently there are two constants available: `PI`, `E`\n```js\nsylver(\"PI\")        // 3.141592653589793\nsylver(\"E\")         // 2.718281828459045\n```\n\n### Variables _(experimental: Available in the next versions npm)_\n\nThe creation of variables is dynamic, it is not necessary to \nspecify the data type: Imagine that you are creating a variable \nin javascript but without specifying var.\n\u003e A variable can contain a number or a list of numbers.\n\n```js\n// Create a variable\nsylver(\"var12 := ((1 to 5) * 34)\")\n\n// Get value of a variable\nsylver(\":var12\")                  // [ 34, 68, 102, 136, 170 ]\n```\n\nWhen you create a variable, the data that has been assigned \nis returned:\n````js\nsylver(\"hello := 123\")        // 123\n\n// e.g.\nsylver(\"(bye := 5) * 2\")      // 10\n````\n\n## Browser support\n__// TODO: Version for browsers in development__\nSylver works on any ES5 compatible JavaScript engine: node.js 0.10, \nand Internet Explorer 9 and newer, and all other browsers (Chrome, Firefox, Safari). \nIf support for old browsers like Internet Explorer 8 is required, \nthe es5-shim library has to be loaded.\n\n\n## Build\n\nFirst clone the project from github:\n\n```bash\ngit clone https://github.com/juliandavidmr/sylver.git\ncd sylver\n```\n\nInstall the project dependencies:\n```bash\nnpm install\n# or\nyarn\n```\n\n## Test\n\nTo execute tests for the library, install the project dependencies once:\n```bash\nnpm install\n```\n\nThen, the tests can be executed:\n```bash\nnpm test\n```\n\nThe tests are run with [ava](https://github.com/avajs/ava)\n\n\n## Built With\n* [jison](https://zaa.ch/jison) - Bison in JavaScript\n\n## Contributing\n\nPlease read [CONTRIBUTING.md](./CONTRIBUTING.md) for details on our code of conduct, and the process for submitting pull requests to us.\n\n## Versioning\n\nWe use [SemVer](http://semver.org/) for versioning. \n\n## Authors\n\n* **Julian David** - *Initial work* - [@juliandavidmr](https://github.com/juliandavidmr)\n\nSee also the list of [contributors](./CONTRIBUTORS.md) who participated in this project.\n\n### [See changelog](CHANGELOG.md)\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE](./LICENSE) file for details","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjuliandavidmr%2Fsylver","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjuliandavidmr%2Fsylver","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjuliandavidmr%2Fsylver/lists"}