Fork me on GitHub
#clojurescript
<
2022-05-18
>
pez08:05:43

There is a good reason why I can't use promesa.core/extract in ClojureScript, right?

(-> (p/create :a)
    (p/extract)) => No protocol method IState.-extract defined for type object: [object Promise]

thheller08:05:08

js promises don't have the concept of a current value. it can only ever be accessed via .then, which makes all access async even when resolved

🙏 1
apt17:05:31

Hi folks. This regex works fine for Clojure, but it won’t work when cljs is compiled to js:

#"^v[0-9-a-z]+{2,5}"
Error in browser:
Uncaught SyntaxError: Invalid regular expression: /^v[0-9-a-z]+{2,5}/: Nothing to repeat
I don’t have details on why it is invalid for js, but, in any case, I’m wondering if cljs could warn about it somehow.

p-himik17:05:14

I'm surprised it works in CLJ. What is that + supposed to mean? A literal plus?

apt17:05:13

Sorry, by ’works in cloure I meant “I can evaluate it with no errors”. But this is true of any regex that uses the #{} syntax anyway

apt17:05:55

So it would fail at runtime anyway, I suppose

Ben Wadsworth17:05:06

Yeah I don’t think you want the + which is adding meaning. you want V and 2-4 digits after?

apt17:05:10

I don’t have context on the original regex, I was just surprised that people noticed it only after the application did not work at all (because of the error). But I guess it makes sense.

Ben Wadsworth17:05:22

Sorry to be clear, you are saying you want “V” followed by alpha newmerics 1 or more times (the +) then you also want that 2 - 5 times, which doesnt make sense

Ben Wadsworth17:05:04

I am not sure why it works in CLJ… well. I wouldn’t say it “works” but you find a match against any alpha-numeric string following a V, regardless of length

Ben Wadsworth17:05:55

Well I guess it will “find” thats fine, you will just get the first grouping being the v + up to 5 alpha numerics… having the plus there seems to be valid in java land but would change your first match to be any length of digits after the v

danieroux19:05:29

May fit whatever cross-platform usecase you may have: https://github.com/lambdaisland/regal

dnolen17:05:34

@andre.peric I don't see any practical way to warn about regexes which are a host feature anyway

👍 3