Node.js class addon

    0

    2

    Giovanny Gongora

    Codiga's Rust Recipes
    #[macro_use]
    extern crate napi_derive;
    use std::convert::TryInto;
    use napi::{CallContext, JsNumber, JsObject, JsUndefined, JsString, Property, Result};
    
    #[js_function(1)]
    fn class_constructor(ctx: CallContext) -> Result<JsUndefined> {
      // Define class constructor
    }
    #[js_function(1)]
    fn process_data_class(ctx: CallContext) -> Result<JsObject> {
    	// Define class methods
    }
    #[module_exports]
    pub fn init(mut exports: JsObject) -> Result<()> {
      exports.create_named_method($1, process_data_class)?;
      Ok(())
    }
    
    Codiga Logo
    Codiga Hub
    • Rulesets
    • Explore
    • Cookbooks
    • Playground
    soc-2 icon

    We are SOC-2 Compliance Certified

    G2 high performer medal

    Codiga – All rights reserved 2022.