Skip to content

Commit

Permalink
Extend metadata and docstrings some more
Browse files Browse the repository at this point in the history
  • Loading branch information
verberktstan authored Jan 31, 2024
1 parent 09e925d commit cbce39f
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions src/swark/core.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,13 @@
(into {}))))

(defn filter-keys
[map pred]
{:added "0.1.3"
:arglists '([map pred])
:doc "Returns a map containing only those entries in map whose key return logical true on evaluation of (pred key)."
:doc "Returns a map containing only those entries in map whose key return
logical true on evaluation of (pred key).
`(filter-keys {:a 1 "b" 2} keyword?) => {:a 1}`"
:static true}
[map pree]
(cond->> map
pred (filter (comp pred key))
map seq
Expand All @@ -56,8 +58,12 @@
;; Try and return nil when something is thrown

(defn try?
"Returns the result of (apply f args). When any error or exception is trown,
returns `nil`."
{:added "0.1.3"
:arglists '([f & args])
:doc "Returns the result of (apply f args). When any error or exception is
thrown, simply returns nil instead.
`(try? inc nil) => nil`"
:static true}
[f & args]
(try
(apply f args)
Expand All @@ -66,7 +72,10 @@
(defn select-namespaced
{:added "0.1.3"
:arglist '([map] [map ns])
:doc "Returns a map containing only those entries in map whose keys' namespace match ns. When ns is nil, returns a map containing only non-namespaced keys."
:doc "Returns a map containing only those entries in map whose keys'
namespace match ns. When ns is nil, returns a map containing only
non-namespaced keys.
`(select-namespaced {::test 1 :test 2} (namespace ::this)) => {::test 1}`"
:static true}
([map]
(select-namespaced map nil))
Expand Down

0 comments on commit cbce39f

Please sign in to comment.