9 releases

new 1.0.0-beta.1 May 8, 2024
1.0.0-beta.0 Apr 18, 2024
0.0.9 Mar 1, 2024
0.0.7 Feb 23, 2024
0.0.1 Nov 22, 2023

#439 in Procedural macros

Download history 171/week @ 2024-02-12 199/week @ 2024-02-19 237/week @ 2024-02-26 24/week @ 2024-03-04 83/week @ 2024-03-11 59/week @ 2024-04-01 76/week @ 2024-04-15 97/week @ 2024-05-06

173 downloads per month

MIT license

180KB
5K SLoC

napi-derive

chat

Checkout more examples in examples folder

#[macro_use]
extern crate napi_derive;
use napi_ohos::bindgen_prelude::*;

#[napi]
fn fibonacci(n: u32) -> u32 {
  match n {
    1 | 2 => 1,
    _ => fibonacci_native(n - 1) + fibonacci_native(n - 2),
  }
}

#[napi]
fn get_cwd<T: Fn(String) -> Result<()>>(callback: T) {
  callback(env::current_dir().unwrap().to_string_lossy().to_string()).unwrap();
}

Dependencies

~1–2MB
~35K SLoC