Fork me on GitHub
#clojurescript
<
2015-07-05
>
afhammad00:07:35

how do you add the case insensitive flag in clojurescript regex? looking at the source it looks like #"(?i)..." but doesn't seem to work

mikethompson01:07:03

@afhammad: I ran into the same issue. Ended up going directly to js.

(def rx   (js/RegExp.  "(o)"  "ig"))    ;;  case insensitive, not greedy

(.split "hellO thereO" rx)
;;=> #js ["hell" "O" " there" "O" ""]

jwm03:07:28

I personally will usually pick the most terse form which is js/RegExp as mikethompson showed

jwm03:07:41

unless there is a big speed difference

Petrus Theron08:07:52

Which Clojurescript libraries occupy the largest % of an advanced compiled JS file? Gzipped app.js is 103KB. How small can you package React and Reagent?

Petrus Theron08:07:10

Hm. cljs.core seems to be 263KB unzipped. Any way to shave some bytes off?

dnolen12:07:26

@petrus: React is probably bigger than cljs.core. You can't really do better than advanced compilation.

dnolen14:07:01

@a.espolov: you don’t have to bind it

dnolen14:07:42

(did-mount [this] (.addEventListener js/window “resize” (fn [e] (handle-resize this e)))

dnolen14:07:57

if you really want to bind, see goog.bind

meow20:07:27

I've got a cljs map object that I want to display in hiccup html [:p (str some-map)] and I need something other than str because that just returns [object Object]. Note that some-map is shallow with simple keys and values. Any suggestions?

meow20:07:46

This is just to display it for development purposes.

meow20:07:52

doh! Why didn't I think of that?

mfikes20:07:37

@meow: I'm curious. Where is your map from? (str {:a 1 :b 2}) yields a nice string.

meow20:07:02

@mfikes: double doh! You are correct. My problem wasn't with str but with the fact that the map was coming from a cursor and freagent treated it differently. Normally it will deref the cursor automagically but in this case I needed to @foo the thing explicitly.

mfikes20:07:05

Cool. (str (clj->js {:a 1 :b 2})) produces "[object Object]" and David's suggestion of pr-str yields nice (`#js`) for that case. Was just curious.

meow20:07:41

And pr-str gave me the clue that my object was a cursor... simple_smile

meow20:07:19

I'm working on an app to provide information about the html environment for developers. Also just exploring the use of freagent, core.async, and Google Closure. https://github.com/decomplect/ing/blob/master/informing/src/app/core.cljs

meow20:07:28

And a library of Google Closure and core.async stuff: https://github.com/decomplect/ion/blob/master/src/ion/poly/core.cljs