This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-07-06
Channels
- # aleph (1)
- # announcements (3)
- # asami (32)
- # aws (12)
- # babashka (6)
- # beginners (43)
- # calva (36)
- # cider (3)
- # clj-kondo (3)
- # cljs-dev (2)
- # clojars (6)
- # clojure (66)
- # clojure-europe (14)
- # clojure-uk (2)
- # clojurescript (12)
- # conjure (1)
- # core-async (27)
- # cursive (17)
- # data-science (9)
- # datahike (1)
- # datomic (28)
- # emacs (34)
- # events (1)
- # girouette (3)
- # jobs (1)
- # klipse (4)
- # lsp (26)
- # malli (5)
- # off-topic (38)
- # portal (1)
- # releases (1)
- # shadow-cljs (72)
- # sql (7)
- # tools-deps (5)
- # vim (9)
- # xtdb (18)
Is it possible to check code coverage for a cljs project which is targeting browser env? My current setup is shadow-cljs+deps.edn and karma for running tests but I couldn't find a way to check the code coverage for .cljs files. This is the :test build from shadow-cljs configuration:
{:target :karma
:output-to "target/karma.js"}
It seems to me it is impossible for karma to check the code coverage because its context is limited to the generated "karma.js" file.This is probably a really basic and stupid question, but I'm trying to get the ascii value for a character in clojurescript.
I have a map, called vm
, it has this structure
{:memory {0 65}
:dp 1
:input ["A" "B" "C"]}
I want to get the ascii value of the first item in input into :memory
with key 1
, then remove it from the input collection.
I thought I could do this:
(assoc-in vm [:memory (vm :dp)] (.charCodeAt (first (vm :input))))
But I get the error when I run it
> repl/invoke error TypeError: cljs.core.nth.call(...).charCodeAt is not a function
Am I doing the js interop wrong ?works for me
❯ clj -A:cljs -M -m cljs.main -re node -r
ClojureScript 1.10.773
cljs.user=> (let [vm {:memory {0 65}
:dp 1
:input ["A" "B" "C"]}]
(assoc-in vm [:memory (vm :dp)] (.charCodeAt (first (vm :input)))))
{:memory {0 65, 1 65}, :dp 1, :input ["A" "B" "C"]}
cljs.user=>
so maybe I'm somehow calling .charCodeAt on a non string ? Could that be what the error is trying to tell me ?
cljs.user=> (let [vm {:memory {0 65}
:dp 1
:input []}]
(assoc-in vm [:memory (vm :dp)] (.charCodeAt (first (vm :input)))))
Execution error (TypeError) at (<cljs repl>:1).
null is not an object (evaluating 'cljs.core.first.call(null,vm.call(null,new cljs.core.Keyword(null,"input","input",556931961))).charCodeAt')
cljs.user=>
calling on null
cljs.user=> (let [vm {:memory {0 65}
:dp 1
:input [2]}]
(assoc-in vm [:memory (vm :dp)] (.charCodeAt (first (vm :input)))))
Execution error (TypeError) at (<cljs repl>:1).
cljs.core.first.call(null,vm.call(null,new cljs.core.Keyword(null,"input","input",556931961))).charCodeAt is not a function. (In 'cljs.core.first.call(null,vm.call(null,new cljs.core.Keyword(null,"input","input",556931961))).charCodeAt()', 'cljs.core.first.call(null,vm.call(null,new cljs.core.Keyword(null,"input","input",556931961))).charCodeAt' is undefined)
cljs.user=>
calling on an integerHi, I am having a really basic issue with sending an image using ajax, this is my code:
(defn post-img [img-file]
(let [form-data (doto
(js/FormData.)
(.append "id" "10")
(.append "file" img-file "filename.txt"))]
(ajax/POST "localhost:8000/ocr"
{:body form-data
:format (ajax/text-request-format)
:response-format (ajax/json-response-format)
:timeout 5000})))
But nothing happens, it seems for me that the form data object is being created correctly, but the (ajax/POST….) does not really do anything, am I missing something obvious? Thanks in advance!it's probably not it, but text-request-format feels weird when sending a form data object
I also tried raw-request-format as well, but the result is the same
Ah, it was something very simple that I completely missed, it does not work with localhost:8000/…
, I just needed to change to
😅