2020-06-21 20:10:06 +09:00
|
|
|
use crate::{Callback, Env, JsObject, Result};
|
|
|
|
|
|
|
|
pub struct Module {
|
|
|
|
pub env: Env,
|
|
|
|
pub exports: JsObject,
|
|
|
|
}
|
|
|
|
|
2020-11-25 18:42:14 +09:00
|
|
|
#[deprecated(since = "1.0.0", note = "[module_exports] macro instead")]
|
2020-06-21 20:10:06 +09:00
|
|
|
impl Module {
|
|
|
|
pub fn create_named_method(&mut self, name: &str, function: Callback) -> Result<()> {
|
|
|
|
self
|
|
|
|
.exports
|
|
|
|
.set_named_property(name, self.env.create_function(name, function)?)?;
|
|
|
|
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
}
|