-
Notifications
You must be signed in to change notification settings - Fork 23
/
helpers.cljc
27 lines (23 loc) · 861 Bytes
/
helpers.cljc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
(ns matthiasn.systems-toolbox.component.helpers
(:require
#?(:clj [clojure.pprint :as pp]
:cljs [cljs.pprint :as pp])
#?(:cljs [cljs-uuid-utils.core :as uuid])))
(defn now
"Get milliseconds since epoch."
[]
#?(:clj (System/currentTimeMillis)
:cljs (.getTime (js/Date.))))
(defn pp-str [data] (with-out-str (pp/pprint data)))
(defn make-uuid
"Get a random UUID."
[]
#?(:clj (java.util.UUID/randomUUID)
:cljs (uuid/make-random-uuid)))
#?(:cljs (def request-animation-frame
(or (when (exists? js/window)
(or (.-requestAnimationFrame js/window)
(.-webkitRequestAnimationFrame js/window)
(.-mozRequestAnimationFrame js/window)
(.-msRequestAnimationFrame js/window)))
(fn [callback] (js/setTimeout callback 17)))))