mirror of
https://github.com/PaddiM8/kalker.git
synced 2025-03-04 16:21:16 +01:00
Updated kalk library README to include a JavaScript example, disabled wasm optimization, and created wasm build script
This commit is contained in:
parent
f81e1731b3
commit
bf06c7789d
@ -24,4 +24,8 @@ wasm-bindgen = "0.2.69"
|
||||
wasm-bindgen-test = "0.3.19"
|
||||
|
||||
[features]
|
||||
default = ["rug"]
|
||||
default = ["rug"]
|
||||
|
||||
# Breaks when optimizing for some reason.
|
||||
[package.metadata.wasm-pack.profile.release]
|
||||
wasm-opt = false
|
||||
|
@ -17,7 +17,7 @@ f(a, 2)
|
||||
* Syntax highlighting
|
||||
* Special-symbol completion on tab. Eg. write `sqrt` and press tab. It will be turned into `√`.
|
||||
|
||||
## Usage
|
||||
## Rust Usage
|
||||
```rust
|
||||
use kalk::parser;
|
||||
let mut parser_context = parser::Context::new();
|
||||
@ -26,8 +26,15 @@ let result = parser::eval(&mut parser_context, "5*3", precision).unwrap().unwrap
|
||||
assert_eq!(result.to_f64(), 15f64);
|
||||
```
|
||||
|
||||
## Using f64 instead of rug::Float
|
||||
### Using f64 instead of rug::Float
|
||||
The cargo feature `rug` enables rug, and is used by default. If you disalbe this, kalk will use `f64` instead, making it more portable.
|
||||
|
||||
## Compiling
|
||||
### Compiling
|
||||
Make sure you have `diffutils` `gcc` `make` and `m4` installed.
|
||||
|
||||
## JavaScript Usage
|
||||
```js
|
||||
const kalk = await import("@paddim8/kalk");
|
||||
const context = new kalk.Context();
|
||||
console.log(context.evaluate("2pi + 3").toScientificNotation().toString());
|
||||
```
|
1
kalk/wasm-build.sh
Executable file
1
kalk/wasm-build.sh
Executable file
@ -0,0 +1 @@
|
||||
wasm-pack build --scope paddim8 -- --no-default-features
|
Loading…
Reference in New Issue
Block a user