Moved web root into root of project; this makes deployment easier.

Also deleted 'docs', which is now redundant.
This commit is contained in:
Simon Brooke 2020-02-27 14:18:29 +00:00
parent a5204c66b9
commit 743d8a1740
No known key found for this signature in database
GPG key ID: A7A4F18D1D4DF987
1592 changed files with 53626 additions and 139250 deletions

View file

@ -0,0 +1,290 @@
(ns no.en.core
(:refer-clojure :exclude [replace read-string])
(:require [clojure.string :refer [blank? join replace split upper-case]]
#?(:clj [clojure.edn :refer [read-string]])
#?(:cljs [cljs.reader :refer [read-string]])
#?(:cljs [goog.crypt.base64 :as base64]))
#?(:clj (:import [java.net URLEncoder URLDecoder]
[org.apache.commons.codec.binary Base64])))
(def port-number
{:amqp 5672
:http 80
:https 443
:mysql 3306
:postgresql 5432
:rabbitmq 5672
:zookeeper 2181})
(def url-regex #"([^:]+)://(([^:]+):([^@/]+)@)?(([^:/]+)(:([0-9]+))?((/[^?#]*)(\?([^#]*))?)?)(\#(.*))?")
(defn split-by-regex
"Split the string `s` by the regex `pattern`."
[s pattern]
(if (sequential? s)
s (if-not (blank? s)
(split s pattern))))
(defn split-by-comma
"Split the string `s` by comma."
[s] (split-by-regex s #"\s*,\s*"))
(defn utf8-string
"Returns `bytes` as an UTF-8 encoded string."
[bytes]
#?(:clj (String. bytes "UTF-8")
:cljs (throw (ex-info "utf8-string not implemented yet" bytes))))
(defn base64-encode
"Returns `s` as a Base64 encoded string."
[bytes]
(when bytes
#?(:clj (String. (Base64/encodeBase64 bytes))
:cljs (base64/encodeString bytes false))))
(defn base64-decode
"Returns `s` as a Base64 decoded string."
[s]
(when s
#?(:clj (Base64/decodeBase64 (.getBytes s))
:cljs (base64/decodeString s false))))
(defn compact-map
"Removes all map entries where the value of the entry is empty."
[m]
(reduce
(fn [m k]
(let [v (get m k)]
(if (or (nil? v)
(and (or (map? v)
(sequential? v))
(empty? v)))
(dissoc m k) m)))
m (keys m)))
(defn url-encode
"Returns `s` as an URL encoded string."
[s & [encoding]]
(when s
#?(:clj (-> (URLEncoder/encode (str s) (or encoding "UTF-8"))
(replace "%7E" "~")
(replace "*" "%2A")
(replace "+" "%20"))
:cljs (-> (js/encodeURIComponent (str s))
(replace "*" "%2A")))))
(defn url-decode
"Returns `s` as an URL decoded string."
[s & [encoding]]
(when s
#?(:clj (URLDecoder/decode s (or encoding "UTF-8"))
:cljs (js/decodeURIComponent s))))
(defn pow [n x]
#?(:clj (Math/pow n x)
:cljs (.pow js/Math n x)))
(def byte-scale
{"B" (pow 1024 0)
"K" (pow 1024 1)
"M" (pow 1024 2)
"G" (pow 1024 3)
"T" (pow 1024 4)
"P" (pow 1024 5)
"E" (pow 1024 6)
"Z" (pow 1024 7)
"Y" (pow 1024 8)})
(defn- apply-unit [number unit]
(if (string? unit)
(case (upper-case unit)
(case unit
"M" (* number 1000000)
"B" (* number 1000000000)))
number))
(defn- parse-number [s parse-fn]
(if-let [matches (re-matches #"\s*([-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?)(M|B)?.*" (str s))]
#?(:clj
(try (let [number (parse-fn (nth matches 1))
unit (nth matches 3)]
(apply-unit number unit))
(catch NumberFormatException _ nil))
:cljs
(let [number (parse-fn (nth matches 1))
unit (nth matches 3)]
(if-not (js/isNaN number)
(apply-unit number unit))))))
(defn parse-bytes [s]
(if-let [matches (re-matches #"\s*([-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?)(B|K|M|G|T|P|E|Z|Y)?.*" (str s))]
(let [number (read-string (nth matches 1))
unit (nth matches 3)]
(long (* (long (read-string (str (nth matches 1))))
(get byte-scale (upper-case (or unit "")) 1))))))
(defn parse-integer
"Parse `s` as a integer number."
[s]
(parse-number s #(#?(:clj Integer/parseInt :cljs js/parseInt) %1)))
(defn parse-long
"Parse `s` as a long number."
[s]
(parse-number s #(#?(:clj Long/parseLong :cljs js/parseInt) %1)))
(defn parse-double
"Parse `s` as a double number."
[s]
(parse-number s #(#?(:clj Double/parseDouble :cljs js/parseFloat) %1)))
(defn parse-float
"Parse `s` as a float number."
[s]
(parse-number s #(#?(:clj Float/parseFloat :cljs js/parseFloat) %1)))
(defn format-query-params
"Format the map `m` into a query parameter string."
[m]
(let [params (->> (sort-by first (seq m))
(remove #(blank? (str (second %1))))
(map #(vector (url-encode (name (first %1)))
(url-encode (second %1))))
(map #(join "=" %1))
(join "&"))]
(if-not (blank? params)
params)))
(defn format-url
"Format the Ring map as an url."
[m]
(if (not (empty? m))
(let [query-params (:query-params m)]
(str (if (:scheme m)
(str (name (:scheme m)) "://"))
(let [{:keys [username password]} m]
(when username
(str username (when password (str ":" password)) "@")))
(:server-name m)
(if-let [port (:server-port m)]
(if-not (= port (port-number (:scheme m)))
(str ":" port)))
(if (and (nil? (:uri m))
(not (empty? query-params)))
"/" (:uri m))
(if-not (empty? query-params)
(str "?" (format-query-params query-params)))
(if-not (blank? (:fragment m))
(str "#" (:fragment m)))))))
(defn public-url
"Return the formatted `url` without password as a string."
[url]
(format-url (dissoc url :password)))
(defn parse-percent
"Parse `s` as a percentage."
[s]
(parse-double (replace s "%" "")))
(defn pattern-quote
"Quote the special characters in `s` that are used in regular expressions."
[s]
(replace (name s) #"([\[\]\^\$\|\(\)\\\+\*\?\{\}\=\!.])" "\\\\$1"))
(defn separator
"Returns the first string that separates the components in `s`."
[s]
(if-let [matches (re-matches #"(?i)([a-z0-9_-]+)([^a-z0-9_-]+).*" s)]
(nth matches 2)))
(defn parse-query-params
"Parse the query parameter string `s` and return a map."
[s]
(if s
(->> (split (str s) #"&")
(map #(split %1 #"="))
(filter #(= 2 (count %1)))
(mapcat #(vector (keyword (url-decode (first %1))) (url-decode (second %1))))
(apply hash-map))))
(defn parse-url
"Parse the url `s` and return a Ring compatible map."
[s]
(if-let [matches (re-matches url-regex (str s))]
(let [scheme (keyword (nth matches 1))]
(compact-map
{:scheme scheme
:username (nth matches 3)
:password (nth matches 4)
:server-name (nth matches 6)
:server-port (or (parse-integer (nth matches 8)) (port-number scheme))
:uri (nth matches 10)
:query-params (parse-query-params (nth matches 12))
:query-string (nth matches 12)
:fragment (nth matches 14)}))))
(defmacro prog1 [& body]
"Evaluate `body`, returning the result of the first form."
`(let [result# ~(first body)]
~@(rest body)
result#))
(defn with-retries*
"Executes thunk. If an exception is thrown, will retry. At most n retries
are done. If still some exception is thrown it is bubbled upwards in
the call chain."
[n thunk]
(loop [n n]
(if-let [result
(try
[(thunk)]
(catch #?(:clj Exception :cljs js/Error) e
(when (zero? n)
(throw e))))]
(result 0)
(recur (dec n)))))
(defmacro with-retries
"Executes body. If an exception is thrown, will retry. At most n retries
are done. If still some exception is thrown it is bubbled upwards in
the call chain."
[n & body]
`(no.en.core/with-retries* ~n (fn [] ~@body)))
(defn- editable? [coll]
#?(:clj (instance? clojure.lang.IEditableCollection coll)
:cljs (satisfies? cljs.core.IEditableCollection coll)))
(defn- reduce-map [f coll]
(if (editable? coll)
(persistent! (reduce-kv (f assoc!) (transient (empty coll)) coll))
(reduce-kv (f assoc) (empty coll) coll)))
(defn map-keys
"Maps a function over the keys of an associative collection."
[f coll]
(reduce-map (fn [xf] (fn [m k v] (xf m (f k) v))) coll))
(defn map-vals
"Maps a function over the values of an associative collection."
[f coll]
(reduce-map (fn [xf] (fn [m k v] (xf m k (f v)))) coll))
(defn deep-merge
"Like merge, but merges maps recursively."
[& maps]
(if (every? map? maps)
(apply merge-with deep-merge maps)
(last maps)))
(defn deep-merge-with
"Like merge-with, but merges maps recursively, applying the given fn
only when there's a non-map at a particular level."
[f & maps]
(apply
(fn m [& maps]
(if (every? map? maps)
(apply merge-with m maps)
(apply f maps)))
maps))

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,628 @@
// Compiled by ClojureScript 1.10.520 {}
goog.provide('no.en.core');
goog.require('cljs.core');
goog.require('clojure.string');
goog.require('cljs.reader');
goog.require('goog.crypt.base64');
no.en.core.port_number = new cljs.core.PersistentArrayMap(null, 7, [new cljs.core.Keyword(null,"amqp","amqp",-994422895),(5672),new cljs.core.Keyword(null,"http","http",382524695),(80),new cljs.core.Keyword(null,"https","https",-1983909665),(443),new cljs.core.Keyword(null,"mysql","mysql",-1431590210),(3306),new cljs.core.Keyword(null,"postgresql","postgresql",-1568339962),(5432),new cljs.core.Keyword(null,"rabbitmq","rabbitmq",1046897371),(5672),new cljs.core.Keyword(null,"zookeeper","zookeeper",17281735),(2181)], null);
no.en.core.url_regex = /([^:]+):\/\/(([^:]+):([^@\/]+)@)?(([^:\/]+)(:([0-9]+))?((\/[^?#]*)(\?([^#]*))?)?)(\#(.*))?/;
/**
* Split the string `s` by the regex `pattern`.
*/
no.en.core.split_by_regex = (function no$en$core$split_by_regex(s,pattern){
if(cljs.core.sequential_QMARK_.call(null,s)){
return s;
} else {
if((!(clojure.string.blank_QMARK_.call(null,s)))){
return clojure.string.split.call(null,s,pattern);
} else {
return null;
}
}
});
/**
* Split the string `s` by comma.
*/
no.en.core.split_by_comma = (function no$en$core$split_by_comma(s){
return no.en.core.split_by_regex.call(null,s,/\s*,\s*/);
});
/**
* Returns `bytes` as an UTF-8 encoded string.
*/
no.en.core.utf8_string = (function no$en$core$utf8_string(bytes){
throw cljs.core.ex_info.call(null,"utf8-string not implemented yet",bytes);
});
/**
* Returns `s` as a Base64 encoded string.
*/
no.en.core.base64_encode = (function no$en$core$base64_encode(bytes){
if(cljs.core.truth_(bytes)){
return goog.crypt.base64.encodeString(bytes,false);
} else {
return null;
}
});
/**
* Returns `s` as a Base64 decoded string.
*/
no.en.core.base64_decode = (function no$en$core$base64_decode(s){
if(cljs.core.truth_(s)){
return goog.crypt.base64.decodeString(s,false);
} else {
return null;
}
});
/**
* Removes all map entries where the value of the entry is empty.
*/
no.en.core.compact_map = (function no$en$core$compact_map(m){
return cljs.core.reduce.call(null,(function (m__$1,k){
var v = cljs.core.get.call(null,m__$1,k);
if((((v == null)) || (((((cljs.core.map_QMARK_.call(null,v)) || (cljs.core.sequential_QMARK_.call(null,v)))) && (cljs.core.empty_QMARK_.call(null,v)))))){
return cljs.core.dissoc.call(null,m__$1,k);
} else {
return m__$1;
}
}),m,cljs.core.keys.call(null,m));
});
/**
* Returns `s` as an URL encoded string.
*/
no.en.core.url_encode = (function no$en$core$url_encode(var_args){
var args__4736__auto__ = [];
var len__4730__auto___21390 = arguments.length;
var i__4731__auto___21391 = (0);
while(true){
if((i__4731__auto___21391 < len__4730__auto___21390)){
args__4736__auto__.push((arguments[i__4731__auto___21391]));
var G__21392 = (i__4731__auto___21391 + (1));
i__4731__auto___21391 = G__21392;
continue;
} else {
}
break;
}
var argseq__4737__auto__ = ((((1) < args__4736__auto__.length))?(new cljs.core.IndexedSeq(args__4736__auto__.slice((1)),(0),null)):null);
return no.en.core.url_encode.cljs$core$IFn$_invoke$arity$variadic((arguments[(0)]),argseq__4737__auto__);
});
no.en.core.url_encode.cljs$core$IFn$_invoke$arity$variadic = (function (s,p__21386){
var vec__21387 = p__21386;
var encoding = cljs.core.nth.call(null,vec__21387,(0),null);
if(cljs.core.truth_(s)){
return clojure.string.replace.call(null,encodeURIComponent(cljs.core.str.cljs$core$IFn$_invoke$arity$1(s)),"*","%2A");
} else {
return null;
}
});
no.en.core.url_encode.cljs$lang$maxFixedArity = (1);
/** @this {Function} */
no.en.core.url_encode.cljs$lang$applyTo = (function (seq21384){
var G__21385 = cljs.core.first.call(null,seq21384);
var seq21384__$1 = cljs.core.next.call(null,seq21384);
var self__4717__auto__ = this;
return self__4717__auto__.cljs$core$IFn$_invoke$arity$variadic(G__21385,seq21384__$1);
});
/**
* Returns `s` as an URL decoded string.
*/
no.en.core.url_decode = (function no$en$core$url_decode(var_args){
var args__4736__auto__ = [];
var len__4730__auto___21399 = arguments.length;
var i__4731__auto___21400 = (0);
while(true){
if((i__4731__auto___21400 < len__4730__auto___21399)){
args__4736__auto__.push((arguments[i__4731__auto___21400]));
var G__21401 = (i__4731__auto___21400 + (1));
i__4731__auto___21400 = G__21401;
continue;
} else {
}
break;
}
var argseq__4737__auto__ = ((((1) < args__4736__auto__.length))?(new cljs.core.IndexedSeq(args__4736__auto__.slice((1)),(0),null)):null);
return no.en.core.url_decode.cljs$core$IFn$_invoke$arity$variadic((arguments[(0)]),argseq__4737__auto__);
});
no.en.core.url_decode.cljs$core$IFn$_invoke$arity$variadic = (function (s,p__21395){
var vec__21396 = p__21395;
var encoding = cljs.core.nth.call(null,vec__21396,(0),null);
if(cljs.core.truth_(s)){
return decodeURIComponent(s);
} else {
return null;
}
});
no.en.core.url_decode.cljs$lang$maxFixedArity = (1);
/** @this {Function} */
no.en.core.url_decode.cljs$lang$applyTo = (function (seq21393){
var G__21394 = cljs.core.first.call(null,seq21393);
var seq21393__$1 = cljs.core.next.call(null,seq21393);
var self__4717__auto__ = this;
return self__4717__auto__.cljs$core$IFn$_invoke$arity$variadic(G__21394,seq21393__$1);
});
no.en.core.pow = (function no$en$core$pow(n,x){
return Math.pow(n,x);
});
no.en.core.byte_scale = cljs.core.PersistentHashMap.fromArrays(["T","K","G","M","Y","Z","E","B","P"],[no.en.core.pow.call(null,(1024),(4)),no.en.core.pow.call(null,(1024),(1)),no.en.core.pow.call(null,(1024),(3)),no.en.core.pow.call(null,(1024),(2)),no.en.core.pow.call(null,(1024),(8)),no.en.core.pow.call(null,(1024),(7)),no.en.core.pow.call(null,(1024),(6)),no.en.core.pow.call(null,(1024),(0)),no.en.core.pow.call(null,(1024),(5))]);
no.en.core.apply_unit = (function no$en$core$apply_unit(number,unit){
if(typeof unit === 'string'){
var G__21402 = clojure.string.upper_case.call(null,unit);
switch (G__21402) {
default:
var G__21403 = unit;
switch (G__21403) {
case "M":
return (number * (1000000));
break;
case "B":
return (number * (1000000000));
break;
default:
throw (new Error(["No matching clause: ",G__21403].join('')));
}
}
} else {
return number;
}
});
no.en.core.parse_number = (function no$en$core$parse_number(s,parse_fn){
var temp__5718__auto__ = cljs.core.re_matches.call(null,/\s*([-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?)(M|B)?.*/,cljs.core.str.cljs$core$IFn$_invoke$arity$1(s));
if(cljs.core.truth_(temp__5718__auto__)){
var matches = temp__5718__auto__;
var number = parse_fn.call(null,cljs.core.nth.call(null,matches,(1)));
var unit = cljs.core.nth.call(null,matches,(3));
if(cljs.core.not.call(null,isNaN(number))){
return no.en.core.apply_unit.call(null,number,unit);
} else {
return null;
}
} else {
return null;
}
});
no.en.core.parse_bytes = (function no$en$core$parse_bytes(s){
var temp__5718__auto__ = cljs.core.re_matches.call(null,/\s*([-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?)(B|K|M|G|T|P|E|Z|Y)?.*/,cljs.core.str.cljs$core$IFn$_invoke$arity$1(s));
if(cljs.core.truth_(temp__5718__auto__)){
var matches = temp__5718__auto__;
var number = cljs.reader.read_string.call(null,cljs.core.nth.call(null,matches,(1)));
var unit = cljs.core.nth.call(null,matches,(3));
return cljs.core.long$.call(null,(cljs.core.long$.call(null,cljs.reader.read_string.call(null,cljs.core.str.cljs$core$IFn$_invoke$arity$1(cljs.core.nth.call(null,matches,(1))))) * cljs.core.get.call(null,no.en.core.byte_scale,clojure.string.upper_case.call(null,(function (){var or__4131__auto__ = unit;
if(cljs.core.truth_(or__4131__auto__)){
return or__4131__auto__;
} else {
return "";
}
})()),(1))));
} else {
return null;
}
});
/**
* Parse `s` as a integer number.
*/
no.en.core.parse_integer = (function no$en$core$parse_integer(s){
return no.en.core.parse_number.call(null,s,(function (p1__21406_SHARP_){
return parseInt(p1__21406_SHARP_);
}));
});
/**
* Parse `s` as a long number.
*/
no.en.core.parse_long = (function no$en$core$parse_long(s){
return no.en.core.parse_number.call(null,s,(function (p1__21407_SHARP_){
return parseInt(p1__21407_SHARP_);
}));
});
/**
* Parse `s` as a double number.
*/
no.en.core.parse_double = (function no$en$core$parse_double(s){
return no.en.core.parse_number.call(null,s,(function (p1__21408_SHARP_){
return parseFloat(p1__21408_SHARP_);
}));
});
/**
* Parse `s` as a float number.
*/
no.en.core.parse_float = (function no$en$core$parse_float(s){
return no.en.core.parse_number.call(null,s,(function (p1__21409_SHARP_){
return parseFloat(p1__21409_SHARP_);
}));
});
/**
* Format the map `m` into a query parameter string.
*/
no.en.core.format_query_params = (function no$en$core$format_query_params(m){
var params = clojure.string.join.call(null,"&",cljs.core.map.call(null,(function (p1__21412_SHARP_){
return clojure.string.join.call(null,"=",p1__21412_SHARP_);
}),cljs.core.map.call(null,(function (p1__21411_SHARP_){
return (new cljs.core.PersistentVector(null,2,(5),cljs.core.PersistentVector.EMPTY_NODE,[no.en.core.url_encode.call(null,cljs.core.name.call(null,cljs.core.first.call(null,p1__21411_SHARP_))),no.en.core.url_encode.call(null,cljs.core.second.call(null,p1__21411_SHARP_))],null));
}),cljs.core.remove.call(null,(function (p1__21410_SHARP_){
return clojure.string.blank_QMARK_.call(null,cljs.core.str.cljs$core$IFn$_invoke$arity$1(cljs.core.second.call(null,p1__21410_SHARP_)));
}),cljs.core.sort_by.call(null,cljs.core.first,cljs.core.seq.call(null,m))))));
if((!(clojure.string.blank_QMARK_.call(null,params)))){
return params;
} else {
return null;
}
});
/**
* Format the Ring map as an url.
*/
no.en.core.format_url = (function no$en$core$format_url(m){
if((!(cljs.core.empty_QMARK_.call(null,m)))){
var query_params = new cljs.core.Keyword(null,"query-params","query-params",900640534).cljs$core$IFn$_invoke$arity$1(m);
return [(cljs.core.truth_(new cljs.core.Keyword(null,"scheme","scheme",90199613).cljs$core$IFn$_invoke$arity$1(m))?[cljs.core.name.call(null,new cljs.core.Keyword(null,"scheme","scheme",90199613).cljs$core$IFn$_invoke$arity$1(m)),"://"].join(''):null),(function (){var map__21415 = m;
var map__21415__$1 = (((((!((map__21415 == null))))?(((((map__21415.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__21415.cljs$core$ISeq$))))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__21415):map__21415);
var username = cljs.core.get.call(null,map__21415__$1,new cljs.core.Keyword(null,"username","username",1605666410));
var password = cljs.core.get.call(null,map__21415__$1,new cljs.core.Keyword(null,"password","password",417022471));
if(cljs.core.truth_(username)){
return [cljs.core.str.cljs$core$IFn$_invoke$arity$1(username),(cljs.core.truth_(password)?[":",cljs.core.str.cljs$core$IFn$_invoke$arity$1(password)].join(''):null),"@"].join('');
} else {
return null;
}
})(),cljs.core.str.cljs$core$IFn$_invoke$arity$1(new cljs.core.Keyword(null,"server-name","server-name",-1012104295).cljs$core$IFn$_invoke$arity$1(m)),(function (){var temp__5718__auto__ = new cljs.core.Keyword(null,"server-port","server-port",663745648).cljs$core$IFn$_invoke$arity$1(m);
if(cljs.core.truth_(temp__5718__auto__)){
var port = temp__5718__auto__;
if((!(cljs.core._EQ_.call(null,port,no.en.core.port_number.call(null,new cljs.core.Keyword(null,"scheme","scheme",90199613).cljs$core$IFn$_invoke$arity$1(m)))))){
return [":",cljs.core.str.cljs$core$IFn$_invoke$arity$1(port)].join('');
} else {
return null;
}
} else {
return null;
}
})(),cljs.core.str.cljs$core$IFn$_invoke$arity$1((((((new cljs.core.Keyword(null,"uri","uri",-774711847).cljs$core$IFn$_invoke$arity$1(m) == null)) && ((!(cljs.core.empty_QMARK_.call(null,query_params))))))?"/":new cljs.core.Keyword(null,"uri","uri",-774711847).cljs$core$IFn$_invoke$arity$1(m))),(((!(cljs.core.empty_QMARK_.call(null,query_params))))?["?",cljs.core.str.cljs$core$IFn$_invoke$arity$1(no.en.core.format_query_params.call(null,query_params))].join(''):null),(((!(clojure.string.blank_QMARK_.call(null,new cljs.core.Keyword(null,"fragment","fragment",826775688).cljs$core$IFn$_invoke$arity$1(m)))))?["#",cljs.core.str.cljs$core$IFn$_invoke$arity$1(new cljs.core.Keyword(null,"fragment","fragment",826775688).cljs$core$IFn$_invoke$arity$1(m))].join(''):null)].join('');
} else {
return null;
}
});
/**
* Return the formatted `url` without password as a string.
*/
no.en.core.public_url = (function no$en$core$public_url(url){
return no.en.core.format_url.call(null,cljs.core.dissoc.call(null,url,new cljs.core.Keyword(null,"password","password",417022471)));
});
/**
* Parse `s` as a percentage.
*/
no.en.core.parse_percent = (function no$en$core$parse_percent(s){
return no.en.core.parse_double.call(null,clojure.string.replace.call(null,s,"%",""));
});
/**
* Quote the special characters in `s` that are used in regular expressions.
*/
no.en.core.pattern_quote = (function no$en$core$pattern_quote(s){
return clojure.string.replace.call(null,cljs.core.name.call(null,s),/([\[\]\^\$\|\(\)\\\+\*\?\{\}\=\!.])/,"\\\\$1");
});
/**
* Returns the first string that separates the components in `s`.
*/
no.en.core.separator = (function no$en$core$separator(s){
var temp__5718__auto__ = cljs.core.re_matches.call(null,/([a-z0-9_-]+)([^a-z0-9_-]+).*/i,s);
if(cljs.core.truth_(temp__5718__auto__)){
var matches = temp__5718__auto__;
return cljs.core.nth.call(null,matches,(2));
} else {
return null;
}
});
/**
* Parse the query parameter string `s` and return a map.
*/
no.en.core.parse_query_params = (function no$en$core$parse_query_params(s){
if(cljs.core.truth_(s)){
return cljs.core.apply.call(null,cljs.core.hash_map,cljs.core.mapcat.call(null,(function (p1__21419_SHARP_){
return (new cljs.core.PersistentVector(null,2,(5),cljs.core.PersistentVector.EMPTY_NODE,[cljs.core.keyword.call(null,no.en.core.url_decode.call(null,cljs.core.first.call(null,p1__21419_SHARP_))),no.en.core.url_decode.call(null,cljs.core.second.call(null,p1__21419_SHARP_))],null));
}),cljs.core.filter.call(null,(function (p1__21418_SHARP_){
return cljs.core._EQ_.call(null,(2),cljs.core.count.call(null,p1__21418_SHARP_));
}),cljs.core.map.call(null,(function (p1__21417_SHARP_){
return clojure.string.split.call(null,p1__21417_SHARP_,/=/);
}),clojure.string.split.call(null,cljs.core.str.cljs$core$IFn$_invoke$arity$1(s),/&/)))));
} else {
return null;
}
});
/**
* Parse the url `s` and return a Ring compatible map.
*/
no.en.core.parse_url = (function no$en$core$parse_url(s){
var temp__5718__auto__ = cljs.core.re_matches.call(null,no.en.core.url_regex,cljs.core.str.cljs$core$IFn$_invoke$arity$1(s));
if(cljs.core.truth_(temp__5718__auto__)){
var matches = temp__5718__auto__;
var scheme = cljs.core.keyword.call(null,cljs.core.nth.call(null,matches,(1)));
return no.en.core.compact_map.call(null,cljs.core.PersistentHashMap.fromArrays([new cljs.core.Keyword(null,"password","password",417022471),new cljs.core.Keyword(null,"fragment","fragment",826775688),new cljs.core.Keyword(null,"username","username",1605666410),new cljs.core.Keyword(null,"server-port","server-port",663745648),new cljs.core.Keyword(null,"query-params","query-params",900640534),new cljs.core.Keyword(null,"uri","uri",-774711847),new cljs.core.Keyword(null,"server-name","server-name",-1012104295),new cljs.core.Keyword(null,"query-string","query-string",-1018845061),new cljs.core.Keyword(null,"scheme","scheme",90199613)],[cljs.core.nth.call(null,matches,(4)),cljs.core.nth.call(null,matches,(14)),cljs.core.nth.call(null,matches,(3)),(function (){var or__4131__auto__ = no.en.core.parse_integer.call(null,cljs.core.nth.call(null,matches,(8)));
if(cljs.core.truth_(or__4131__auto__)){
return or__4131__auto__;
} else {
return no.en.core.port_number.call(null,scheme);
}
})(),no.en.core.parse_query_params.call(null,cljs.core.nth.call(null,matches,(12))),cljs.core.nth.call(null,matches,(10)),cljs.core.nth.call(null,matches,(6)),cljs.core.nth.call(null,matches,(12)),scheme]));
} else {
return null;
}
});
var ret__4776__auto___21424 = (function (){
no.en.core.prog1 = (function no$en$core$prog1(var_args){
var args__4736__auto__ = [];
var len__4730__auto___21425 = arguments.length;
var i__4731__auto___21426 = (0);
while(true){
if((i__4731__auto___21426 < len__4730__auto___21425)){
args__4736__auto__.push((arguments[i__4731__auto___21426]));
var G__21427 = (i__4731__auto___21426 + (1));
i__4731__auto___21426 = G__21427;
continue;
} else {
}
break;
}
var argseq__4737__auto__ = ((((2) < args__4736__auto__.length))?(new cljs.core.IndexedSeq(args__4736__auto__.slice((2)),(0),null)):null);
return no.en.core.prog1.cljs$core$IFn$_invoke$arity$variadic((arguments[(0)]),(arguments[(1)]),argseq__4737__auto__);
});
no.en.core.prog1.cljs$core$IFn$_invoke$arity$variadic = (function (_AMPERSAND_form,_AMPERSAND_env,body){
return cljs.core.sequence.call(null,cljs.core.seq.call(null,cljs.core.concat.call(null,(new cljs.core.List(null,new cljs.core.Symbol("cljs.core","let","cljs.core/let",-308701135,null),null,(1),null)),(new cljs.core.List(null,cljs.core.vec.call(null,cljs.core.sequence.call(null,cljs.core.seq.call(null,cljs.core.concat.call(null,(new cljs.core.List(null,new cljs.core.Symbol(null,"result__21420__auto__","result__21420__auto__",591703516,null),null,(1),null)),(new cljs.core.List(null,cljs.core.first.call(null,body),null,(1),null)))))),null,(1),null)),cljs.core.rest.call(null,body),(new cljs.core.List(null,new cljs.core.Symbol(null,"result__21420__auto__","result__21420__auto__",591703516,null),null,(1),null)))));
});
no.en.core.prog1.cljs$lang$maxFixedArity = (2);
/** @this {Function} */
no.en.core.prog1.cljs$lang$applyTo = (function (seq21421){
var G__21422 = cljs.core.first.call(null,seq21421);
var seq21421__$1 = cljs.core.next.call(null,seq21421);
var G__21423 = cljs.core.first.call(null,seq21421__$1);
var seq21421__$2 = cljs.core.next.call(null,seq21421__$1);
var self__4717__auto__ = this;
return self__4717__auto__.cljs$core$IFn$_invoke$arity$variadic(G__21422,G__21423,seq21421__$2);
});
return null;
})()
;
no.en.core.prog1.cljs$lang$macro = true;
/**
* Executes thunk. If an exception is thrown, will retry. At most n retries
* are done. If still some exception is thrown it is bubbled upwards in
* the call chain.
*/
no.en.core.with_retries_STAR_ = (function no$en$core$with_retries_STAR_(n,thunk){
var n__$1 = n;
while(true){
var temp__5718__auto__ = (function (){try{return new cljs.core.PersistentVector(null, 1, 5, cljs.core.PersistentVector.EMPTY_NODE, [thunk.call(null)], null);
}catch (e21428){if((e21428 instanceof Error)){
var e = e21428;
if((n__$1 === (0))){
throw e;
} else {
return null;
}
} else {
throw e21428;
}
}})();
if(cljs.core.truth_(temp__5718__auto__)){
var result = temp__5718__auto__;
return result.call(null,(0));
} else {
var G__21429 = (n__$1 - (1));
n__$1 = G__21429;
continue;
}
break;
}
});
var ret__4776__auto___21434 = (function (){
/**
* Executes body. If an exception is thrown, will retry. At most n retries
* are done. If still some exception is thrown it is bubbled upwards in
* the call chain.
*/
no.en.core.with_retries = (function no$en$core$with_retries(var_args){
var args__4736__auto__ = [];
var len__4730__auto___21435 = arguments.length;
var i__4731__auto___21436 = (0);
while(true){
if((i__4731__auto___21436 < len__4730__auto___21435)){
args__4736__auto__.push((arguments[i__4731__auto___21436]));
var G__21437 = (i__4731__auto___21436 + (1));
i__4731__auto___21436 = G__21437;
continue;
} else {
}
break;
}
var argseq__4737__auto__ = ((((3) < args__4736__auto__.length))?(new cljs.core.IndexedSeq(args__4736__auto__.slice((3)),(0),null)):null);
return no.en.core.with_retries.cljs$core$IFn$_invoke$arity$variadic((arguments[(0)]),(arguments[(1)]),(arguments[(2)]),argseq__4737__auto__);
});
no.en.core.with_retries.cljs$core$IFn$_invoke$arity$variadic = (function (_AMPERSAND_form,_AMPERSAND_env,n,body){
return cljs.core.sequence.call(null,cljs.core.seq.call(null,cljs.core.concat.call(null,(new cljs.core.List(null,new cljs.core.Symbol("no.en.core","with-retries*","no.en.core/with-retries*",172357687,null),null,(1),null)),(new cljs.core.List(null,n,null,(1),null)),(new cljs.core.List(null,cljs.core.sequence.call(null,cljs.core.seq.call(null,cljs.core.concat.call(null,(new cljs.core.List(null,new cljs.core.Symbol("cljs.core","fn","cljs.core/fn",-1065745098,null),null,(1),null)),(new cljs.core.List(null,cljs.core.vec.call(null,cljs.core.sequence.call(null,cljs.core.seq.call(null,cljs.core.concat.call(null)))),null,(1),null)),body))),null,(1),null)))));
});
no.en.core.with_retries.cljs$lang$maxFixedArity = (3);
/** @this {Function} */
no.en.core.with_retries.cljs$lang$applyTo = (function (seq21430){
var G__21431 = cljs.core.first.call(null,seq21430);
var seq21430__$1 = cljs.core.next.call(null,seq21430);
var G__21432 = cljs.core.first.call(null,seq21430__$1);
var seq21430__$2 = cljs.core.next.call(null,seq21430__$1);
var G__21433 = cljs.core.first.call(null,seq21430__$2);
var seq21430__$3 = cljs.core.next.call(null,seq21430__$2);
var self__4717__auto__ = this;
return self__4717__auto__.cljs$core$IFn$_invoke$arity$variadic(G__21431,G__21432,G__21433,seq21430__$3);
});
return null;
})()
;
no.en.core.with_retries.cljs$lang$macro = true;
no.en.core.editable_QMARK_ = (function no$en$core$editable_QMARK_(coll){
if((!((coll == null)))){
if(((false) || ((cljs.core.PROTOCOL_SENTINEL === coll.cljs$core$IEditableCollection$)))){
return true;
} else {
if((!coll.cljs$lang$protocol_mask$partition$)){
return cljs.core.native_satisfies_QMARK_.call(null,cljs.core.IEditableCollection,coll);
} else {
return false;
}
}
} else {
return cljs.core.native_satisfies_QMARK_.call(null,cljs.core.IEditableCollection,coll);
}
});
no.en.core.reduce_map = (function no$en$core$reduce_map(f,coll){
if(no.en.core.editable_QMARK_.call(null,coll)){
return cljs.core.persistent_BANG_.call(null,cljs.core.reduce_kv.call(null,f.call(null,cljs.core.assoc_BANG_),cljs.core.transient$.call(null,cljs.core.empty.call(null,coll)),coll));
} else {
return cljs.core.reduce_kv.call(null,f.call(null,cljs.core.assoc),cljs.core.empty.call(null,coll),coll);
}
});
/**
* Maps a function over the keys of an associative collection.
*/
no.en.core.map_keys = (function no$en$core$map_keys(f,coll){
return no.en.core.reduce_map.call(null,(function (xf){
return (function (m,k,v){
return xf.call(null,m,f.call(null,k),v);
});
}),coll);
});
/**
* Maps a function over the values of an associative collection.
*/
no.en.core.map_vals = (function no$en$core$map_vals(f,coll){
return no.en.core.reduce_map.call(null,(function (xf){
return (function (m,k,v){
return xf.call(null,m,k,f.call(null,v));
});
}),coll);
});
/**
* Like merge, but merges maps recursively.
*/
no.en.core.deep_merge = (function no$en$core$deep_merge(var_args){
var args__4736__auto__ = [];
var len__4730__auto___21440 = arguments.length;
var i__4731__auto___21441 = (0);
while(true){
if((i__4731__auto___21441 < len__4730__auto___21440)){
args__4736__auto__.push((arguments[i__4731__auto___21441]));
var G__21442 = (i__4731__auto___21441 + (1));
i__4731__auto___21441 = G__21442;
continue;
} else {
}
break;
}
var argseq__4737__auto__ = ((((0) < args__4736__auto__.length))?(new cljs.core.IndexedSeq(args__4736__auto__.slice((0)),(0),null)):null);
return no.en.core.deep_merge.cljs$core$IFn$_invoke$arity$variadic(argseq__4737__auto__);
});
no.en.core.deep_merge.cljs$core$IFn$_invoke$arity$variadic = (function (maps){
if(cljs.core.every_QMARK_.call(null,cljs.core.map_QMARK_,maps)){
return cljs.core.apply.call(null,cljs.core.merge_with,no.en.core.deep_merge,maps);
} else {
return cljs.core.last.call(null,maps);
}
});
no.en.core.deep_merge.cljs$lang$maxFixedArity = (0);
/** @this {Function} */
no.en.core.deep_merge.cljs$lang$applyTo = (function (seq21439){
var self__4718__auto__ = this;
return self__4718__auto__.cljs$core$IFn$_invoke$arity$variadic(cljs.core.seq.call(null,seq21439));
});
/**
* Like merge-with, but merges maps recursively, applying the given fn
* only when there's a non-map at a particular level.
*/
no.en.core.deep_merge_with = (function no$en$core$deep_merge_with(var_args){
var args__4736__auto__ = [];
var len__4730__auto___21445 = arguments.length;
var i__4731__auto___21446 = (0);
while(true){
if((i__4731__auto___21446 < len__4730__auto___21445)){
args__4736__auto__.push((arguments[i__4731__auto___21446]));
var G__21447 = (i__4731__auto___21446 + (1));
i__4731__auto___21446 = G__21447;
continue;
} else {
}
break;
}
var argseq__4737__auto__ = ((((1) < args__4736__auto__.length))?(new cljs.core.IndexedSeq(args__4736__auto__.slice((1)),(0),null)):null);
return no.en.core.deep_merge_with.cljs$core$IFn$_invoke$arity$variadic((arguments[(0)]),argseq__4737__auto__);
});
no.en.core.deep_merge_with.cljs$core$IFn$_invoke$arity$variadic = (function (f,maps){
return cljs.core.apply.call(null,(function() {
var no$en$core$m__delegate = function (maps__$1){
if(cljs.core.every_QMARK_.call(null,cljs.core.map_QMARK_,maps__$1)){
return cljs.core.apply.call(null,cljs.core.merge_with,no$en$core$m,maps__$1);
} else {
return cljs.core.apply.call(null,f,maps__$1);
}
};
var no$en$core$m = function (var_args){
var maps__$1 = null;
if (arguments.length > 0) {
var G__21448__i = 0, G__21448__a = new Array(arguments.length - 0);
while (G__21448__i < G__21448__a.length) {G__21448__a[G__21448__i] = arguments[G__21448__i + 0]; ++G__21448__i;}
maps__$1 = new cljs.core.IndexedSeq(G__21448__a,0,null);
}
return no$en$core$m__delegate.call(this,maps__$1);};
no$en$core$m.cljs$lang$maxFixedArity = 0;
no$en$core$m.cljs$lang$applyTo = (function (arglist__21449){
var maps__$1 = cljs.core.seq(arglist__21449);
return no$en$core$m__delegate(maps__$1);
});
no$en$core$m.cljs$core$IFn$_invoke$arity$variadic = no$en$core$m__delegate;
return no$en$core$m;
})()
,maps);
});
no.en.core.deep_merge_with.cljs$lang$maxFixedArity = (1);
/** @this {Function} */
no.en.core.deep_merge_with.cljs$lang$applyTo = (function (seq21443){
var G__21444 = cljs.core.first.call(null,seq21443);
var seq21443__$1 = cljs.core.next.call(null,seq21443);
var self__4717__auto__ = this;
return self__4717__auto__.cljs$core$IFn$_invoke$arity$variadic(G__21444,seq21443__$1);
});
//# sourceMappingURL=core.js.map?rel=1582812677679

File diff suppressed because one or more lines are too long