(defn
invert-reverse-map
"Given a ClojureScript to JavaScript source map, invert it. Useful when\n mapping JavaScript stack traces when environment support is unavailable."
[reverse-map]
(let
[inverted (atom (sorted-map))]
(doseq
[[line columns] reverse-map]
(doseq
[[column column-info] columns]
(doseq
[{:keys [gline gcol name]} column-info]
(swap!
inverted
update-in
[gline]
(fnil
(fn
[columns]
(update-in
columns
[gcol]
(fnil conj [])
{:line line, :col column, :name name}))
(sorted-map))))))
@inverted))