This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-09-13
Channels
- # announcements (15)
- # babashka (48)
- # beginners (5)
- # biff (4)
- # calva (3)
- # cider (10)
- # clerk (16)
- # clj-kondo (6)
- # cljdoc (20)
- # cljs-dev (13)
- # clojure (117)
- # clojure-argentina (1)
- # clojure-brasil (5)
- # clojure-europe (40)
- # clojure-nl (1)
- # clojure-norway (111)
- # clojure-uk (5)
- # clojurescript (16)
- # cursive (20)
- # datascript (2)
- # datomic (106)
- # etaoin (2)
- # events (3)
- # funcool (1)
- # graphql (1)
- # helix (8)
- # hyperfiddle (36)
- # leiningen (12)
- # matrix (1)
- # nrepl (1)
- # off-topic (61)
- # other-languages (10)
- # polylith (22)
- # practicalli (1)
- # reagent (28)
- # reitit (11)
- # remote-jobs (3)
- # ring (12)
- # shadow-cljs (109)
- # slack-help (6)
- # solo-full-stack (23)
- # squint (7)
- # xtdb (11)
After require
ing a npm package, is it possible to inspect all objs or methods behind the namespace?
btw, why [cljs.repl/dir](https://cljs.github.io/api/cljs.repl/dir) is not working in my cljs repl
cljs꞉dudee.core꞉>
cljs.repl
#js {:print_doc #object[cljs$repl$print_doc], :Error__GT_map #object[cljs$repl$Error__GT_map], :ex_triage #object[cljs$repl$ex_triage], :ex_str #object[cljs$repl$ex_str], :error__GT_str #object[cljs$repl$error__GT_str]}
cljs꞉dudee.core꞉>
cljs.repl/dir
nil
; ------ WARNING - :undeclared-var -----------------------------------------------
; Resource: <eval>:1:1
; Can't take value of macro cljs.repl/dir
; --------------------------------------------------------------------------------
you can use (require '["whatever-npm" :as x])
(js/console.log x)
or (js/console.dir x)
I want to interop with this in cljs:
const jwksClient = require('jwks-rsa');
const client = jwksClient({
jwksUri: '',
requestHeaders: {}, // Optional
timeout: 30000 // Defaults to 30s
});
I'm using this in cljs (and variations like it):
(ns my-ns
(:require [jwks-rsa]))
(comment
(jwks-rsa #js {:jwksUri "blahblah"})
)
It doesn't like me calling jwks-rsa directly. Any ideas what I should be doing differently?I've also tried
...(:require [jwks-rsa :as jwks-client])
(jwks-client ...)
(js/jwks-client ...)
(jwks-client/jwks-client ...)
(new jwks-client ...)
You need to integrate npm module. https://clojurescript.org/news/2017-07-12-clojurescript-is-not-an-island-integrating-node-modules Or you can use shadow-cljs as your compiler: https://shadow-cljs.github.io/docs/UsersGuide.html#js-deps
Thank you @U4EFBUCUE It turns out I needed
[jwks-rsa :refer [JwksClient]]
(new JwksClient ...)
Hey everyone, what are some ways of converting a clojure form into a javascript string inside a clojure app? I've looked into the cljs comipler as well as squint/cherry but haven't seen an obvious answer.
for example:
(defn double [n] (+ n n))
(defn handler [_]
{:status 200,
:headers {"content-type" "text/javascript"}
:body (clj->js double)})
what could provide the clj->js
function?Unless you literally want to compile double
as cljs? I'm not sure if thats feasible
Thanks for the reply. I'd expect the string output to be something similar to function double(n) {n + n}
or at least something that behaves similarly inside of a js interpreter
I think you'd need to write a simple interpreter for that (if there's no way out) I wrote a simple interpreter sometime ago (not complete though) that can interpret some clj forms and run them. This can be transformed to JS forms of its that important and Maybe be helpful for you (if you don't mind) https://github.com/naxiwaynez10/hw6