mirror of
https://github.com/status-im/status-mobile.git
synced 2025-02-13 17:17:08 +00:00
Remove misleading wrap-call-once! fn
Signed-off-by: yenda <eric@status.im>
This commit is contained in:
parent
089027c3bf
commit
1ddb09b249
@ -36,16 +36,6 @@
|
|||||||
(defn hash-tag? [s]
|
(defn hash-tag? [s]
|
||||||
(= \# (first 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
|
(defn update-if-present
|
||||||
"Like regular `clojure.core/update` but returns original map if update key is not present"
|
"Like regular `clojure.core/update` but returns original map if update key is not present"
|
||||||
[m k f & args]
|
[m k f & args]
|
||||||
|
@ -2,15 +2,6 @@
|
|||||||
(:require [cljs.test :refer-macros [deftest is]]
|
(:require [cljs.test :refer-macros [deftest is]]
|
||||||
[status-im.utils.core :as u]))
|
[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
|
(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) "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)
|
(is (= (u/truncate-str "Long string" 7 true) "Lo...ng")) ; threshold is less then string length (truncate middle)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user