Skip to content

Commit

Permalink
keyword accepts 2 args
Browse files Browse the repository at this point in the history
  • Loading branch information
bobbicodes committed Sep 3, 2023
1 parent 7a92a2c commit c5fbbba
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 11 deletions.
10 changes: 4 additions & 6 deletions src/clj/core.clj
Original file line number Diff line number Diff line change
Expand Up @@ -755,11 +755,10 @@
(if (keyword? mk)
(let* [mkns (namespace mk)
mkn (name mk)]
(println (name mk))
(cond (= mkn "keys")
(cond (= mkn "keys")
(assoc transforms
mk
#(keyword (or mkns (namespace %)) (name %)))
(fn [k] (keyword (or mkns (namespace k)) (name k))))
(= mkn "syms")
(assoc transforms
mk
Expand Down Expand Up @@ -798,9 +797,8 @@
ret))))

(defn namespace [x]
(first (str/split (str x) "/")))

(namespace :keys)
(when (str/includes? x "/")
(first (str/split (str x) "/"))))

(defn name [x]
(if (keyword? x)
Expand Down
17 changes: 12 additions & 5 deletions src/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -179,12 +179,19 @@ export function _ratio_Q(obj) {
}

// Keywords
export function _keyword(obj) {
if (typeof obj === 'string' && obj[0] === '\u029e') {
return obj;
} else {
return "\u029e" + obj;
export function _keyword(ns, name) {
if (!name) {
name = ns
if (typeof name === 'string' && name[0] === '\u029e') {
return name;
} else {
return "\u029e" + name;
}
}
if (ns === null) {
return "\u029e" + name
}
return "\u029e" + ns + "/" + name
}
export function _keyword_Q(obj) {
return typeof obj === 'string' && obj[0] === '\u029e';
Expand Down

0 comments on commit c5fbbba

Please sign in to comment.