nha
nha

Reputation: 18005

ClojureScript - list functions of a namespace

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.

Upvotes: 1

Views: 1043

Answers (3)

Ahmed Almutawa
Ahmed Almutawa

Reputation: 51

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.

Upvotes: 2

gsnewmark
gsnewmark

Reputation: 308

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

Upvotes: 2

nha
nha

Reputation: 18005

Fow now I am doing :

(.keys js/Object my.ns)

As it looks like a namespace is an js object.

Upvotes: 0

Related Questions