Fork me on GitHub

Is there a cljs equivalent to Throwable->map?


It might be a bit tricky in JS given that any kind of object can be thrown. I’m guessing that you’re looking to convert an Error object into a map?


It doesn’t attempt to parse the stack trace into a seq, but here is a simple attempt


It should provide something regardless of the type you give it, but it will provide the most data if you give it something that extends Error


cljs.user=> (Throwable->map {})
{:type cljs.core/PersistentArrayMap, :message "{}"}

cljs.user=> (Throwable->map "Error")
{:type String, :message "Error"}

cljs.user=> (Throwable->map (js/Error "There was an error"))
{:type Error,
 :message "There was an error",
 :stack "Error: There was an error\n    at repl:1:127\n    at repl:9:3\n    at repl:14:4\n    at Script.runInThisContext (node:vm:129:12)\n    at Object.runInThisContext (node:vm:313:38)\n    at Domain.<anonymous> ([stdin]:76:38)\n    at (node:domain:389:15)\n    at Socket.<anonymous> ([stdin]:73:29)\n    at Socket.emit (node:events:513:28)\n    at Socket.emit (node:domain:489:12)"}


In case this is useful, I put it on github:


That's great, thank you! I was expecting a yes/no 🙂


I'd love to see it on clojars too


I will. I just need some tests


hi everybody! I'm trying to figure out if it is possible to implement tooling that can interact with js runtimes (browser, node) thru a clojurescript repl. This is, instead of making tooling that connects via websocket to the js runtime, make everything thru clojurescript repls. Sending a command is just writing a form on the repl, but is there a way of implementing runtime sent events without constantly polling? Something like long polling, where I write on the repl (wait-for-events) and it will block there until something happens en the js runtime and then return?

Ted Ciafardini18:08:13

hello. I’ve been exploring the Google Closure Library a bit & I was wondering if there were any goog.closure classes/methods/vars that people in the community especially appreciate and/or would recommend looking into? gratitude


There are many “hidden” gems. 🙂 With a quick grep I’ve used functions from these modules: • goog.object • goog.string.format • goog.string.path • • goog.color • goog.color.alpha • goog.functions • goog.array • goog.crypt.base64 • goog.labs.userAgent.browser

gratitude-danke 2

Also goog.async.Debouncer, goog.dom.ViewportSizeMonitor


goog.Uri (used by cljs.core) goog.StringBuffer (really useful for portable Java/JavaScript interop, since a number of libraries write to files or string with .append)


I did play a bit with goog.math.Long, but found better ways 🙂


IWriter in cljs.core uses StringBuffer, and it’s all through that namespace

thanks2 1