@@ -23,7 +23,7 @@ aljibe de madera.
2323Add the following dependency to your project.clj file:
2424
2525``` clojure
26- funcool/cuerdas {:mvn/version " RELEASE " }
26+ funcool/cuerdas {:mvn/version " 2022.03.27-397 " }
2727```
2828
2929## Quick start
@@ -87,12 +87,43 @@ first line
8787another line
8888```
8989
90+ ### concat
91+
92+ This is a macro variant of ` clojure.core/str ` function that performs
93+ string concatenation. It is considerably faster on CLJS and slightly
94+ faster on JVM.
95+
96+ On CLJS, it uses the ` + ` native operator to perform the concatenation
97+ that is more optimized than the ` [].join(...) ` for the vast majority
98+ of cases. On the JVM it only simplifies contiguos strings that are
99+ know to be string instances at compile time.
100+
101+ ``` clojure
102+ (str/concat " foo" 1 " bar" )
103+ ; ; => "foo1bar"
104+ ```
105+
106+ There some benchmark result with huge number of items to concatenate:
107+
108+ ``` clojure
109+ ; ; => benchmarking: cljs.core/str
110+ ; ; --> WARM: 100000
111+ ; ; --> BENCH: 500000
112+ ; ; --> TOTAL: 197.82ms
113+ ; ; --> MEAN: 395.64ns
114+ ; ; => benchmarking: cuerdas.core/concat
115+ ; ; --> WARM: 100000
116+ ; ; --> BENCH: 500000
117+ ; ; --> TOTAL: 20.31ms
118+ ; ; --> MEAN: 40.63ns
119+ ```
90120
91121### istr
92122
93123String interpolation macro. Enables easy string formating allowing
94- symbol substitutions and simple expression evaluation.
95- At the moment not compatible with self-host ClojureScript.
124+ symbol substitutions and simple expression evaluation. Very similar to
125+ the ES6 template strings. At the moment not compatible with self-host
126+ ClojureScript.
96127
97128``` clojure
98129(def value 30 )
@@ -113,6 +144,35 @@ that will be concatenated on the final return value:
113144; ; => "the value is 30"
114145```
115146
147+ This macro ends using the fast string concatenation thanks to ` concat `
148+ macro.
149+
150+ ### ffmt
151+
152+ Another string formating, simplier alternative to the ` istr ` macro.
153+
154+ It works with two basic forms: sequencial and indexed. Let seen an
155+ example:
156+
157+
158+ ``` clojure
159+ (str/ffmt \"url(% )\" my-url) ; sequential
160+ (str/ffmt \"url(%1 )\" my-url) ; indexed
161+ ```
162+
163+ If you need the ` % ` character, just duplicate it:
164+
165+ ``` clojure
166+ (str/fmt " %1%%" 1 )
167+ ; ; => "1%"
168+
169+ (str/fmt " %%%" 1 )
170+ ; ; => "%1"
171+ ```
172+
173+ This macro ends using the fast string concatenation thanks to ` concat `
174+ macro.
175+
116176### alnum?
117177
118178Checks if a string contains only alphanumeric characters.
@@ -128,7 +188,6 @@ Checks if a string contains only alphanumeric characters.
128188; ; => true
129189```
130190
131-
132191### alpha?
133192
134193Checks if a string contains only alpha characters.
@@ -368,7 +427,9 @@ And you can access to indexed positions of an vector using `$0`, `$1`, `$N` synt
368427; ; => "hello yen"
369428```
370429
371- You can use ` str/fmt ` as shorter alias to ` str/format ` function.
430+ You can use ` str/fmt ` as shorter alias to ` str/format ` function. This
431+ performs the formatting at runtime, so consider using the ` istr ` or
432+ ` ffmt ` macros if you can, because they will have much lower overhead.
372433
373434
374435### human
@@ -1074,14 +1135,16 @@ expression that matches a single word (defaults to `[a-zA-Z0-9_-]+`).
10741135_ cuerdas_ has targeted some parts of implementation for Clojure and
10751136ClojureScript using Reader Conditionals.
10761137
1077- .Run tests in the Clojure environment.
1138+ Run tests in the Clojure environment:
1139+
10781140```
1079- $ clj -A :dev ./tools.clj test
1141+ $ clojure -M :dev: test
10801142```
10811143
1082- .Run tests in the ClojureScript environment.
1144+ Run tests in the ClojureScript environment:
1145+
10831146```
1084- $ clj -A :dev ./tools.clj test-cljs
1147+ $ clojure -M :dev ./tools.clj test <once|watch>
10851148```
10861149
10871150
@@ -1100,7 +1163,7 @@ restrictions for contributions.
11001163_ cuerdas_ is licensed under BSD (2-Clause) license:
11011164
11021165```
1103- Copyright (c) 2015-2016 Andrey Antukh <niwi@niwi.nz>
1166+ Copyright (c) 2015-Now Andrey Antukh <niwi@niwi.nz>
11041167
11051168All rights reserved.
11061169
@@ -1124,4 +1187,4 @@ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
11241187CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
11251188OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
11261189OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1127- ```
1190+ ```
0 commit comments