From 084353bad3935523292d4aaa8f353926a5fec2aa Mon Sep 17 00:00:00 2001 From: Olamide Atitebi <66855179+olamide203@users.noreply.github.com> Date: Mon, 1 Jan 2024 17:11:40 +0100 Subject: [PATCH] Docs/readme (#63) * docs: update readme * docs: add logo * docs: add logo to README * docs: update docs --- .github/assets/logo.svg | 16 +++++++++++++++ README.md | 44 ++++++++++++++++++++++++++++++++++++++--- 2 files changed, 57 insertions(+), 3 deletions(-) create mode 100644 .github/assets/logo.svg diff --git a/.github/assets/logo.svg b/.github/assets/logo.svg new file mode 100644 index 0000000..9c628da --- /dev/null +++ b/.github/assets/logo.svg @@ -0,0 +1,16 @@ + + + + + + + \ No newline at end of file diff --git a/README.md b/README.md index 6657879..0d3d20a 100755 --- a/README.md +++ b/README.md @@ -1,8 +1,27 @@ -# hyoka -[![Version](https://img.shields.io/npm/v/hyoka.svg)](https://www.npmjs.com/package/hyoka) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://github.com/olamide203/hyoka/blob/main/LICENSE) [![GitHub release (latest by date)](https://img.shields.io/github/v/release/olamide203/hyoka?)](https://github.com/olamide203/hyoka/releases) [![Build Status](https://github.com/olamide203/hyoka/workflows/CI/badge.svg)](https://github.com/olamide203/hyoka/actions) [![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/) - +

+ hyoka +

+ +

+ + Version + + + License + + + + + + + + + + +

+# hyoka hyoka is a simple math expression parser and evaluator for JavaScript and TypeScript. it uses [decimal.js](https://mikemcl.github.io/decimal.js/) to ensure precision of floating point calculations. ## Features @@ -76,6 +95,7 @@ hyoka configuration extends that of [decimal.js](https://mikemcl.github.io/decim - `maxE`: the maximum exponent value - `crypto`: whether to use the crypto module for random number generation - `angles`: the unit of angles to use for trig functions +- `decimalPlaces`: the number of decimal places of returned value The config options can be set using the `config` method on the `Expression` class: @@ -88,6 +108,24 @@ Expression.config({ angles: 'degrees' }); +new Expression('sin(30)').evaluate(); // 0.5 +``` + +config options can also be passed to the `evaluate` method. this will override the global config options for that evaluation only: + +```js +import {Expression} from 'hyoka'; +Expression.config({ + precision: 20, + rounding: 4, + angles: 'degrees' +}); + +// using local config options +new Expression('sin(π/6)').evaluate({angles: 'radians'}); // 0.5 +new Expression('1/3').evaluate({decimalPlaces: 3}); // 0.333 + +// using global config options new Expression('sin(30)').evaluate(); // 0.5 ``` ## Supported Operators