https://github.com/tonywu6/ferrosaur
🦀📲🦕
https://github.com/tonywu6/ferrosaur
deno proc-macro v8
Last synced: 4 months ago
JSON representation
🦀📲🦕
- Host: GitHub
- URL: https://github.com/tonywu6/ferrosaur
- Owner: tonywu6
- License: apache-2.0
- Created: 2025-02-16T17:08:00.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-05-11T13:01:20.000Z (about 1 year ago)
- Last Synced: 2025-11-12T03:27:05.048Z (8 months ago)
- Topics: deno, proc-macro, v8
- Language: Rust
- Homepage: https://tonywu6.github.io/ferrosaur/
- Size: 573 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE-APACHE.md
Awesome Lists containing this project
README
# ferrosaur
[](https://crates.io/crates/ferrosaur)
[](https://tonywu6.github.io/ferrosaur/)
[](https://github.com/tonywu6/ferrosaur/tree/main/LICENSE-APACHE.md)
So you use [`deno_core`], and you want to call JavaScript from Rust.
```javascript
// If you have: lib.js
export const slowFib = (n) =>
n === 0 ? 0 : n === 1 ? 1 : slowFib(n - 1) + slowFib(n - 2);
```
```rust
// and you write: lib.rs
use ferrosaur::js;
#[js(module("lib.js"))]
struct Math;
#[js(interface)]
impl Math {
#[js(func)]
fn slow_fib(&self, n: serde) -> serde {}
}
```
```rust
// Then you get:
// let rt: &mut JsRuntime;
let lib = Math::main_module_init(rt).await?;
let fib = lib.slow_fib(42, rt)?;
assert_eq!(fib, 267914296);
```
_ferrosaur_ derives types and implementations, Ã la [wasm-bindgen], that you can use
with your favorite [`JsRuntime`].
## Documentation
[Read the book!](https://tonywu6.github.io/ferrosaur/)
You may be looking for:
- [Examples](https://tonywu6.github.io/ferrosaur/examples)
- [_console.log_](https://tonywu6.github.io/ferrosaur/examples/console)
| [_calculator_](https://tonywu6.github.io/ferrosaur/examples/calculator)
| [_ts_](https://tonywu6.github.io/ferrosaur/examples/ts)
| [_ts-blank-space_](https://tonywu6.github.io/ferrosaur/examples/ts-blank-space)
- [Reference](https://tonywu6.github.io/ferrosaur/reference)
- [`js(global_this)`](https://tonywu6.github.io/ferrosaur/reference/global-this)
| [`js(module)`](https://tonywu6.github.io/ferrosaur/reference/module)
| [`js(value)`](https://tonywu6.github.io/ferrosaur/reference/value)
| [`js(interface)`](https://tonywu6.github.io/ferrosaur/reference/interface)
| [`js(prop)`](https://tonywu6.github.io/ferrosaur/reference/interface/prop)
| [`js(func)`](https://tonywu6.github.io/ferrosaur/reference/interface/func)
| [`js(new)`](https://tonywu6.github.io/ferrosaur/reference/interface/new)
## License
This project is released under the
[Apache 2.0 License](https://github.com/tonywu6/ferrosaur/tree/main/LICENSE-APACHE.md)
and the [MIT License](https://github.com/tonywu6/ferrosaur/tree/main/LICENSE-MIT.md).
[`deno_core`]: https://docs.rs/deno_core
[`JsRuntime`]: https://docs.rs/deno_core/latest/deno_core/struct.JsRuntime.html
[wasm-bindgen]: https://github.com/rustwasm/wasm-bindgen#example