@@ -1098,16 +1098,24 @@ defaults to returning v."))
10981098 IPrintWithWriter
10991099 (-pr-writer [o writer _] (-write writer str)))
11001100
1101+ (defn var?
1102+ " Returns true if v is of type cljs.core.Var"
1103+ [v]
1104+ (instance? cljs.core.Var v))
1105+
11011106(defn symbol
1102- " Returns a Symbol with the given namespace and name."
1107+ " Returns a Symbol with the given namespace and name. Arity-1 works
1108+ on strings, keywords, and vars."
11031109 ([name]
1104- (if (symbol? name)
1105- name
1106- (let [idx (.indexOf name " /" )]
1107- (if (< idx 1 )
1108- (symbol nil name)
1109- (symbol (.substring name 0 idx)
1110- (.substring name (inc idx) (. name -length)))))))
1110+ (cond (symbol? name) name
1111+ (string? name) (let [idx (.indexOf name " /" )]
1112+ (if (< idx 1 )
1113+ (symbol nil name)
1114+ (symbol (.substring name 0 idx)
1115+ (.substring name (inc idx) (. name -length)))))
1116+ (var? name) (.-sym name)
1117+ (keyword? name) (recur (.-fqn name))
1118+ :else (throw (new js/Error " no conversion to symbol" ))))
11111119 ([ns name]
11121120 (let [sym-str (if-not (nil? ns )
11131121 (str ns " /" name)
@@ -1182,11 +1190,6 @@ defaults to returning v."))
11821190 (-invoke [_ a b c d e f g h i j k l m n o p q r s t rest]
11831191 (apply (val ) a b c d e f g h i j k l m n o p q r s t rest)))
11841192
1185- (defn var?
1186- " Returns true if v is of type cljs.core.Var"
1187- [v]
1188- (instance? cljs.core.Var v))
1189-
11901193; ;;;;;;;;;;;;;;;;;; fundamentals ;;;;;;;;;;;;;;;
11911194
11921195(declare array-seq prim-seq IndexedSeq )
0 commit comments