Git Product home page Git Product logo

cljs-priority-map's People

Contributors

alandipert avatar dubiousdavid avatar greenrecyclebin avatar leonoel avatar micha avatar ninjudd avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

cljs-priority-map's Issues

priority-map-keyfn

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.

Error: No reader function for tag tailrecursion.priority-map

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.

CleanShot 2022-08-25 at 19 39 50@2x

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)

Issue with priority-map-keyfn

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

Bad require example.

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

IMapEntry protocol errors with newer clojurescript

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)

Error: compare on non-nil objects of different types

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?

cljs.reader/reader-error removed in cljs v1.9.854

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:

(reader-error nil "Priority map literal expects a map for its elements.")))

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))))

(e.g. from https://github.com/clojure/clojurescript/blob/e86c36bb5408a0778bde6b56a292819d6d2af4c6/src/main/cljs/cljs/reader.cljs#L70-L72 )

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.