This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-11-14
Channels
- # adventofcode (1)
- # babashka (60)
- # beginners (107)
- # calva (11)
- # cider (3)
- # clara (11)
- # clj-kondo (6)
- # cljs-dev (33)
- # clojure (70)
- # clojure-dev (4)
- # clojure-europe (3)
- # clojure-italy (2)
- # clojure-kc (1)
- # clojure-losangeles (12)
- # clojure-nl (4)
- # clojure-spec (32)
- # clojure-uk (35)
- # clojuredesign-podcast (1)
- # clojurescript (28)
- # core-logic (4)
- # cursive (5)
- # datomic (34)
- # devcards (1)
- # emacs (16)
- # events (13)
- # fulcro (15)
- # graalvm (5)
- # graphql (3)
- # jobs (8)
- # joker (2)
- # kaocha (17)
- # malli (6)
- # music (3)
- # off-topic (58)
- # protorepl (7)
- # re-frame (28)
- # rewrite-clj (9)
- # shadow-cljs (102)
- # spacemacs (3)
- # sql (20)
- # tools-deps (9)
I was mainly looking for a way to check that something is a map. Was following a CLJ example using that
Gotcha, thinking about it that would make sense. Though there was a comment about making sure it wasn’t a scalar
Hello, guys
How can I evaluate/execute a javascript expression from a string?
suppose that I have this string function (e) {return e * 2}
... how can I invoke it?
In the browser console (or other environments if they allow it), usually eval("function f(e) {return e * 2}")
works, so in CLJS (js/eval "function f(e) {return e * 2}")
should be equivalent. However:
- for specifically the browser, 'eval' is blocked by content-security-policy ("CSP") on many pages, specific headers may be needed
it seems function
is a statement however so you don't get anything back you could use
Right. If I put in directly eval("function(e) {return e * 2}")
it says SyntaxError: function statement requires a name
.
function f(e) ...
works but then you can only get to the result via a global name - this name would be hit by advanced optimisations
\o/ tks, @spacemods @dpsutton it worked
I thought that cljs.analyzer.api/resolve
was doing that, but I'm also getting macros in there which I do not want
also anytime I try and print anything coming back from the analyzer, I get way too much data (like thousands of lines). is there a better way to inspect it?
Should be huge env map, dissoc :env
I think that I can detect function args and let bindings by checking to see if :local
equals :let
after calling resolve