infinyon / node-bindgen

Easy way to write Node.js module using Rust
Apache License 2.0
536 stars 43 forks source link

JS namespaces (modules) #185

Open DmitryAstafyev opened 2 years ago

DmitryAstafyev commented 2 years ago

Hello, Is it possible to define somehow module/namespace on JS level? Let's say I have:

mod features {
    #[node_bindgen]
    pub fn feature_a() -> Result<...> { .... }
}

mod tools {
    #[node_bindgen]
    pub fn tool_a() -> Result<...> { .... }
}

On js level I would like to see it as:

let rustcore = require('rustcore.node');
rustcore.features.feature_a();
rustcore.tools.tool_a();

Sorry if question is trivial, but didn't find any kind of solution for that.

sehz commented 2 years ago

Sorry, not yet. Would love contribution though