diff --git a/.gitignore b/.gitignore index eea0e79..7e79506 100644 --- a/.gitignore +++ b/.gitignore @@ -14,3 +14,5 @@ pom.xml.asc .lein-failures .lein-plugins .lein-repl-history +.idea +thread-expr.iml diff --git a/README.md b/README.md index 04aca65..28d00c7 100644 --- a/README.md +++ b/README.md @@ -58,6 +58,26 @@ Expands to: ;=> 7 ``` +## ClojureScript + +In order to use the library with [ClojureScript](https://github.com/clojure/clojurescript) we use [readers conditionals](http://clojure.org/guides/reader_conditionals). + +You need to use `:require-macros` in your namespace. For example: +```clojure +;; example_ns.cljs +(ns example-ns + (:require-macros [pallet.thread-expr :as th])) +``` + +Also, you can use both with readers conditionals: + +```clojure +;; example_ns.cljc +(ns example-ns + #?(:cljs (:require-macros [pallet.thread-expr :as th])) + #?(:clj (:require [pallet.thread-expr :as th]))) +``` + ## Installation thread-expr is distributed as a jar, and is available in the diff --git a/project.clj b/project.clj index c96ea11..7b4141e 100644 --- a/project.clj +++ b/project.clj @@ -1,8 +1,9 @@ -(defproject com.palletops/thread-expr "1.3.1-SNAPSHOT" +(defproject com.palletops/thread-expr "1.4.0" :description "Thread-expr provides macros for use within a clojure threaded argument expressions (-> and ->>)." :url "http://palletops.com" :license {:name "Eclipse Public License" :url "http://www.eclipse.org/legal/epl-v10.html"} - :dependencies [[org.clojure/clojure "1.2.1"] - [org.clojure/tools.macro "0.1.1"]]) + + :dependencies [[org.clojure/clojure "1.7.0"] + [org.clojure/tools.macro "0.1.2"]]) diff --git a/src/pallet/thread_expr.clj b/src/pallet/thread_expr.cljc similarity index 99% rename from src/pallet/thread_expr.clj rename to src/pallet/thread_expr.cljc index 0420a12..4974956 100644 --- a/src/pallet/thread_expr.clj +++ b/src/pallet/thread_expr.cljc @@ -1,6 +1,7 @@ (ns pallet.thread-expr "Macros that can be used in an expression thread." - (:require [clojure.tools.macro :as macro])) + #?(:clj (:require [clojure.tools.macro :as macro]))) + (letfn [(for- [threader arg seq-exprs body] `(reduce #(%2 %1)