【发布时间】:2017-10-04 09:10:29
【问题描述】:
在 python 中,为了在包中公开顶级功能,可以创建一个__init__.py
#__init__.py
from .implmentation import impl_function
def exposed_fn():
"""call impl_function
这会将exposed_fn 公开为导入目录(包)时要使用的主要功能。 javascript 的require 中的这个等价物是什么?
显然您可以执行以下操作。
//init.js?
var impl_function = require('./implmentation.js').impl_function;
var exposed_fn = function () {//call impl_function ...};
//Will expose `exposed_fn` when requiring this file.
module.exports = {
exposed_fn: exposed_fn
}
//How to expose `expose_fn` when requiring a this folder?????
有没有等价物?到目前为止,所有搜索都没有得到证明。
【问题讨论】:
标签: javascript package