|
1263 | 1263 | (garray/defaultCompare (.valueOf this) (.valueOf other)) |
1264 | 1264 | (throw (js/Error. (str "Cannot compare " this " to " other)))))) |
1265 | 1265 |
|
| 1266 | +(defprotocol Inst |
| 1267 | + (inst-ms* [inst])) |
| 1268 | + |
| 1269 | +(extend-protocol Inst |
| 1270 | + js/Date |
| 1271 | + (inst-ms* [inst] (.getTime inst))) |
| 1272 | + |
| 1273 | +(defn inst-ms |
| 1274 | + "Return the number of milliseconds since January 1, 1970, 00:00:00 GMT" |
| 1275 | + [inst] |
| 1276 | + (inst-ms* inst)) |
| 1277 | + |
| 1278 | +(defn ^boolean inst? |
| 1279 | + "Return true if x satisfies Inst" |
| 1280 | + [x] |
| 1281 | + (satisfies? Inst x)) |
| 1282 | + |
1266 | 1283 | (extend-type number |
1267 | 1284 | IEquiv |
1268 | 1285 | (-equiv [x o] (identical? x o))) |
@@ -2064,6 +2081,10 @@ reduces them without incurring seq initialization" |
2064 | 2081 | "Returns true if x is the value true, false otherwise." |
2065 | 2082 | [x] (cljs.core/true? x)) |
2066 | 2083 |
|
| 2084 | +(defn ^boolean boolean? |
| 2085 | + "Return true if x is a Boolean" |
| 2086 | + [x] (or (cljs.core/true? x) (cljs.core/false? x))) |
| 2087 | + |
2067 | 2088 | (defn ^boolean undefined? |
2068 | 2089 | "Returns true if x identical to the JavaScript undefined value." |
2069 | 2090 | [x] |
@@ -2102,6 +2123,26 @@ reduces them without incurring seq initialization" |
2102 | 2123 | (not (identical? n js/Infinity)) |
2103 | 2124 | (== (js/parseFloat n) (js/parseInt n 10)))) |
2104 | 2125 |
|
| 2126 | +(defn ^boolean long? |
| 2127 | + "Return true if x is an instance of goog.math.Long" |
| 2128 | + [x] (instance? goog.math.Long x)) |
| 2129 | + |
| 2130 | +(defn ^boolean pos-long? |
| 2131 | + "Return true if x is a positive Long" |
| 2132 | + [x] (and (instance? goog.math.Long x) |
| 2133 | + (not (.isNegative x)) |
| 2134 | + (not (.isZero x)))) |
| 2135 | + |
| 2136 | +(defn ^boolean neg-long? |
| 2137 | + "Return true if x is a negative Long" |
| 2138 | + [x] (and (instance? goog.math.Long x) |
| 2139 | + (.isNegative x))) |
| 2140 | + |
| 2141 | +(defn ^boolean nat-long? |
| 2142 | + "Return true if x is a non-negative Long" |
| 2143 | + [x] (and (instance? goog.math.Long x) |
| 2144 | + (or (not (.isNegative x)) (.isZero x)))) |
| 2145 | + |
2105 | 2146 | (defn ^boolean contains? |
2106 | 2147 | "Returns true if key is present in the given collection, otherwise |
2107 | 2148 | returns false. Note that for numerically indexed collections like |
@@ -3086,6 +3127,34 @@ reduces them without incurring seq initialization" |
3086 | 3127 | (-namespace ^not-native x) |
3087 | 3128 | (throw (js/Error. (str "Doesn't support namespace: " x))))) |
3088 | 3129 |
|
| 3130 | +(defn ^boolean ident? |
| 3131 | + "Return true if x is a symbol or keyword" |
| 3132 | + [x] (or (keyword? x) (symbol? x))) |
| 3133 | + |
| 3134 | +(defn ^boolean simple-ident? |
| 3135 | + "Return true if x is a symbol or keyword without a namespace" |
| 3136 | + [x] (and (ident? x) (nil? (namespace x)))) |
| 3137 | + |
| 3138 | +(defn ^boolean qualified-ident? |
| 3139 | + "Return true if x is a symbol or keyword with a namespace" |
| 3140 | + [x] (and (ident? x) (namespace x) true)) |
| 3141 | + |
| 3142 | +(defn ^boolean simple-symbol? |
| 3143 | + "Return true if x is a symbol without a namespace" |
| 3144 | + [x] (and (symbol? x) (nil? (namespace x)))) |
| 3145 | + |
| 3146 | +(defn ^boolean qualified-symbol? |
| 3147 | + "Return true if x is a symbol with a namespace" |
| 3148 | + [x] (and (symbol? x) (namespace x) true)) |
| 3149 | + |
| 3150 | +(defn ^boolean simple-keyword? |
| 3151 | + "Return true if x is a keyword without a namespace" |
| 3152 | + [x] (and (keyword? x) (nil? (namespace x)))) |
| 3153 | + |
| 3154 | +(defn ^boolean qualified-keyword? |
| 3155 | + "Return true if x is a keyword with a namespace" |
| 3156 | + [x] (and (keyword? x) (namespace x) true)) |
| 3157 | + |
3089 | 3158 | (defn keyword |
3090 | 3159 | "Returns a Keyword with the given namespace and name. Do not use : |
3091 | 3160 | in the keyword strings, it will be added automatically." |
@@ -10090,8 +10159,11 @@ reduces them without incurring seq initialization" |
10090 | 10159 | [multifn] (-dispatch-fn multifn)) |
10091 | 10160 |
|
10092 | 10161 | ;; UUID |
| 10162 | +(defprotocol IUUID "A marker protocol for UUIDs") |
10093 | 10163 |
|
10094 | 10164 | (deftype UUID [uuid ^:mutable __hash] |
| 10165 | + IUUID |
| 10166 | + |
10095 | 10167 | Object |
10096 | 10168 | (toString [_] uuid) |
10097 | 10169 | (equiv [this other] |
@@ -10131,6 +10203,9 @@ reduces them without incurring seq initialization" |
10131 | 10203 | (hex) (hex) (hex) (hex) |
10132 | 10204 | (hex) (hex) (hex) (hex)))))) |
10133 | 10205 |
|
| 10206 | +(defn ^boolean uuid? |
| 10207 | + [x] (implements? IUUID x)) |
| 10208 | + |
10134 | 10209 | ;;; ExceptionInfo |
10135 | 10210 |
|
10136 | 10211 | (defn- pr-writer-ex-info [obj writer opts] |
|
0 commit comments