File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -2185,6 +2185,22 @@ reduces them without incurring seq initialization"
21852185
21862186 :else false ))
21872187
2188+ (defn ^boolean float?
2189+ " Returns true for JavaScript numbers, false otherwise."
2190+ [x]
2191+ (number? x))
2192+
2193+ (defn ^boolean double?
2194+ " Returns true for JavaScript numbers, false otherwise."
2195+ [x]
2196+ (number? x))
2197+
2198+ (defn ^boolean infinite?
2199+ " Returns true for Infinity and -Infinity values."
2200+ [x]
2201+ (or (identical? x js/Number.POSITIVE_INFINITY)
2202+ (identical? x js/Number.NEGATIVE_INFINITY)))
2203+
21882204(defn ^boolean contains?
21892205 " Returns true if key is present in the given collection, otherwise
21902206 returns false. Note that for numerically indexed collections like
Original file line number Diff line number Diff line change 77; You must not remove this notice, or any other, from this software.
88
99(ns cljs.pprint
10- (:refer-clojure :exclude [deftype print println pr prn])
10+ (:refer-clojure :exclude [deftype print println pr prn float? ])
1111 (:require-macros
1212 [cljs.pprint :as m :refer [with-pretty-writer getf setf deftype
1313 pprint-logical-block print-length-loop
Original file line number Diff line number Diff line change 443443 `(spec (and c/int? #(int-in-range? ~start ~end %))
444444 :gen #(gen/large-integer* {:min ~start :max (dec ~end)})))
445445
446+ (defmacro double-in
447+ " Specs a 64-bit floating point number. Options:
448+
449+ :infinite? - whether +/- infinity allowed (default true)
450+ :NaN? - whether NaN allowed (default true)
451+ :min - minimum value (inclusive, default none)
452+ :max - maximum value (inclusive, default none)"
453+ [& {:keys [infinite? NaN? min max]
454+ :or {infinite? true NaN? true }
455+ :as m}]
456+ `(spec (and c/double?
457+ ~@(when-not infinite? '[#(not (infinite? %))])
458+ ~@(when-not NaN? '[#(not (js/isNaN %))])
459+ ~@(when max `[#(<= % ~max)])
460+ ~@(when min `[#(<= ~min %)]))
461+ :gen #(gen/double* ~m)))
462+
446463(defmacro merge
447464 " Takes map-validating specs (e.g. 'keys' specs) and
448465 returns a spec that returns a conformed map satisfying all of the
Original file line number Diff line number Diff line change @@ -94,7 +94,8 @@ gen-builtins
9494 pos-int? (large-integer* {:min 1 })
9595 neg-int? (large-integer* {:max -1 })
9696 nat-int? (large-integer* {:min 0 })
97- ; float? (double)
97+ float? (double )
98+ double? (double )
9899 string? (string-alphanumeric )
99100 ident? (one-of [(keyword-ns ) (symbol-ns )])
100101 simple-ident? (one-of [(keyword ) (symbol )])
You can’t perform that action at this time.
0 commit comments