Skip to content

Commit

Permalink
Deprecate redundant contrib.str fns
Browse files Browse the repository at this point in the history
  • Loading branch information
ggeoffrey committed Aug 9, 2024
1 parent 643dac9 commit ae982c9
Showing 1 changed file with 20 additions and 10 deletions.
30 changes: 20 additions & 10 deletions src/contrib/str.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -60,21 +60,31 @@
(any-matches? ["abc"] "d") := nil)


(defn empty? [s] (or (and (string? s) (zero? (count s)))
(nil? s)))
(defn ^{:deprecated "Use clojure.core/empty?"} empty? [s]
(or (and (string? s) (zero? (count s)))
(nil? s)))

(tests
(empty? "") := true
(empty? nil) := true
(empty? " ") := false)
(empty? "") := true
(clojure.core/empty? "") := true
(empty? nil) := true
(clojure.core/empty? nil) := true
(empty? " ") := false
(clojure.core/empty? " ") := false
)

(defn empty->nil [s] (if (empty? s) nil s))
(defn ^{:deprecated "Use clojure.core/not-empty"} empty->nil [s] (if (empty? s) nil s))

(tests
(empty->nil nil) := nil
(empty->nil "") := nil
(empty->nil " ") := " "
(empty->nil "a") := "a")
(empty->nil nil) := nil
(clojure.core/not-empty nil) := nil
(empty->nil "") := nil
(clojure.core/not-empty "") := nil
(empty->nil " ") := " "
(clojure.core/not-empty " ") := " "
(empty->nil "a") := "a"
(clojure.core/not-empty "a") := "a"
)

(defn blank->nil "Nullify empty strings, identity on all other values." [s]
(if-not (string? s)
Expand Down

0 comments on commit ae982c9

Please sign in to comment.