zelark / nano-id Goto Github PK
View Code? Open in Web Editor NEWA unique string ID generator for Clojure and ClojureScript (・_・)ノ
License: MIT License
A unique string ID generator for Clojure and ClojureScript (・_・)ノ
License: MIT License
When downloading v0.9.3 from Clojars you get a pretty big 1.7MB jar.
https://clojars.org/nano-id
Resulting size should be around 10KB.
Let’s update the library to be compatible with the latest Nano ID 2.0:
~
to -
in default alphabetnon-secure
fast generatornano-id uses window.crypto
, but that object is not defined in nodejs.
nano-id/src/nano_id/random.cljc
Lines 7 to 9 in 1467b6a
Since new 1.0.0 version is going out soon, I wonder who's using nano-id? So if you use it in prod or just for hobby project, please drop a message below. I'd like to add a list to readme.
Also you might consider to start using it once 1.0.0 is released. ٩(◕‿◕。)۶
UPD: nano-id 1.0.0 was released. Give it a try.
A goal is generating IDs in lexicographical order. And there are 2 ways to reach for the goal:
(let [alphabet "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz~"
time-gen (fn [n] (take n (iterate #(bit-shift-right % 6)
(quot (System/currentTimeMillis) 1000))))
time-id (generate alphabet time-gen)]
(time-id 6))
Ran in to this error when I try to use a custom generator.
(def hex-id-generator (generate "0123456789abcdef"))
Exception
Uncaught TypeError: id.length is not a function
at nano_id.custom.generate.cljs$core$IFn$_invoke$arity$2 (custom.cljc?rel=1531759015549:22)
at my_tool$events$generate_system_key (events.cljs?rel=1531759024127:14)
at events.cljs?rel=1531759024127:96
at std_interceptors.cljc?rel=1531759023484:115
at re_frame$std_interceptors$db_handler__GT_interceptor_$_db_handler_before (std_interceptors.cljc?rel=1531759023484:111)
at re_frame$interceptor$invoke_interceptor_fn (interceptor.cljc?rel=1531759014576:68)
at re_frame$interceptor$invoke_interceptors (interceptor.cljc?rel=1531759014576:106)
at re_frame$interceptor$execute (interceptor.cljc?rel=1531759014576:199)
at re_frame$events$handle (events.cljc?rel=1531759022762:65)
at re_frame.router.EventQueue.re_frame$router$IEventQueue$_process_1st_event_in_queue$arity$1 (router.cljc?rel=1531759022973:178)
at re_frame$router$_process_1st_event_in_queue (router.cljc?rel=1531759022973:84)
at re_frame.router.EventQueue.re_frame$router$IEventQueue$_run_queue$arity$1 (router.cljc?rel=1531759022973:197)
at re_frame$router$_run_queue (router.cljc?rel=1531759022973:86)
at router.cljc?rel=1531759022973:145
at re_frame.router.EventQueue.re_frame$router$IEventQueue$_fsm_trigger$arity$3 (router.cljc?rel=1531759022973:168)
at re_frame$router$_fsm_trigger (router.cljc?rel=1531759022973:80)
at router.cljc?rel=1531759022973:186
Environment;
[org.clojure/clojurescript "1.10.238"]
[reagent "0.7.0"]
[re-frame "0.10.5"]
[nano-id "0.9.2"]
[com.andrewmcveigh/cljs-time "0.5.2"]
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.