Remove misleading wrap-call-once! fn

Signed-off-by: yenda <eric@status.im>
This commit is contained in:
yenda 2018-09-23 11:44:47 +02:00
parent 089027c3bf
commit 1ddb09b249
No known key found for this signature in database
GPG Key ID: 0095623C0069DCE6
2 changed files with 0 additions and 19 deletions

View File

@ -36,16 +36,6 @@
(defn hash-tag? [s]
(= \# (first s)))
(defn wrap-call-once!
"Returns a version of provided function that will be called only the first time wrapping function is called. Returns nil."
[f]
(let [called? (volatile! false)]
(fn [& args]
(when-not @called?
(vreset! called? true)
(apply f args)
nil))))
(defn update-if-present
"Like regular `clojure.core/update` but returns original map if update key is not present"
[m k f & args]

View File

@ -2,15 +2,6 @@
(:require [cljs.test :refer-macros [deftest is]]
[status-im.utils.core :as u]))
(deftest wrap-as-call-once-test
(let [count (atom 0)]
(letfn [(inc-count [] (swap! count inc))]
(let [f (u/wrap-call-once! inc-count)]
(is (nil? (f)))
(is (= 1 @count))
(is (nil? (f)))
(is (= 1 @count))))))
(deftest truncate-str-test
(is (= (u/truncate-str "Long string" 7) "Long...")) ; threshold is less then string length
(is (= (u/truncate-str "Long string" 7 true) "Lo...ng")) ; threshold is less then string length (truncate middle)