ClojureScript - 列出命名空间的函数

ClojureScript - list functions of a namespace

如何列出 ClojureScripts 命名空间的 functions/vars?

这是一个与 Clojure 等价的问题,但提到的解决方案对我不起作用。

我现在在做什么:

(.keys js/Object my.ns)

因为它看起来像一个命名空间是一个 js 对象。

clojure.repl/dir 适用于我最新的 ClojureScript (1.7.228)

ns-interns seems to do what you need. If you need the vars/fns of the current namespace, you can use *ns*连同它。

用法:

(keys (ns-interns 'my-ns)) ;; All defined variables/functions of an arbitrary evaluated namespace

(keys (ns-interns *ns*)) ;; All defined variables/functions of the current namespace

请注意 ns 的值在 运行 时间和编译时间上有所不同,使用 CIDER/REPL 也会影响当前设置的 ns。后者在我的 lein repl 中有效,但在我的 CIDER repl 中无效。此 answer 有可能解决该问题。