1

How do I list the functions/vars of a ClojureScripts namespace ?

This is a question that has an equivalent for Clojure, but the solutions mentioned did not work for me.

Community
  • 1
  • 1
nha
  • 17,623
  • 13
  • 87
  • 133

3 Answers3

2

clojure.repl/dir works for me with latest ClojureScript (1.7.228)

gsnewmark
  • 308
  • 1
  • 8
2

ns-interns seems to do what you need. If you need the vars/fns of the current namespace, you can use *ns* in conjunction with it.

Usage:

(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

Note that value of ns differs in run time and compile time and using CIDER/REPL also affects which ns is currently set. The latter works in my lein repl but not in my CIDER repl for example. This answer has a possible solution to that issue.

  • alternatively, (keys (ns-publics 'my-ns)) , will list just the public mappings, which is a little easier to manage on some of the bigger modules. – vt5491 Dec 07 '21 at 08:54
0

Fow now I am doing :

(.keys js/Object my.ns)

As it looks like a namespace is an js object.

nha
  • 17,623
  • 13
  • 87
  • 133