tailrecursion / cljs-priority-map Goto Github PK
View Code? Open in Web Editor NEWPersistentPriorityMap for ClojureScript
PersistentPriorityMap for ClojureScript
6d4c384 added some new things that are discussed in data.priority-map's README but not in ours.
I think I need priority-map-keyfn
. I was wondering if there was a specific reason you left it out, and if you have any thoughts on how difficult it would be to add.
I'm happy to work on a patch adding it if you will accept it (and there isn't some better way to accomplish what I need). Specifically, I have a collection of items with ids and timestamps. I want to be able to look them up by id, but access them sequentially sorted by timestamp.
When we do pr-str
and then read-string
on a priority map, the reading fails.
I think this is because the priority-map reader is registered as a string, not a symbol.
To reproduce:
(cljs.reader/read-string (pr-str (pm/priority-map :a 1)))
To fix:
(cljs.reader/register-tag-parser! 'tailrecursion.priority-map pm/read-priority-map)
Hi, I am trying to use a priority map with a keyfn and I get the following error (using [tailrecursion/cljs-priority-map "1.1.0"])
(assoc (pm/priority-map-keyfn first :a [1] :b [1]) :a [2])
Error: compare on non-nil objects of different types
In the readme:
(ns your-ns
(:require [tailrecursion.priority-map :refer [priority-map priority-map-by])))
Should be:
(ns your-ns
(:require [tailrecursion.priority-map :refer [priority-map priority-map-by]]))
a parenthesis at the end should be a closing bracket
ran into the following using [org.clojure/clojure "1.9.0"] [org.clojure/clojurescript "1.10.238"]
and [tailrecursion/cljs-priority-map "1.2.1"]
user=> (def m (tailrecursion.priority-map/priority-map :a 2 :b 1 :c 3 :d 5 :e 4 :f 3))
#'user/m
user=>(vals m)
#object[TypeError TypeError: me.cljs$core$IMapEntry$_val$arity$1 is not a function]
cljs$core$ISeq$_first$arity$1 (jar:file:/Users/Joseph/.m2/repository/org/clojure/clojurescript/1.10.238/clojurescript-1.10.238.jar!/cljs/core.cljs:8955:13)
cljs.core/first (jar:file:/Users/Joseph/.m2/repository/org/clojure/clojurescript/1.10.238/clojurescript-1.10.238.jar!/cljs/core.cljs:1231:27)
cljs.pprint/pprint-reader-macro (jar:file:/Users/Joseph/.m2/repository/org/clojure/clojurescript/1.10.238/clojurescript-1.10.238.jar!/cljs/pprint.cljs:2797:36)
cljs$pprint$pprint_list (jar:file:/Users/Joseph/.m2/repository/org/clojure/clojurescript/1.10.238/clojurescript-1.10.238.jar!/cljs/pprint.cljs:2824:12)
G__12472__2 (jar:file:/Users/Joseph/.m2/repository/org/clojure/clojurescript/1.10.238/clojurescript-1.10.238.jar!/cljs/core.cljs:10851:8)
G__12472 (jar:file:/Users/Joseph/.m2/repository/org/clojure/clojurescript/1.10.238/clojurescript-1.10.238.jar!/cljs/core.cljs:10837:1)
cljs.pprint/write-out (jar:file:/Users/Joseph/.m2/repository/org/clojure/clojurescript/1.10.238/clojurescript-1.10.238.jar!/cljs/pprint.cljs:747:12)
Function.cljs$core$IFn$_invoke$arity$2 (jar:file:/Users/Joseph/.m2/repository/org/clojure/clojurescript/1.10.238/clojurescript-1.10.238.jar!/cljs/pprint.cljs:822:27)
cljs.pprint/pprint (jar:file:/Users/Joseph/.m2/repository/org/clojure/clojurescript/1.10.238/clojurescript-1.10.238.jar!/cljs/pprint.cljs:813:1)
figwheel$client$utils$pprint_to_string (jar:file:/Users/Joseph/.m2/repository/figwheel/figwheel/0.5.18/figwheel-0.5.18.jar!/figwheel/client/utils.cljs:82:6)
I've been using a priority-map inside an atom and I'm updating like the following:
(swap! my-priority-map update-in ["some key"] merge m)
The problem is that depending on the amount of keys in m
(it seems), the merge function will either return PersistentHashMap
or a PersistentArrayMap
Is there anyway that I can make the priority-map "not care" or force it to be one or the other?
As per https://cljs.github.io/api/cljs.reader/reader-error the function reader-error
was removed in version v1.9.854.
This breaks with:
Invalid :refer, var cljs.reader/reader-error does not exist
It is only used once at:
and could be replaced with:
(throw (js/Error. "Priority map literal expects a map for its elements."))
As the function used to be:
(defn reader-error [rdr & msg] (throw (js/Error. (apply str msg))))
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.