Fork me on GitHub
#clojurescript
<
2020-10-13
>
suren08:10:31

Whats the Clojurescript equivalence of Javascript re.exec ? re-maches returns the string and captured group without name. Is there a way to get the captured group name and its value ? For example for regex "^/item/(?<itemid>[a-zA-Z0-9-]+?)$" I want to get the {:itemid 1} for string /item/1 .

p-himik10:10:06

Nothing built-in. You can just JS interop or some thirdparty library.

suren02:10:23

I have tried (.exe (RegExp. ...) too. It seems the value returned by .exe is a malformed Javascript Array. It has the value that looks something like this.

{0: <actual-str>, 1: <match-groups>, matches: {..}}
Now when this value is parsed by Clojurescript it thinks its an array and only returns [<actual-str>, <match-groups>]

suren02:10:40

It makes sense cos Array in Javascript is an Object whos keys are numbers.

p-himik11:10:00

It's not a malformed array. In JavaScript world, it's a proper array-like object with custom fields. Or something like that. Do not convert it to CLJS using js->clj. Just use interop: (.-matches result).

p-himik11:10:25

The matches themselves can be converted with js->clj if you really need it.

suren09:10:38

It worked. Thanks buddy

👍 3
jmckitrick13:10:43

What’s the best non-chrome browser for cljs development these days?

p-himik13:10:27

Given that most browsers are based on Chromium and generally provide only user-facing changes, I'm pretty sure that your only alternative is Firefox.

p-himik13:10:04

But its DevTools are not yet as extendable as Chrome's AFAIK.

jmckitrick18:10:00

Yeah, FF was on the verge of implementing the custom formatters, but it got squashed after downsizing 😞

p-himik18:10:28

Oh, that sucks, I didn't know about that.

jmckitrick15:10:05

Yeah, I was really excited about it, too. Was hoping to be mentored and help with the feature.

jmckitrick21:10:19

Would Safari be a huge step down for cljs dev? I’d like to commit to Safari or FF for an upcoming large project. Don’t want to re-learn tools in the middle of something big….

jmckitrick21:10:45

Seems Safari would be optimized for my mbp, which could be a good thing. And it’s WebKit.

p-himik22:10:17

I don't remember seeing anything good about WebKit that wouldn't also be true for Chrome/FF. But I remember quite a few instances were it didn't work as expected. Also not sure what "optimized" would mean here. If it work fast enough both for you and your users, then all is good.

jmckitrick22:10:14

I just hate Google and Chrome now. It’s totally irrational, but there it is.

jmckitrick22:10:39

I just want to support the alternatives.

jmckitrick22:10:00

‘optimized’ = runs better on the mac I’m developing on

Rico Meinl21:10:15

#shadow-cljs I’m importing a library via :require . Then after doing the shadow-cljs release to a node-library I get this error when importing it into the browser. Does anyone know why it doesnt resolve the require durin the build?

thheller21:10:59

because as the name implies it is building a node-library. intended to run in node, not in the browser?