diff --git a/project.clj b/project.clj index fd2966b..6d2edaf 100644 --- a/project.clj +++ b/project.clj @@ -46,4 +46,5 @@ :aliases {"cleantest" ["do" "clean," "cljx" "once," "test"] - "deploy" ["do" "clean," "cljx" "once," "deploy" "clojars"]}) + "deploy" ["do" "clean," "cljx" "once," "deploy" "clojars"]} + ) diff --git a/repl.clj b/repl.clj index fb0ad2b..c472bca 100644 --- a/repl.clj +++ b/repl.clj @@ -4,7 +4,15 @@ (cljs.build.api/build "target/classes/com/rpl" {:output-to "out/main.js" - :verbose true}) + :verbose true + :warning-handlers [(fn [warning-type env extra] + (when (warning-type cljs.analyzer/*cljs-warnings*) + (when-let [s (cljs.analyzer/error-message warning-type extra)] + (binding [*out* *err*] + (println "WARNING:" (cljs.analyzer/message env s)) + (println "Failed to build because of warning!") + ) + (System/exit 1))))]}) (cljs.repl/repl (cljs.repl.node/repl-env) :watch "target/classes/com/rpl" diff --git a/scripts/benchmarks.clj b/scripts/benchmarks.clj index 3a1800e..cf80a41 100644 --- a/scripts/benchmarks.clj +++ b/scripts/benchmarks.clj @@ -1,7 +1,7 @@ (ns com.rpl.specter.benchmarks (:use [com.rpl.specter] [com.rpl.specter macros] - [com.rpl.specter.transient] + [com.rpl.specter.transients] [com.rpl.specter.impl :only [benchmark]]) (:require [clojure.walk :as walk])) diff --git a/src/clj/com/rpl/specter/transient.cljx b/src/clj/com/rpl/specter/transient.cljx deleted file mode 100644 index dd11f36..0000000 --- a/src/clj/com/rpl/specter/transient.cljx +++ /dev/null @@ -1,91 +0,0 @@ -(ns com.rpl.specter.transient - #+cljs - (:require-macros [com.rpl.specter.macros - :refer - [defnav - defpathedfn]]) - (:use #+clj - [com.rpl.specter.macros :only - [defnav - defpathedfn]]) - (:require [com.rpl.specter.impl :as i] - [com.rpl.specter :refer [subselect selected?]])) - -(defnav - ^{:doc "Navigates to the specified key of a transient collection, - navigating to nil if it doesn't exist."} - keypath! - [key] - (select* [this structure next-fn] - (next-fn (get structure key))) - (transform* [this structure next-fn] - (assoc! structure key (next-fn (get structure key))))) - -(def END! - "Navigates to an empty (persistent) vector at the end of a transient vector." - (i/comp-paths* (i/->TransientEndNavigator))) - -(defn- t-get-first - [tv] - (nth tv 0)) - -(defn- t-get-last - [tv] - (nth tv (dec (i/transient-vec-count tv)))) - -(defn- t-update-first - [tv next-fn] - (assoc! tv 0 (next-fn (nth tv 0)))) - -(defn- t-update-last - [tv next-fn] - (let [i (dec (i/transient-vec-count tv))] - (assoc! tv i (next-fn (nth tv i))))) - -(def FIRST! - "Navigates to the first element of a transient vector." - (i/->PosNavigator t-get-first t-update-first)) - -(def LAST! - "Navigates to the last element of a transient vector." - (i/->PosNavigator t-get-last t-update-last)) - -#+clj -(defn- select-keys-from-transient-map - "Selects keys from transient map, because built-in select-keys uses - `find` which is unsupported." - [m m-keys] - (loop [result {} - m-keys m-keys] - (if-not (seq m-keys) - result - (let [k (first m-keys) - ;; support Clojure 1.6 where contains? is broken on transients - item (get m k ::not-found)] - (recur (if-not (identical? item ::not-found) - (assoc result k item) - result) - (rest m-keys)))))) - -#+cljs -(defn- select-keys-from-transient-map - "Uses select-keys on a transient map." - [m m-keys] - (select-keys m m-keys)) - -(defnav - ^{:doc "Navigates to the specified persistent submap of a transient map."} - submap! - [m-keys] - (select* [this structure next-fn] - (next-fn (select-keys-from-transient-map structure m-keys))) - (transform* [this structure next-fn] - (let [selected (select-keys-from-transient-map structure m-keys) - res (next-fn selected)] - (as-> structure % - (reduce (fn [m k] - (dissoc! m k)) - % m-keys) - (reduce-kv (fn [m k v] - (assoc! m k v)) - % res))))) diff --git a/test/com/rpl/specter/core_test.cljx b/test/com/rpl/specter/core_test.cljx index 6493f6c..96f866f 100644 --- a/test/com/rpl/specter/core_test.cljx +++ b/test/com/rpl/specter/core_test.cljx @@ -27,7 +27,7 @@ #+cljs [cljs.test.check.generators :as gen] #+cljs [cljs.test.check.properties :as prop :include-macros true] [com.rpl.specter :as s] - [com.rpl.specter.transient :as t] + [com.rpl.specter.transients :as t] [clojure.set :as set])) ;;TODO: