Moved web root into root of project; this makes deployment easier.
Also deleted 'docs', which is now redundant.
This commit is contained in:
parent
a5204c66b9
commit
743d8a1740
1592 changed files with 53626 additions and 139250 deletions
152
js/compiled/out/clojure/browser/dom.cljs
Normal file
152
js/compiled/out/clojure/browser/dom.cljs
Normal file
|
|
@ -0,0 +1,152 @@
|
|||
;; Copyright (c) Rich Hickey. All rights reserved.
|
||||
;; The use and distribution terms for this software are covered by the
|
||||
;; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)
|
||||
;; which can be found in the file epl-v10.html at the root of this distribution.
|
||||
;; By using this software in any fashion, you are agreeing to be bound by
|
||||
;; the terms of this license.
|
||||
;; You must not remove this notice, or any other, from this software.
|
||||
|
||||
(ns clojure.browser.dom
|
||||
(:require [goog.dom :as gdom]
|
||||
[goog.object :as gobject]))
|
||||
|
||||
(defn append [parent & children]
|
||||
(apply gdom/append parent children)
|
||||
parent)
|
||||
|
||||
(defprotocol DOMBuilder
|
||||
(-element [this] [this attrs-or-children] [this attrs children]))
|
||||
|
||||
(defn log [& args]
|
||||
(.log js/console (apply pr-str args)))
|
||||
|
||||
(defn log-obj [obj]
|
||||
(.log js/console obj))
|
||||
|
||||
(extend-protocol DOMBuilder
|
||||
|
||||
string
|
||||
(-element
|
||||
([this]
|
||||
(log "string (-element " this ")")
|
||||
(cond (keyword? this) (gdom/createElement (name this))
|
||||
:else (gdom/createTextNode (name this))))
|
||||
|
||||
([this attrs-or-children]
|
||||
(log "string (-element " this " " attrs-or-children ")")
|
||||
(let [attrs (first attrs-or-children)]
|
||||
(if (map? attrs)
|
||||
(-element this attrs (rest attrs-or-children))
|
||||
(-element this nil attrs-or-children))))
|
||||
|
||||
([this attrs children]
|
||||
(log "string (-element " this " " attrs " " children ")")
|
||||
(let [str-attrs (if (and (map? attrs) (seq attrs))
|
||||
(reduce (fn [o [k v]]
|
||||
(let [o (if (nil? o) (js-obj) o)]
|
||||
(log "o = " o)
|
||||
(log "k = " k)
|
||||
(log "v = " v)
|
||||
(when (or (keyword? k)
|
||||
(string? k))
|
||||
(doto o (gobject/set (name k) v)))))
|
||||
(js-obj)
|
||||
attrs)
|
||||
nil)]
|
||||
(log-obj str-attrs)
|
||||
(if (seq children)
|
||||
(apply gdom/createDom
|
||||
(name this)
|
||||
str-attrs
|
||||
(map -element children))
|
||||
(gdom/createDom (name this)
|
||||
str-attrs)))))
|
||||
|
||||
PersistentVector
|
||||
(-element
|
||||
[this]
|
||||
(log "PersistentVector (-element " this ")")
|
||||
(let [tag (first this)
|
||||
attrs (second this)
|
||||
children (drop 2 this)]
|
||||
(if (map? attrs)
|
||||
(-element tag attrs children)
|
||||
(-element tag nil (rest this)))))
|
||||
|
||||
js/Element
|
||||
(-element [this]
|
||||
(log "js/Element (-element " this ")")
|
||||
this))
|
||||
|
||||
(defn element
|
||||
([tag-or-text]
|
||||
(log "(element " tag-or-text ")")
|
||||
(-element tag-or-text))
|
||||
([tag & children]
|
||||
(log "(element " tag " " children ")")
|
||||
(let [attrs (first children)]
|
||||
(if (map? attrs)
|
||||
(-element tag attrs (rest children))
|
||||
(-element tag nil children)))))
|
||||
|
||||
(defn remove-children
|
||||
"Remove all children from the element with the passed id."
|
||||
[id]
|
||||
(let [parent (gdom/getElement (name id))]
|
||||
(do (gdom/removeChildren parent))))
|
||||
|
||||
(defn get-element [id]
|
||||
(gdom/getElement (name id)))
|
||||
|
||||
(defn html->dom [s]
|
||||
(gdom/htmlToDocumentFragment s))
|
||||
|
||||
(defn insert-at [parent child index]
|
||||
(gdom/insertChildAt parent child index))
|
||||
|
||||
(defn ensure-element
|
||||
"Coerce the argument to a dom element if possible."
|
||||
[e]
|
||||
(cond (keyword? e) (get-element e)
|
||||
(string? e) (html->dom e)
|
||||
:else e))
|
||||
|
||||
(defn replace-node
|
||||
"Replace old-node with new-node. old-node can be an element or a
|
||||
keyword which is the id of the node to replace. new-node can be an
|
||||
element or an html string."
|
||||
[old-node new-node]
|
||||
(let [old-node (ensure-element old-node)
|
||||
new-node (ensure-element new-node)]
|
||||
(gdom/replaceNode new-node old-node)
|
||||
new-node))
|
||||
|
||||
(defn set-text
|
||||
"Set the text content for the passed element returning the
|
||||
element. If a keyword is passed in the place of e, the element with
|
||||
that id will be used and returned."
|
||||
[e s]
|
||||
(gdom/setTextContent (ensure-element e) s))
|
||||
|
||||
(defn get-value
|
||||
"Get the value of an element."
|
||||
[e]
|
||||
(.-value (ensure-element e)))
|
||||
|
||||
(defn set-properties
|
||||
"Set properties on an element"
|
||||
[e m]
|
||||
(gdom/setProperties (ensure-element e)
|
||||
(apply gobject/create (interleave (keys m) (vals m)))))
|
||||
|
||||
(defn set-value
|
||||
"Set the value property for an element."
|
||||
[e v]
|
||||
(set-properties e {"value" v}))
|
||||
|
||||
(defn click-element
|
||||
[e]
|
||||
(.click (ensure-element e) ()))
|
||||
|
||||
;; TODO CSS class manipulation
|
||||
;; TODO Query syntax
|
||||
1
js/compiled/out/clojure/browser/dom.cljs.cache.json
Normal file
1
js/compiled/out/clojure/browser/dom.cljs.cache.json
Normal file
File diff suppressed because one or more lines are too long
390
js/compiled/out/clojure/browser/dom.js
Normal file
390
js/compiled/out/clojure/browser/dom.js
Normal file
|
|
@ -0,0 +1,390 @@
|
|||
// Compiled by ClojureScript 1.10.520 {}
|
||||
goog.provide('clojure.browser.dom');
|
||||
goog.require('cljs.core');
|
||||
goog.require('goog.dom');
|
||||
goog.require('goog.object');
|
||||
clojure.browser.dom.append = (function clojure$browser$dom$append(var_args){
|
||||
var args__4736__auto__ = [];
|
||||
var len__4730__auto___24960 = arguments.length;
|
||||
var i__4731__auto___24961 = (0);
|
||||
while(true){
|
||||
if((i__4731__auto___24961 < len__4730__auto___24960)){
|
||||
args__4736__auto__.push((arguments[i__4731__auto___24961]));
|
||||
|
||||
var G__24962 = (i__4731__auto___24961 + (1));
|
||||
i__4731__auto___24961 = G__24962;
|
||||
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 clojure.browser.dom.append.cljs$core$IFn$_invoke$arity$variadic((arguments[(0)]),argseq__4737__auto__);
|
||||
});
|
||||
|
||||
clojure.browser.dom.append.cljs$core$IFn$_invoke$arity$variadic = (function (parent,children){
|
||||
cljs.core.apply.call(null,goog.dom.append,parent,children);
|
||||
|
||||
return parent;
|
||||
});
|
||||
|
||||
clojure.browser.dom.append.cljs$lang$maxFixedArity = (1);
|
||||
|
||||
/** @this {Function} */
|
||||
clojure.browser.dom.append.cljs$lang$applyTo = (function (seq24958){
|
||||
var G__24959 = cljs.core.first.call(null,seq24958);
|
||||
var seq24958__$1 = cljs.core.next.call(null,seq24958);
|
||||
var self__4717__auto__ = this;
|
||||
return self__4717__auto__.cljs$core$IFn$_invoke$arity$variadic(G__24959,seq24958__$1);
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* @interface
|
||||
*/
|
||||
clojure.browser.dom.DOMBuilder = function(){};
|
||||
|
||||
clojure.browser.dom._element = (function clojure$browser$dom$_element(var_args){
|
||||
var G__24964 = arguments.length;
|
||||
switch (G__24964) {
|
||||
case 1:
|
||||
return clojure.browser.dom._element.cljs$core$IFn$_invoke$arity$1((arguments[(0)]));
|
||||
|
||||
break;
|
||||
case 2:
|
||||
return clojure.browser.dom._element.cljs$core$IFn$_invoke$arity$2((arguments[(0)]),(arguments[(1)]));
|
||||
|
||||
break;
|
||||
case 3:
|
||||
return clojure.browser.dom._element.cljs$core$IFn$_invoke$arity$3((arguments[(0)]),(arguments[(1)]),(arguments[(2)]));
|
||||
|
||||
break;
|
||||
default:
|
||||
throw (new Error(["Invalid arity: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(arguments.length)].join('')));
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
clojure.browser.dom._element.cljs$core$IFn$_invoke$arity$1 = (function (this$){
|
||||
if((((!((this$ == null)))) && ((!((this$.clojure$browser$dom$DOMBuilder$_element$arity$1 == null)))))){
|
||||
return this$.clojure$browser$dom$DOMBuilder$_element$arity$1(this$);
|
||||
} else {
|
||||
var x__4433__auto__ = (((this$ == null))?null:this$);
|
||||
var m__4434__auto__ = (clojure.browser.dom._element[goog.typeOf(x__4433__auto__)]);
|
||||
if((!((m__4434__auto__ == null)))){
|
||||
return m__4434__auto__.call(null,this$);
|
||||
} else {
|
||||
var m__4431__auto__ = (clojure.browser.dom._element["_"]);
|
||||
if((!((m__4431__auto__ == null)))){
|
||||
return m__4431__auto__.call(null,this$);
|
||||
} else {
|
||||
throw cljs.core.missing_protocol.call(null,"DOMBuilder.-element",this$);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
clojure.browser.dom._element.cljs$core$IFn$_invoke$arity$2 = (function (this$,attrs_or_children){
|
||||
if((((!((this$ == null)))) && ((!((this$.clojure$browser$dom$DOMBuilder$_element$arity$2 == null)))))){
|
||||
return this$.clojure$browser$dom$DOMBuilder$_element$arity$2(this$,attrs_or_children);
|
||||
} else {
|
||||
var x__4433__auto__ = (((this$ == null))?null:this$);
|
||||
var m__4434__auto__ = (clojure.browser.dom._element[goog.typeOf(x__4433__auto__)]);
|
||||
if((!((m__4434__auto__ == null)))){
|
||||
return m__4434__auto__.call(null,this$,attrs_or_children);
|
||||
} else {
|
||||
var m__4431__auto__ = (clojure.browser.dom._element["_"]);
|
||||
if((!((m__4431__auto__ == null)))){
|
||||
return m__4431__auto__.call(null,this$,attrs_or_children);
|
||||
} else {
|
||||
throw cljs.core.missing_protocol.call(null,"DOMBuilder.-element",this$);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
clojure.browser.dom._element.cljs$core$IFn$_invoke$arity$3 = (function (this$,attrs,children){
|
||||
if((((!((this$ == null)))) && ((!((this$.clojure$browser$dom$DOMBuilder$_element$arity$3 == null)))))){
|
||||
return this$.clojure$browser$dom$DOMBuilder$_element$arity$3(this$,attrs,children);
|
||||
} else {
|
||||
var x__4433__auto__ = (((this$ == null))?null:this$);
|
||||
var m__4434__auto__ = (clojure.browser.dom._element[goog.typeOf(x__4433__auto__)]);
|
||||
if((!((m__4434__auto__ == null)))){
|
||||
return m__4434__auto__.call(null,this$,attrs,children);
|
||||
} else {
|
||||
var m__4431__auto__ = (clojure.browser.dom._element["_"]);
|
||||
if((!((m__4431__auto__ == null)))){
|
||||
return m__4431__auto__.call(null,this$,attrs,children);
|
||||
} else {
|
||||
throw cljs.core.missing_protocol.call(null,"DOMBuilder.-element",this$);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
clojure.browser.dom._element.cljs$lang$maxFixedArity = 3;
|
||||
|
||||
|
||||
clojure.browser.dom.log = (function clojure$browser$dom$log(var_args){
|
||||
var args__4736__auto__ = [];
|
||||
var len__4730__auto___24967 = arguments.length;
|
||||
var i__4731__auto___24968 = (0);
|
||||
while(true){
|
||||
if((i__4731__auto___24968 < len__4730__auto___24967)){
|
||||
args__4736__auto__.push((arguments[i__4731__auto___24968]));
|
||||
|
||||
var G__24969 = (i__4731__auto___24968 + (1));
|
||||
i__4731__auto___24968 = G__24969;
|
||||
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 clojure.browser.dom.log.cljs$core$IFn$_invoke$arity$variadic(argseq__4737__auto__);
|
||||
});
|
||||
|
||||
clojure.browser.dom.log.cljs$core$IFn$_invoke$arity$variadic = (function (args){
|
||||
return console.log(cljs.core.apply.call(null,cljs.core.pr_str,args));
|
||||
});
|
||||
|
||||
clojure.browser.dom.log.cljs$lang$maxFixedArity = (0);
|
||||
|
||||
/** @this {Function} */
|
||||
clojure.browser.dom.log.cljs$lang$applyTo = (function (seq24966){
|
||||
var self__4718__auto__ = this;
|
||||
return self__4718__auto__.cljs$core$IFn$_invoke$arity$variadic(cljs.core.seq.call(null,seq24966));
|
||||
});
|
||||
|
||||
clojure.browser.dom.log_obj = (function clojure$browser$dom$log_obj(obj){
|
||||
return console.log(obj);
|
||||
});
|
||||
goog.object.set(clojure.browser.dom.DOMBuilder,"string",true);
|
||||
|
||||
goog.object.set(clojure.browser.dom._element,"string",(function() {
|
||||
var G__24979 = null;
|
||||
var G__24979__1 = (function (this$){
|
||||
clojure.browser.dom.log.call(null,"string (-element ",this$,")");
|
||||
|
||||
if((this$ instanceof cljs.core.Keyword)){
|
||||
return goog.dom.createElement(cljs.core.name.call(null,this$));
|
||||
} else {
|
||||
return goog.dom.createTextNode(cljs.core.name.call(null,this$));
|
||||
|
||||
}
|
||||
});
|
||||
var G__24979__2 = (function (this$,attrs_or_children){
|
||||
clojure.browser.dom.log.call(null,"string (-element ",this$," ",attrs_or_children,")");
|
||||
|
||||
var attrs = cljs.core.first.call(null,attrs_or_children);
|
||||
if(cljs.core.map_QMARK_.call(null,attrs)){
|
||||
return clojure.browser.dom._element.call(null,this$,attrs,cljs.core.rest.call(null,attrs_or_children));
|
||||
} else {
|
||||
return clojure.browser.dom._element.call(null,this$,null,attrs_or_children);
|
||||
}
|
||||
});
|
||||
var G__24979__3 = (function (this$,attrs,children){
|
||||
clojure.browser.dom.log.call(null,"string (-element ",this$," ",attrs," ",children,")");
|
||||
|
||||
var str_attrs = ((((cljs.core.map_QMARK_.call(null,attrs)) && (cljs.core.seq.call(null,attrs))))?cljs.core.reduce.call(null,(function (o,p__24970){
|
||||
var vec__24971 = p__24970;
|
||||
var k = cljs.core.nth.call(null,vec__24971,(0),null);
|
||||
var v = cljs.core.nth.call(null,vec__24971,(1),null);
|
||||
var o__$1 = (((o == null))?({}):o);
|
||||
clojure.browser.dom.log.call(null,"o = ",o__$1);
|
||||
|
||||
clojure.browser.dom.log.call(null,"k = ",k);
|
||||
|
||||
clojure.browser.dom.log.call(null,"v = ",v);
|
||||
|
||||
if((((k instanceof cljs.core.Keyword)) || (typeof k === 'string'))){
|
||||
var G__24976 = o__$1;
|
||||
goog.object.set(G__24976,cljs.core.name.call(null,k),v);
|
||||
|
||||
return G__24976;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}),({}),attrs):null);
|
||||
clojure.browser.dom.log_obj.call(null,str_attrs);
|
||||
|
||||
if(cljs.core.seq.call(null,children)){
|
||||
return cljs.core.apply.call(null,goog.dom.createDom,cljs.core.name.call(null,this$),str_attrs,cljs.core.map.call(null,clojure.browser.dom._element,children));
|
||||
} else {
|
||||
return goog.dom.createDom(cljs.core.name.call(null,this$),str_attrs);
|
||||
}
|
||||
});
|
||||
G__24979 = function(this$,attrs,children){
|
||||
switch(arguments.length){
|
||||
case 1:
|
||||
return G__24979__1.call(this,this$);
|
||||
case 2:
|
||||
return G__24979__2.call(this,this$,attrs);
|
||||
case 3:
|
||||
return G__24979__3.call(this,this$,attrs,children);
|
||||
}
|
||||
throw(new Error('Invalid arity: ' + arguments.length));
|
||||
};
|
||||
G__24979.cljs$core$IFn$_invoke$arity$1 = G__24979__1;
|
||||
G__24979.cljs$core$IFn$_invoke$arity$2 = G__24979__2;
|
||||
G__24979.cljs$core$IFn$_invoke$arity$3 = G__24979__3;
|
||||
return G__24979;
|
||||
})()
|
||||
);
|
||||
|
||||
cljs.core.PersistentVector.prototype.clojure$browser$dom$DOMBuilder$ = cljs.core.PROTOCOL_SENTINEL;
|
||||
|
||||
cljs.core.PersistentVector.prototype.clojure$browser$dom$DOMBuilder$_element$arity$1 = (function (this$){
|
||||
var this$__$1 = this;
|
||||
clojure.browser.dom.log.call(null,"PersistentVector (-element ",this$__$1,")");
|
||||
|
||||
var tag = cljs.core.first.call(null,this$__$1);
|
||||
var attrs = cljs.core.second.call(null,this$__$1);
|
||||
var children = cljs.core.drop.call(null,(2),this$__$1);
|
||||
if(cljs.core.map_QMARK_.call(null,attrs)){
|
||||
return clojure.browser.dom._element.call(null,tag,attrs,children);
|
||||
} else {
|
||||
return clojure.browser.dom._element.call(null,tag,null,cljs.core.rest.call(null,this$__$1));
|
||||
}
|
||||
});
|
||||
|
||||
Element.prototype.clojure$browser$dom$DOMBuilder$ = cljs.core.PROTOCOL_SENTINEL;
|
||||
|
||||
Element.prototype.clojure$browser$dom$DOMBuilder$_element$arity$1 = (function (this$){
|
||||
var this$__$1 = this;
|
||||
clojure.browser.dom.log.call(null,"js/Element (-element ",this$__$1,")");
|
||||
|
||||
return this$__$1;
|
||||
});
|
||||
clojure.browser.dom.element = (function clojure$browser$dom$element(var_args){
|
||||
var G__24983 = arguments.length;
|
||||
switch (G__24983) {
|
||||
case 1:
|
||||
return clojure.browser.dom.element.cljs$core$IFn$_invoke$arity$1((arguments[(0)]));
|
||||
|
||||
break;
|
||||
default:
|
||||
var args_arr__4751__auto__ = [];
|
||||
var len__4730__auto___24985 = arguments.length;
|
||||
var i__4731__auto___24986 = (0);
|
||||
while(true){
|
||||
if((i__4731__auto___24986 < len__4730__auto___24985)){
|
||||
args_arr__4751__auto__.push((arguments[i__4731__auto___24986]));
|
||||
|
||||
var G__24987 = (i__4731__auto___24986 + (1));
|
||||
i__4731__auto___24986 = G__24987;
|
||||
continue;
|
||||
} else {
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
var argseq__4752__auto__ = (new cljs.core.IndexedSeq(args_arr__4751__auto__.slice((1)),(0),null));
|
||||
return clojure.browser.dom.element.cljs$core$IFn$_invoke$arity$variadic((arguments[(0)]),argseq__4752__auto__);
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
clojure.browser.dom.element.cljs$core$IFn$_invoke$arity$1 = (function (tag_or_text){
|
||||
clojure.browser.dom.log.call(null,"(element ",tag_or_text,")");
|
||||
|
||||
return clojure.browser.dom._element.call(null,tag_or_text);
|
||||
});
|
||||
|
||||
clojure.browser.dom.element.cljs$core$IFn$_invoke$arity$variadic = (function (tag,children){
|
||||
clojure.browser.dom.log.call(null,"(element ",tag," ",children,")");
|
||||
|
||||
var attrs = cljs.core.first.call(null,children);
|
||||
if(cljs.core.map_QMARK_.call(null,attrs)){
|
||||
return clojure.browser.dom._element.call(null,tag,attrs,cljs.core.rest.call(null,children));
|
||||
} else {
|
||||
return clojure.browser.dom._element.call(null,tag,null,children);
|
||||
}
|
||||
});
|
||||
|
||||
/** @this {Function} */
|
||||
clojure.browser.dom.element.cljs$lang$applyTo = (function (seq24981){
|
||||
var G__24982 = cljs.core.first.call(null,seq24981);
|
||||
var seq24981__$1 = cljs.core.next.call(null,seq24981);
|
||||
var self__4717__auto__ = this;
|
||||
return self__4717__auto__.cljs$core$IFn$_invoke$arity$variadic(G__24982,seq24981__$1);
|
||||
});
|
||||
|
||||
clojure.browser.dom.element.cljs$lang$maxFixedArity = (1);
|
||||
|
||||
/**
|
||||
* Remove all children from the element with the passed id.
|
||||
*/
|
||||
clojure.browser.dom.remove_children = (function clojure$browser$dom$remove_children(id){
|
||||
var parent = goog.dom.getElement(cljs.core.name.call(null,id));
|
||||
return goog.dom.removeChildren(parent);
|
||||
});
|
||||
clojure.browser.dom.get_element = (function clojure$browser$dom$get_element(id){
|
||||
return goog.dom.getElement(cljs.core.name.call(null,id));
|
||||
});
|
||||
clojure.browser.dom.html__GT_dom = (function clojure$browser$dom$html__GT_dom(s){
|
||||
return goog.dom.htmlToDocumentFragment(s);
|
||||
});
|
||||
clojure.browser.dom.insert_at = (function clojure$browser$dom$insert_at(parent,child,index){
|
||||
return goog.dom.insertChildAt(parent,child,index);
|
||||
});
|
||||
/**
|
||||
* Coerce the argument to a dom element if possible.
|
||||
*/
|
||||
clojure.browser.dom.ensure_element = (function clojure$browser$dom$ensure_element(e){
|
||||
if((e instanceof cljs.core.Keyword)){
|
||||
return clojure.browser.dom.get_element.call(null,e);
|
||||
} else {
|
||||
if(typeof e === 'string'){
|
||||
return clojure.browser.dom.html__GT_dom.call(null,e);
|
||||
} else {
|
||||
return e;
|
||||
|
||||
}
|
||||
}
|
||||
});
|
||||
/**
|
||||
* Replace old-node with new-node. old-node can be an element or a
|
||||
* keyword which is the id of the node to replace. new-node can be an
|
||||
* element or an html string.
|
||||
*/
|
||||
clojure.browser.dom.replace_node = (function clojure$browser$dom$replace_node(old_node,new_node){
|
||||
var old_node__$1 = clojure.browser.dom.ensure_element.call(null,old_node);
|
||||
var new_node__$1 = clojure.browser.dom.ensure_element.call(null,new_node);
|
||||
goog.dom.replaceNode(new_node__$1,old_node__$1);
|
||||
|
||||
return new_node__$1;
|
||||
});
|
||||
/**
|
||||
* Set the text content for the passed element returning the
|
||||
* element. If a keyword is passed in the place of e, the element with
|
||||
* that id will be used and returned.
|
||||
*/
|
||||
clojure.browser.dom.set_text = (function clojure$browser$dom$set_text(e,s){
|
||||
return goog.dom.setTextContent(clojure.browser.dom.ensure_element.call(null,e),s);
|
||||
});
|
||||
/**
|
||||
* Get the value of an element.
|
||||
*/
|
||||
clojure.browser.dom.get_value = (function clojure$browser$dom$get_value(e){
|
||||
return clojure.browser.dom.ensure_element.call(null,e).value;
|
||||
});
|
||||
/**
|
||||
* Set properties on an element
|
||||
*/
|
||||
clojure.browser.dom.set_properties = (function clojure$browser$dom$set_properties(e,m){
|
||||
return goog.dom.setProperties(clojure.browser.dom.ensure_element.call(null,e),cljs.core.apply.call(null,goog.object.create,cljs.core.interleave.call(null,cljs.core.keys.call(null,m),cljs.core.vals.call(null,m))));
|
||||
});
|
||||
/**
|
||||
* Set the value property for an element.
|
||||
*/
|
||||
clojure.browser.dom.set_value = (function clojure$browser$dom$set_value(e,v){
|
||||
return clojure.browser.dom.set_properties.call(null,e,new cljs.core.PersistentArrayMap(null, 1, ["value",v], null));
|
||||
});
|
||||
clojure.browser.dom.click_element = (function clojure$browser$dom$click_element(e){
|
||||
return clojure.browser.dom.ensure_element.call(null,e).click(cljs.core.List.EMPTY);
|
||||
});
|
||||
|
||||
//# sourceMappingURL=dom.js.map?rel=1582812678762
|
||||
1
js/compiled/out/clojure/browser/dom.js.map
Normal file
1
js/compiled/out/clojure/browser/dom.js.map
Normal file
File diff suppressed because one or more lines are too long
162
js/compiled/out/clojure/data.cljs
Normal file
162
js/compiled/out/clojure/data.cljs
Normal file
|
|
@ -0,0 +1,162 @@
|
|||
; Copyright (c) Rich Hickey. All rights reserved.
|
||||
; The use and distribution terms for this software are covered by the
|
||||
; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)
|
||||
; which can be found in the file epl-v10.html at the root of this distribution.
|
||||
; By using this software in any fashion, you are agreeing to be bound by
|
||||
; the terms of this license.
|
||||
; You must not remove this notice, or any other, from this software.
|
||||
|
||||
(ns
|
||||
^{:author "Stuart Halloway",
|
||||
:doc "Non-core data functions."}
|
||||
clojure.data
|
||||
(:require [clojure.set :as set]))
|
||||
|
||||
(declare ^{:arglists '([a b])} diff)
|
||||
|
||||
(defn- atom-diff
|
||||
"Internal helper for diff."
|
||||
[a b]
|
||||
(if (= a b) [nil nil a] [a b nil]))
|
||||
|
||||
;; for big things a sparse vector class would be better
|
||||
(defn- vectorize
|
||||
"Convert an associative-by-numeric-index collection into
|
||||
an equivalent vector, with nil for any missing keys"
|
||||
[m]
|
||||
(when (seq m)
|
||||
(reduce
|
||||
(fn [result [k v]] (assoc result k v))
|
||||
(vec (repeat (apply max (keys m)) nil))
|
||||
m)))
|
||||
|
||||
(defn- diff-associative-key
|
||||
"Diff associative things a and b, comparing only the key k."
|
||||
[a b k]
|
||||
(let [va (get a k)
|
||||
vb (get b k)
|
||||
[a* b* ab] (diff va vb)
|
||||
in-a (contains? a k)
|
||||
in-b (contains? b k)
|
||||
same (and in-a in-b
|
||||
(or (not (nil? ab))
|
||||
(and (nil? va) (nil? vb))))]
|
||||
[(when (and in-a (or (not (nil? a*)) (not same))) {k a*})
|
||||
(when (and in-b (or (not (nil? b*)) (not same))) {k b*})
|
||||
(when same {k ab})
|
||||
]))
|
||||
|
||||
(defn- diff-associative
|
||||
"Diff associative things a and b, comparing only keys in ks (if supplied)."
|
||||
([a b]
|
||||
(diff-associative a b (set/union (keys a) (keys b))))
|
||||
([a b ks]
|
||||
(reduce
|
||||
(fn [diff1 diff2]
|
||||
(doall (map merge diff1 diff2)))
|
||||
[nil nil nil]
|
||||
(map
|
||||
(partial diff-associative-key a b)
|
||||
ks))))
|
||||
|
||||
(defn- diff-sequential
|
||||
[a b]
|
||||
(vec (map vectorize (diff-associative
|
||||
(if (vector? a) a (vec a))
|
||||
(if (vector? b) b (vec b))
|
||||
(range (max (count a) (count b)))))))
|
||||
|
||||
(defn- diff-set
|
||||
[a b]
|
||||
[(not-empty (set/difference a b))
|
||||
(not-empty (set/difference b a))
|
||||
(not-empty (set/intersection a b))])
|
||||
|
||||
(defprotocol EqualityPartition
|
||||
"Implementation detail. Subject to change."
|
||||
(equality-partition [x] "Implementation detail. Subject to change."))
|
||||
|
||||
(defprotocol Diff
|
||||
"Implementation detail. Subject to change."
|
||||
(diff-similar [a b] "Implementation detail. Subject to change."))
|
||||
|
||||
(extend-protocol EqualityPartition
|
||||
nil
|
||||
(equality-partition [x] :atom)
|
||||
|
||||
string
|
||||
(equality-partition [x] :atom)
|
||||
|
||||
number
|
||||
(equality-partition [x] :atom)
|
||||
|
||||
array
|
||||
(equality-partition [x] :sequential)
|
||||
|
||||
function
|
||||
(equality-partition [x] :atom)
|
||||
|
||||
boolean
|
||||
(equality-partition [x] :atom)
|
||||
|
||||
default
|
||||
(equality-partition [x]
|
||||
(cond
|
||||
(satisfies? IMap x) :map
|
||||
(satisfies? ISet x) :set
|
||||
(satisfies? ISequential x) :sequential
|
||||
:default :atom)))
|
||||
|
||||
(extend-protocol Diff
|
||||
nil
|
||||
(diff-similar [a b]
|
||||
(atom-diff a b))
|
||||
|
||||
string
|
||||
(diff-similar [a b]
|
||||
(atom-diff a b))
|
||||
|
||||
number
|
||||
(diff-similar [a b]
|
||||
(atom-diff a b))
|
||||
|
||||
array
|
||||
(diff-similar [a b]
|
||||
(diff-sequential a b))
|
||||
|
||||
function
|
||||
(diff-similar [a b]
|
||||
(atom-diff a b))
|
||||
|
||||
boolean
|
||||
(diff-similar [a b]
|
||||
(atom-diff a b))
|
||||
|
||||
default
|
||||
(diff-similar [a b]
|
||||
((case (equality-partition a)
|
||||
:atom atom-diff
|
||||
:set diff-set
|
||||
:sequential diff-sequential
|
||||
:map diff-associative)
|
||||
a b)))
|
||||
|
||||
(defn diff
|
||||
"Recursively compares a and b, returning a tuple of
|
||||
[things-only-in-a things-only-in-b things-in-both].
|
||||
Comparison rules:
|
||||
|
||||
* For equal a and b, return [nil nil a].
|
||||
* Maps are subdiffed where keys match and values differ.
|
||||
* Sets are never subdiffed.
|
||||
* All sequential things are treated as associative collections
|
||||
by their indexes, with results returned as vectors.
|
||||
* Everything else (including strings!) is treated as
|
||||
an atom and compared for equality."
|
||||
[a b]
|
||||
(if (= a b)
|
||||
[nil nil a]
|
||||
(if (= (equality-partition a) (equality-partition b))
|
||||
(diff-similar a b)
|
||||
(atom-diff a b))))
|
||||
|
||||
1
js/compiled/out/clojure/data.cljs.cache.json
Normal file
1
js/compiled/out/clojure/data.cljs.cache.json
Normal file
File diff suppressed because one or more lines are too long
288
js/compiled/out/clojure/data.js
Normal file
288
js/compiled/out/clojure/data.js
Normal file
|
|
@ -0,0 +1,288 @@
|
|||
// Compiled by ClojureScript 1.10.520 {}
|
||||
goog.provide('clojure.data');
|
||||
goog.require('cljs.core');
|
||||
goog.require('clojure.set');
|
||||
/**
|
||||
* Internal helper for diff.
|
||||
*/
|
||||
clojure.data.atom_diff = (function clojure$data$atom_diff(a,b){
|
||||
if(cljs.core._EQ_.call(null,a,b)){
|
||||
return new cljs.core.PersistentVector(null, 3, 5, cljs.core.PersistentVector.EMPTY_NODE, [null,null,a], null);
|
||||
} else {
|
||||
return new cljs.core.PersistentVector(null, 3, 5, cljs.core.PersistentVector.EMPTY_NODE, [a,b,null], null);
|
||||
}
|
||||
});
|
||||
/**
|
||||
* Convert an associative-by-numeric-index collection into
|
||||
* an equivalent vector, with nil for any missing keys
|
||||
*/
|
||||
clojure.data.vectorize = (function clojure$data$vectorize(m){
|
||||
if(cljs.core.seq.call(null,m)){
|
||||
return cljs.core.reduce.call(null,(function (result,p__27656){
|
||||
var vec__27657 = p__27656;
|
||||
var k = cljs.core.nth.call(null,vec__27657,(0),null);
|
||||
var v = cljs.core.nth.call(null,vec__27657,(1),null);
|
||||
return cljs.core.assoc.call(null,result,k,v);
|
||||
}),cljs.core.vec.call(null,cljs.core.repeat.call(null,cljs.core.apply.call(null,cljs.core.max,cljs.core.keys.call(null,m)),null)),m);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
});
|
||||
/**
|
||||
* Diff associative things a and b, comparing only the key k.
|
||||
*/
|
||||
clojure.data.diff_associative_key = (function clojure$data$diff_associative_key(a,b,k){
|
||||
var va = cljs.core.get.call(null,a,k);
|
||||
var vb = cljs.core.get.call(null,b,k);
|
||||
var vec__27660 = clojure.data.diff.call(null,va,vb);
|
||||
var a_STAR_ = cljs.core.nth.call(null,vec__27660,(0),null);
|
||||
var b_STAR_ = cljs.core.nth.call(null,vec__27660,(1),null);
|
||||
var ab = cljs.core.nth.call(null,vec__27660,(2),null);
|
||||
var in_a = cljs.core.contains_QMARK_.call(null,a,k);
|
||||
var in_b = cljs.core.contains_QMARK_.call(null,b,k);
|
||||
var same = ((in_a) && (in_b) && ((((!((ab == null)))) || ((((va == null)) && ((vb == null)))))));
|
||||
return new cljs.core.PersistentVector(null, 3, 5, cljs.core.PersistentVector.EMPTY_NODE, [((((in_a) && ((((!((a_STAR_ == null)))) || ((!(same)))))))?cljs.core.PersistentArrayMap.createAsIfByAssoc([k,a_STAR_]):null),((((in_b) && ((((!((b_STAR_ == null)))) || ((!(same)))))))?cljs.core.PersistentArrayMap.createAsIfByAssoc([k,b_STAR_]):null),((same)?cljs.core.PersistentArrayMap.createAsIfByAssoc([k,ab]):null)], null);
|
||||
});
|
||||
/**
|
||||
* Diff associative things a and b, comparing only keys in ks (if supplied).
|
||||
*/
|
||||
clojure.data.diff_associative = (function clojure$data$diff_associative(var_args){
|
||||
var G__27664 = arguments.length;
|
||||
switch (G__27664) {
|
||||
case 2:
|
||||
return clojure.data.diff_associative.cljs$core$IFn$_invoke$arity$2((arguments[(0)]),(arguments[(1)]));
|
||||
|
||||
break;
|
||||
case 3:
|
||||
return clojure.data.diff_associative.cljs$core$IFn$_invoke$arity$3((arguments[(0)]),(arguments[(1)]),(arguments[(2)]));
|
||||
|
||||
break;
|
||||
default:
|
||||
throw (new Error(["Invalid arity: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(arguments.length)].join('')));
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
clojure.data.diff_associative.cljs$core$IFn$_invoke$arity$2 = (function (a,b){
|
||||
return clojure.data.diff_associative.call(null,a,b,clojure.set.union.call(null,cljs.core.keys.call(null,a),cljs.core.keys.call(null,b)));
|
||||
});
|
||||
|
||||
clojure.data.diff_associative.cljs$core$IFn$_invoke$arity$3 = (function (a,b,ks){
|
||||
return cljs.core.reduce.call(null,(function (diff1,diff2){
|
||||
return cljs.core.doall.call(null,cljs.core.map.call(null,cljs.core.merge,diff1,diff2));
|
||||
}),new cljs.core.PersistentVector(null, 3, 5, cljs.core.PersistentVector.EMPTY_NODE, [null,null,null], null),cljs.core.map.call(null,cljs.core.partial.call(null,clojure.data.diff_associative_key,a,b),ks));
|
||||
});
|
||||
|
||||
clojure.data.diff_associative.cljs$lang$maxFixedArity = 3;
|
||||
|
||||
clojure.data.diff_sequential = (function clojure$data$diff_sequential(a,b){
|
||||
return cljs.core.vec.call(null,cljs.core.map.call(null,clojure.data.vectorize,clojure.data.diff_associative.call(null,((cljs.core.vector_QMARK_.call(null,a))?a:cljs.core.vec.call(null,a)),((cljs.core.vector_QMARK_.call(null,b))?b:cljs.core.vec.call(null,b)),cljs.core.range.call(null,(function (){var x__4219__auto__ = cljs.core.count.call(null,a);
|
||||
var y__4220__auto__ = cljs.core.count.call(null,b);
|
||||
return ((x__4219__auto__ > y__4220__auto__) ? x__4219__auto__ : y__4220__auto__);
|
||||
})()))));
|
||||
});
|
||||
clojure.data.diff_set = (function clojure$data$diff_set(a,b){
|
||||
return new cljs.core.PersistentVector(null, 3, 5, cljs.core.PersistentVector.EMPTY_NODE, [cljs.core.not_empty.call(null,clojure.set.difference.call(null,a,b)),cljs.core.not_empty.call(null,clojure.set.difference.call(null,b,a)),cljs.core.not_empty.call(null,clojure.set.intersection.call(null,a,b))], null);
|
||||
});
|
||||
|
||||
/**
|
||||
* Implementation detail. Subject to change.
|
||||
* @interface
|
||||
*/
|
||||
clojure.data.EqualityPartition = function(){};
|
||||
|
||||
/**
|
||||
* Implementation detail. Subject to change.
|
||||
*/
|
||||
clojure.data.equality_partition = (function clojure$data$equality_partition(x){
|
||||
if((((!((x == null)))) && ((!((x.clojure$data$EqualityPartition$equality_partition$arity$1 == null)))))){
|
||||
return x.clojure$data$EqualityPartition$equality_partition$arity$1(x);
|
||||
} else {
|
||||
var x__4433__auto__ = (((x == null))?null:x);
|
||||
var m__4434__auto__ = (clojure.data.equality_partition[goog.typeOf(x__4433__auto__)]);
|
||||
if((!((m__4434__auto__ == null)))){
|
||||
return m__4434__auto__.call(null,x);
|
||||
} else {
|
||||
var m__4431__auto__ = (clojure.data.equality_partition["_"]);
|
||||
if((!((m__4431__auto__ == null)))){
|
||||
return m__4431__auto__.call(null,x);
|
||||
} else {
|
||||
throw cljs.core.missing_protocol.call(null,"EqualityPartition.equality-partition",x);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* Implementation detail. Subject to change.
|
||||
* @interface
|
||||
*/
|
||||
clojure.data.Diff = function(){};
|
||||
|
||||
/**
|
||||
* Implementation detail. Subject to change.
|
||||
*/
|
||||
clojure.data.diff_similar = (function clojure$data$diff_similar(a,b){
|
||||
if((((!((a == null)))) && ((!((a.clojure$data$Diff$diff_similar$arity$2 == null)))))){
|
||||
return a.clojure$data$Diff$diff_similar$arity$2(a,b);
|
||||
} else {
|
||||
var x__4433__auto__ = (((a == null))?null:a);
|
||||
var m__4434__auto__ = (clojure.data.diff_similar[goog.typeOf(x__4433__auto__)]);
|
||||
if((!((m__4434__auto__ == null)))){
|
||||
return m__4434__auto__.call(null,a,b);
|
||||
} else {
|
||||
var m__4431__auto__ = (clojure.data.diff_similar["_"]);
|
||||
if((!((m__4431__auto__ == null)))){
|
||||
return m__4431__auto__.call(null,a,b);
|
||||
} else {
|
||||
throw cljs.core.missing_protocol.call(null,"Diff.diff-similar",a);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
goog.object.set(clojure.data.EqualityPartition,"null",true);
|
||||
|
||||
goog.object.set(clojure.data.equality_partition,"null",(function (x){
|
||||
return new cljs.core.Keyword(null,"atom","atom",-397043653);
|
||||
}));
|
||||
|
||||
goog.object.set(clojure.data.EqualityPartition,"string",true);
|
||||
|
||||
goog.object.set(clojure.data.equality_partition,"string",(function (x){
|
||||
return new cljs.core.Keyword(null,"atom","atom",-397043653);
|
||||
}));
|
||||
|
||||
goog.object.set(clojure.data.EqualityPartition,"number",true);
|
||||
|
||||
goog.object.set(clojure.data.equality_partition,"number",(function (x){
|
||||
return new cljs.core.Keyword(null,"atom","atom",-397043653);
|
||||
}));
|
||||
|
||||
goog.object.set(clojure.data.EqualityPartition,"array",true);
|
||||
|
||||
goog.object.set(clojure.data.equality_partition,"array",(function (x){
|
||||
return new cljs.core.Keyword(null,"sequential","sequential",-1082983960);
|
||||
}));
|
||||
|
||||
goog.object.set(clojure.data.EqualityPartition,"function",true);
|
||||
|
||||
goog.object.set(clojure.data.equality_partition,"function",(function (x){
|
||||
return new cljs.core.Keyword(null,"atom","atom",-397043653);
|
||||
}));
|
||||
|
||||
goog.object.set(clojure.data.EqualityPartition,"boolean",true);
|
||||
|
||||
goog.object.set(clojure.data.equality_partition,"boolean",(function (x){
|
||||
return new cljs.core.Keyword(null,"atom","atom",-397043653);
|
||||
}));
|
||||
|
||||
goog.object.set(clojure.data.EqualityPartition,"_",true);
|
||||
|
||||
goog.object.set(clojure.data.equality_partition,"_",(function (x){
|
||||
if((((!((x == null))))?(((((x.cljs$lang$protocol_mask$partition0$ & (1024))) || ((cljs.core.PROTOCOL_SENTINEL === x.cljs$core$IMap$))))?true:(((!x.cljs$lang$protocol_mask$partition0$))?cljs.core.native_satisfies_QMARK_.call(null,cljs.core.IMap,x):false)):cljs.core.native_satisfies_QMARK_.call(null,cljs.core.IMap,x))){
|
||||
return new cljs.core.Keyword(null,"map","map",1371690461);
|
||||
} else {
|
||||
if((((!((x == null))))?(((((x.cljs$lang$protocol_mask$partition0$ & (4096))) || ((cljs.core.PROTOCOL_SENTINEL === x.cljs$core$ISet$))))?true:(((!x.cljs$lang$protocol_mask$partition0$))?cljs.core.native_satisfies_QMARK_.call(null,cljs.core.ISet,x):false)):cljs.core.native_satisfies_QMARK_.call(null,cljs.core.ISet,x))){
|
||||
return new cljs.core.Keyword(null,"set","set",304602554);
|
||||
} else {
|
||||
if((((!((x == null))))?(((((x.cljs$lang$protocol_mask$partition0$ & (16777216))) || ((cljs.core.PROTOCOL_SENTINEL === x.cljs$core$ISequential$))))?true:(((!x.cljs$lang$protocol_mask$partition0$))?cljs.core.native_satisfies_QMARK_.call(null,cljs.core.ISequential,x):false)):cljs.core.native_satisfies_QMARK_.call(null,cljs.core.ISequential,x))){
|
||||
return new cljs.core.Keyword(null,"sequential","sequential",-1082983960);
|
||||
} else {
|
||||
return new cljs.core.Keyword(null,"atom","atom",-397043653);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}));
|
||||
goog.object.set(clojure.data.Diff,"null",true);
|
||||
|
||||
goog.object.set(clojure.data.diff_similar,"null",(function (a,b){
|
||||
return clojure.data.atom_diff.call(null,a,b);
|
||||
}));
|
||||
|
||||
goog.object.set(clojure.data.Diff,"string",true);
|
||||
|
||||
goog.object.set(clojure.data.diff_similar,"string",(function (a,b){
|
||||
return clojure.data.atom_diff.call(null,a,b);
|
||||
}));
|
||||
|
||||
goog.object.set(clojure.data.Diff,"number",true);
|
||||
|
||||
goog.object.set(clojure.data.diff_similar,"number",(function (a,b){
|
||||
return clojure.data.atom_diff.call(null,a,b);
|
||||
}));
|
||||
|
||||
goog.object.set(clojure.data.Diff,"array",true);
|
||||
|
||||
goog.object.set(clojure.data.diff_similar,"array",(function (a,b){
|
||||
return clojure.data.diff_sequential.call(null,a,b);
|
||||
}));
|
||||
|
||||
goog.object.set(clojure.data.Diff,"function",true);
|
||||
|
||||
goog.object.set(clojure.data.diff_similar,"function",(function (a,b){
|
||||
return clojure.data.atom_diff.call(null,a,b);
|
||||
}));
|
||||
|
||||
goog.object.set(clojure.data.Diff,"boolean",true);
|
||||
|
||||
goog.object.set(clojure.data.diff_similar,"boolean",(function (a,b){
|
||||
return clojure.data.atom_diff.call(null,a,b);
|
||||
}));
|
||||
|
||||
goog.object.set(clojure.data.Diff,"_",true);
|
||||
|
||||
goog.object.set(clojure.data.diff_similar,"_",(function (a,b){
|
||||
return (function (){var G__27669 = clojure.data.equality_partition.call(null,a);
|
||||
var G__27669__$1 = (((G__27669 instanceof cljs.core.Keyword))?G__27669.fqn:null);
|
||||
switch (G__27669__$1) {
|
||||
case "atom":
|
||||
return clojure.data.atom_diff;
|
||||
|
||||
break;
|
||||
case "set":
|
||||
return clojure.data.diff_set;
|
||||
|
||||
break;
|
||||
case "sequential":
|
||||
return clojure.data.diff_sequential;
|
||||
|
||||
break;
|
||||
case "map":
|
||||
return clojure.data.diff_associative;
|
||||
|
||||
break;
|
||||
default:
|
||||
throw (new Error(["No matching clause: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(G__27669__$1)].join('')));
|
||||
|
||||
}
|
||||
})().call(null,a,b);
|
||||
}));
|
||||
/**
|
||||
* Recursively compares a and b, returning a tuple of
|
||||
* [things-only-in-a things-only-in-b things-in-both].
|
||||
* Comparison rules:
|
||||
*
|
||||
* * For equal a and b, return [nil nil a].
|
||||
* * Maps are subdiffed where keys match and values differ.
|
||||
* * Sets are never subdiffed.
|
||||
* * All sequential things are treated as associative collections
|
||||
* by their indexes, with results returned as vectors.
|
||||
* * Everything else (including strings!) is treated as
|
||||
* an atom and compared for equality.
|
||||
*/
|
||||
clojure.data.diff = (function clojure$data$diff(a,b){
|
||||
if(cljs.core._EQ_.call(null,a,b)){
|
||||
return new cljs.core.PersistentVector(null, 3, 5, cljs.core.PersistentVector.EMPTY_NODE, [null,null,a], null);
|
||||
} else {
|
||||
if(cljs.core._EQ_.call(null,clojure.data.equality_partition.call(null,a),clojure.data.equality_partition.call(null,b))){
|
||||
return clojure.data.diff_similar.call(null,a,b);
|
||||
} else {
|
||||
return clojure.data.atom_diff.call(null,a,b);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
//# sourceMappingURL=data.js.map?rel=1582812680420
|
||||
1
js/compiled/out/clojure/data.js.map
Normal file
1
js/compiled/out/clojure/data.js.map
Normal file
File diff suppressed because one or more lines are too long
161
js/compiled/out/clojure/set.cljs
Normal file
161
js/compiled/out/clojure/set.cljs
Normal file
|
|
@ -0,0 +1,161 @@
|
|||
; Copyright (c) Rich Hickey. All rights reserved.
|
||||
; The use and distribution terms for this software are covered by the
|
||||
; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)
|
||||
; which can be found in the file epl-v10.html at the root of this distribution.
|
||||
; By using this software in any fashion, you are agreeing to be bound by
|
||||
; the terms of this license.
|
||||
; You must not remove this notice, or any other, from this software.
|
||||
|
||||
(ns ^{:doc "Set operations such as union/intersection."
|
||||
:author "Rich Hickey"}
|
||||
clojure.set)
|
||||
|
||||
(defn- bubble-max-key [k coll]
|
||||
"Move a maximal element of coll according to fn k (which returns a number)
|
||||
to the front of coll."
|
||||
(let [max (apply max-key k coll)]
|
||||
(cons max (remove #(identical? max %) coll))))
|
||||
|
||||
(defn union
|
||||
"Return a set that is the union of the input sets"
|
||||
([] #{})
|
||||
([s1] s1)
|
||||
([s1 s2]
|
||||
(if (< (count s1) (count s2))
|
||||
(reduce conj s2 s1)
|
||||
(reduce conj s1 s2)))
|
||||
([s1 s2 & sets]
|
||||
(let [bubbled-sets (bubble-max-key count (conj sets s2 s1))]
|
||||
(reduce into (first bubbled-sets) (rest bubbled-sets)))))
|
||||
|
||||
(defn intersection
|
||||
"Return a set that is the intersection of the input sets"
|
||||
([s1] s1)
|
||||
([s1 s2]
|
||||
(if (< (count s2) (count s1))
|
||||
(recur s2 s1)
|
||||
(reduce (fn [result item]
|
||||
(if (contains? s2 item)
|
||||
result
|
||||
(disj result item)))
|
||||
s1 s1)))
|
||||
([s1 s2 & sets]
|
||||
(let [bubbled-sets (bubble-max-key #(- (count %)) (conj sets s2 s1))]
|
||||
(reduce intersection (first bubbled-sets) (rest bubbled-sets)))))
|
||||
|
||||
(defn difference
|
||||
"Return a set that is the first set without elements of the remaining sets"
|
||||
([s1] s1)
|
||||
([s1 s2]
|
||||
(if (< (count s1) (count s2))
|
||||
(reduce (fn [result item]
|
||||
(if (contains? s2 item)
|
||||
(disj result item)
|
||||
result))
|
||||
s1 s1)
|
||||
(reduce disj s1 s2)))
|
||||
([s1 s2 & sets]
|
||||
(reduce difference s1 (conj sets s2))))
|
||||
|
||||
|
||||
(defn select
|
||||
"Returns a set of the elements for which pred is true"
|
||||
[pred xset]
|
||||
(reduce (fn [s k] (if (pred k) s (disj s k)))
|
||||
xset xset))
|
||||
|
||||
(defn project
|
||||
"Returns a rel of the elements of xrel with only the keys in ks"
|
||||
[xrel ks]
|
||||
(set (map #(select-keys % ks) xrel)))
|
||||
|
||||
(defn rename-keys
|
||||
"Returns the map with the keys in kmap renamed to the vals in kmap"
|
||||
[map kmap]
|
||||
(reduce
|
||||
(fn [m [old new]]
|
||||
(if (contains? map old)
|
||||
(assoc m new (get map old))
|
||||
m))
|
||||
(apply dissoc map (keys kmap)) kmap))
|
||||
|
||||
(defn rename
|
||||
"Returns a rel of the maps in xrel with the keys in kmap renamed to the vals in kmap"
|
||||
[xrel kmap]
|
||||
(set (map #(rename-keys % kmap) xrel)))
|
||||
|
||||
(defn index
|
||||
"Returns a map of the distinct values of ks in the xrel mapped to a
|
||||
set of the maps in xrel with the corresponding values of ks."
|
||||
[xrel ks]
|
||||
(reduce
|
||||
(fn [m x]
|
||||
(let [ik (select-keys x ks)]
|
||||
(assoc m ik (conj (get m ik #{}) x))))
|
||||
{} xrel))
|
||||
|
||||
(defn map-invert
|
||||
"Returns the map with the vals mapped to the keys."
|
||||
[m] (reduce (fn [m [k v]] (assoc m v k)) {} m))
|
||||
|
||||
(defn join
|
||||
"When passed 2 rels, returns the rel corresponding to the natural
|
||||
join. When passed an additional keymap, joins on the corresponding
|
||||
keys."
|
||||
([xrel yrel] ;natural join
|
||||
(if (and (seq xrel) (seq yrel))
|
||||
(let [ks (intersection (set (keys (first xrel))) (set (keys (first yrel))))
|
||||
[r s] (if (<= (count xrel) (count yrel))
|
||||
[xrel yrel]
|
||||
[yrel xrel])
|
||||
idx (index r ks)]
|
||||
(reduce (fn [ret x]
|
||||
(let [found (idx (select-keys x ks))]
|
||||
(if found
|
||||
(reduce #(conj %1 (merge %2 x)) ret found)
|
||||
ret)))
|
||||
#{} s))
|
||||
#{}))
|
||||
([xrel yrel km] ;arbitrary key mapping
|
||||
(let [[r s k] (if (<= (count xrel) (count yrel))
|
||||
[xrel yrel (map-invert km)]
|
||||
[yrel xrel km])
|
||||
idx (index r (vals k))]
|
||||
(reduce (fn [ret x]
|
||||
(let [found (idx (rename-keys (select-keys x (keys k)) k))]
|
||||
(if found
|
||||
(reduce #(conj %1 (merge %2 x)) ret found)
|
||||
ret)))
|
||||
#{} s))))
|
||||
|
||||
(defn subset?
|
||||
"Is set1 a subset of set2?"
|
||||
[set1 set2]
|
||||
(and (<= (count set1) (count set2))
|
||||
(every? #(contains? set2 %) set1)))
|
||||
|
||||
(defn superset?
|
||||
"Is set1 a superset of set2?"
|
||||
[set1 set2]
|
||||
(and (>= (count set1) (count set2))
|
||||
(every? #(contains? set1 %) set2)))
|
||||
|
||||
(comment
|
||||
(refer 'set)
|
||||
(def xs #{{:a 11 :b 1 :c 1 :d 4}
|
||||
{:a 2 :b 12 :c 2 :d 6}
|
||||
{:a 3 :b 3 :c 3 :d 8 :f 42}})
|
||||
|
||||
(def ys #{{:a 11 :b 11 :c 11 :e 5}
|
||||
{:a 12 :b 11 :c 12 :e 3}
|
||||
{:a 3 :b 3 :c 3 :e 7 }})
|
||||
|
||||
(join xs ys)
|
||||
(join xs (rename ys {:b :yb :c :yc}) {:a :a})
|
||||
|
||||
(union #{:a :b :c} #{:c :d :e })
|
||||
(difference #{:a :b :c} #{:c :d :e})
|
||||
(intersection #{:a :b :c} #{:c :d :e})
|
||||
|
||||
(index ys [:b]))
|
||||
|
||||
1
js/compiled/out/clojure/set.cljs.cache.json
Normal file
1
js/compiled/out/clojure/set.cljs.cache.json
Normal file
File diff suppressed because one or more lines are too long
391
js/compiled/out/clojure/set.js
Normal file
391
js/compiled/out/clojure/set.js
Normal file
|
|
@ -0,0 +1,391 @@
|
|||
// Compiled by ClojureScript 1.10.520 {}
|
||||
goog.provide('clojure.set');
|
||||
goog.require('cljs.core');
|
||||
clojure.set.bubble_max_key = (function clojure$set$bubble_max_key(k,coll){
|
||||
|
||||
var max = cljs.core.apply.call(null,cljs.core.max_key,k,coll);
|
||||
return cljs.core.cons.call(null,max,cljs.core.remove.call(null,((function (max){
|
||||
return (function (p1__27598_SHARP_){
|
||||
return (max === p1__27598_SHARP_);
|
||||
});})(max))
|
||||
,coll));
|
||||
});
|
||||
/**
|
||||
* Return a set that is the union of the input sets
|
||||
*/
|
||||
clojure.set.union = (function clojure$set$union(var_args){
|
||||
var G__27603 = arguments.length;
|
||||
switch (G__27603) {
|
||||
case 0:
|
||||
return clojure.set.union.cljs$core$IFn$_invoke$arity$0();
|
||||
|
||||
break;
|
||||
case 1:
|
||||
return clojure.set.union.cljs$core$IFn$_invoke$arity$1((arguments[(0)]));
|
||||
|
||||
break;
|
||||
case 2:
|
||||
return clojure.set.union.cljs$core$IFn$_invoke$arity$2((arguments[(0)]),(arguments[(1)]));
|
||||
|
||||
break;
|
||||
default:
|
||||
var args_arr__4751__auto__ = [];
|
||||
var len__4730__auto___27605 = arguments.length;
|
||||
var i__4731__auto___27606 = (0);
|
||||
while(true){
|
||||
if((i__4731__auto___27606 < len__4730__auto___27605)){
|
||||
args_arr__4751__auto__.push((arguments[i__4731__auto___27606]));
|
||||
|
||||
var G__27607 = (i__4731__auto___27606 + (1));
|
||||
i__4731__auto___27606 = G__27607;
|
||||
continue;
|
||||
} else {
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
var argseq__4752__auto__ = (new cljs.core.IndexedSeq(args_arr__4751__auto__.slice((2)),(0),null));
|
||||
return clojure.set.union.cljs$core$IFn$_invoke$arity$variadic((arguments[(0)]),(arguments[(1)]),argseq__4752__auto__);
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
clojure.set.union.cljs$core$IFn$_invoke$arity$0 = (function (){
|
||||
return cljs.core.PersistentHashSet.EMPTY;
|
||||
});
|
||||
|
||||
clojure.set.union.cljs$core$IFn$_invoke$arity$1 = (function (s1){
|
||||
return s1;
|
||||
});
|
||||
|
||||
clojure.set.union.cljs$core$IFn$_invoke$arity$2 = (function (s1,s2){
|
||||
if((cljs.core.count.call(null,s1) < cljs.core.count.call(null,s2))){
|
||||
return cljs.core.reduce.call(null,cljs.core.conj,s2,s1);
|
||||
} else {
|
||||
return cljs.core.reduce.call(null,cljs.core.conj,s1,s2);
|
||||
}
|
||||
});
|
||||
|
||||
clojure.set.union.cljs$core$IFn$_invoke$arity$variadic = (function (s1,s2,sets){
|
||||
var bubbled_sets = clojure.set.bubble_max_key.call(null,cljs.core.count,cljs.core.conj.call(null,sets,s2,s1));
|
||||
return cljs.core.reduce.call(null,cljs.core.into,cljs.core.first.call(null,bubbled_sets),cljs.core.rest.call(null,bubbled_sets));
|
||||
});
|
||||
|
||||
/** @this {Function} */
|
||||
clojure.set.union.cljs$lang$applyTo = (function (seq27600){
|
||||
var G__27601 = cljs.core.first.call(null,seq27600);
|
||||
var seq27600__$1 = cljs.core.next.call(null,seq27600);
|
||||
var G__27602 = cljs.core.first.call(null,seq27600__$1);
|
||||
var seq27600__$2 = cljs.core.next.call(null,seq27600__$1);
|
||||
var self__4717__auto__ = this;
|
||||
return self__4717__auto__.cljs$core$IFn$_invoke$arity$variadic(G__27601,G__27602,seq27600__$2);
|
||||
});
|
||||
|
||||
clojure.set.union.cljs$lang$maxFixedArity = (2);
|
||||
|
||||
/**
|
||||
* Return a set that is the intersection of the input sets
|
||||
*/
|
||||
clojure.set.intersection = (function clojure$set$intersection(var_args){
|
||||
var G__27613 = arguments.length;
|
||||
switch (G__27613) {
|
||||
case 1:
|
||||
return clojure.set.intersection.cljs$core$IFn$_invoke$arity$1((arguments[(0)]));
|
||||
|
||||
break;
|
||||
case 2:
|
||||
return clojure.set.intersection.cljs$core$IFn$_invoke$arity$2((arguments[(0)]),(arguments[(1)]));
|
||||
|
||||
break;
|
||||
default:
|
||||
var args_arr__4751__auto__ = [];
|
||||
var len__4730__auto___27615 = arguments.length;
|
||||
var i__4731__auto___27616 = (0);
|
||||
while(true){
|
||||
if((i__4731__auto___27616 < len__4730__auto___27615)){
|
||||
args_arr__4751__auto__.push((arguments[i__4731__auto___27616]));
|
||||
|
||||
var G__27617 = (i__4731__auto___27616 + (1));
|
||||
i__4731__auto___27616 = G__27617;
|
||||
continue;
|
||||
} else {
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
var argseq__4752__auto__ = (new cljs.core.IndexedSeq(args_arr__4751__auto__.slice((2)),(0),null));
|
||||
return clojure.set.intersection.cljs$core$IFn$_invoke$arity$variadic((arguments[(0)]),(arguments[(1)]),argseq__4752__auto__);
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
clojure.set.intersection.cljs$core$IFn$_invoke$arity$1 = (function (s1){
|
||||
return s1;
|
||||
});
|
||||
|
||||
clojure.set.intersection.cljs$core$IFn$_invoke$arity$2 = (function (s1,s2){
|
||||
while(true){
|
||||
if((cljs.core.count.call(null,s2) < cljs.core.count.call(null,s1))){
|
||||
var G__27618 = s2;
|
||||
var G__27619 = s1;
|
||||
s1 = G__27618;
|
||||
s2 = G__27619;
|
||||
continue;
|
||||
} else {
|
||||
return cljs.core.reduce.call(null,((function (s1,s2){
|
||||
return (function (result,item){
|
||||
if(cljs.core.contains_QMARK_.call(null,s2,item)){
|
||||
return result;
|
||||
} else {
|
||||
return cljs.core.disj.call(null,result,item);
|
||||
}
|
||||
});})(s1,s2))
|
||||
,s1,s1);
|
||||
}
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
clojure.set.intersection.cljs$core$IFn$_invoke$arity$variadic = (function (s1,s2,sets){
|
||||
var bubbled_sets = clojure.set.bubble_max_key.call(null,(function (p1__27608_SHARP_){
|
||||
return (- cljs.core.count.call(null,p1__27608_SHARP_));
|
||||
}),cljs.core.conj.call(null,sets,s2,s1));
|
||||
return cljs.core.reduce.call(null,clojure.set.intersection,cljs.core.first.call(null,bubbled_sets),cljs.core.rest.call(null,bubbled_sets));
|
||||
});
|
||||
|
||||
/** @this {Function} */
|
||||
clojure.set.intersection.cljs$lang$applyTo = (function (seq27610){
|
||||
var G__27611 = cljs.core.first.call(null,seq27610);
|
||||
var seq27610__$1 = cljs.core.next.call(null,seq27610);
|
||||
var G__27612 = cljs.core.first.call(null,seq27610__$1);
|
||||
var seq27610__$2 = cljs.core.next.call(null,seq27610__$1);
|
||||
var self__4717__auto__ = this;
|
||||
return self__4717__auto__.cljs$core$IFn$_invoke$arity$variadic(G__27611,G__27612,seq27610__$2);
|
||||
});
|
||||
|
||||
clojure.set.intersection.cljs$lang$maxFixedArity = (2);
|
||||
|
||||
/**
|
||||
* Return a set that is the first set without elements of the remaining sets
|
||||
*/
|
||||
clojure.set.difference = (function clojure$set$difference(var_args){
|
||||
var G__27624 = arguments.length;
|
||||
switch (G__27624) {
|
||||
case 1:
|
||||
return clojure.set.difference.cljs$core$IFn$_invoke$arity$1((arguments[(0)]));
|
||||
|
||||
break;
|
||||
case 2:
|
||||
return clojure.set.difference.cljs$core$IFn$_invoke$arity$2((arguments[(0)]),(arguments[(1)]));
|
||||
|
||||
break;
|
||||
default:
|
||||
var args_arr__4751__auto__ = [];
|
||||
var len__4730__auto___27626 = arguments.length;
|
||||
var i__4731__auto___27627 = (0);
|
||||
while(true){
|
||||
if((i__4731__auto___27627 < len__4730__auto___27626)){
|
||||
args_arr__4751__auto__.push((arguments[i__4731__auto___27627]));
|
||||
|
||||
var G__27628 = (i__4731__auto___27627 + (1));
|
||||
i__4731__auto___27627 = G__27628;
|
||||
continue;
|
||||
} else {
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
var argseq__4752__auto__ = (new cljs.core.IndexedSeq(args_arr__4751__auto__.slice((2)),(0),null));
|
||||
return clojure.set.difference.cljs$core$IFn$_invoke$arity$variadic((arguments[(0)]),(arguments[(1)]),argseq__4752__auto__);
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
clojure.set.difference.cljs$core$IFn$_invoke$arity$1 = (function (s1){
|
||||
return s1;
|
||||
});
|
||||
|
||||
clojure.set.difference.cljs$core$IFn$_invoke$arity$2 = (function (s1,s2){
|
||||
if((cljs.core.count.call(null,s1) < cljs.core.count.call(null,s2))){
|
||||
return cljs.core.reduce.call(null,(function (result,item){
|
||||
if(cljs.core.contains_QMARK_.call(null,s2,item)){
|
||||
return cljs.core.disj.call(null,result,item);
|
||||
} else {
|
||||
return result;
|
||||
}
|
||||
}),s1,s1);
|
||||
} else {
|
||||
return cljs.core.reduce.call(null,cljs.core.disj,s1,s2);
|
||||
}
|
||||
});
|
||||
|
||||
clojure.set.difference.cljs$core$IFn$_invoke$arity$variadic = (function (s1,s2,sets){
|
||||
return cljs.core.reduce.call(null,clojure.set.difference,s1,cljs.core.conj.call(null,sets,s2));
|
||||
});
|
||||
|
||||
/** @this {Function} */
|
||||
clojure.set.difference.cljs$lang$applyTo = (function (seq27621){
|
||||
var G__27622 = cljs.core.first.call(null,seq27621);
|
||||
var seq27621__$1 = cljs.core.next.call(null,seq27621);
|
||||
var G__27623 = cljs.core.first.call(null,seq27621__$1);
|
||||
var seq27621__$2 = cljs.core.next.call(null,seq27621__$1);
|
||||
var self__4717__auto__ = this;
|
||||
return self__4717__auto__.cljs$core$IFn$_invoke$arity$variadic(G__27622,G__27623,seq27621__$2);
|
||||
});
|
||||
|
||||
clojure.set.difference.cljs$lang$maxFixedArity = (2);
|
||||
|
||||
/**
|
||||
* Returns a set of the elements for which pred is true
|
||||
*/
|
||||
clojure.set.select = (function clojure$set$select(pred,xset){
|
||||
return cljs.core.reduce.call(null,(function (s,k){
|
||||
if(cljs.core.truth_(pred.call(null,k))){
|
||||
return s;
|
||||
} else {
|
||||
return cljs.core.disj.call(null,s,k);
|
||||
}
|
||||
}),xset,xset);
|
||||
});
|
||||
/**
|
||||
* Returns a rel of the elements of xrel with only the keys in ks
|
||||
*/
|
||||
clojure.set.project = (function clojure$set$project(xrel,ks){
|
||||
return cljs.core.set.call(null,cljs.core.map.call(null,(function (p1__27629_SHARP_){
|
||||
return cljs.core.select_keys.call(null,p1__27629_SHARP_,ks);
|
||||
}),xrel));
|
||||
});
|
||||
/**
|
||||
* Returns the map with the keys in kmap renamed to the vals in kmap
|
||||
*/
|
||||
clojure.set.rename_keys = (function clojure$set$rename_keys(map,kmap){
|
||||
return cljs.core.reduce.call(null,(function (m,p__27630){
|
||||
var vec__27631 = p__27630;
|
||||
var old = cljs.core.nth.call(null,vec__27631,(0),null);
|
||||
var new$ = cljs.core.nth.call(null,vec__27631,(1),null);
|
||||
if(cljs.core.contains_QMARK_.call(null,map,old)){
|
||||
return cljs.core.assoc.call(null,m,new$,cljs.core.get.call(null,map,old));
|
||||
} else {
|
||||
return m;
|
||||
}
|
||||
}),cljs.core.apply.call(null,cljs.core.dissoc,map,cljs.core.keys.call(null,kmap)),kmap);
|
||||
});
|
||||
/**
|
||||
* Returns a rel of the maps in xrel with the keys in kmap renamed to the vals in kmap
|
||||
*/
|
||||
clojure.set.rename = (function clojure$set$rename(xrel,kmap){
|
||||
return cljs.core.set.call(null,cljs.core.map.call(null,(function (p1__27634_SHARP_){
|
||||
return clojure.set.rename_keys.call(null,p1__27634_SHARP_,kmap);
|
||||
}),xrel));
|
||||
});
|
||||
/**
|
||||
* Returns a map of the distinct values of ks in the xrel mapped to a
|
||||
* set of the maps in xrel with the corresponding values of ks.
|
||||
*/
|
||||
clojure.set.index = (function clojure$set$index(xrel,ks){
|
||||
return cljs.core.reduce.call(null,(function (m,x){
|
||||
var ik = cljs.core.select_keys.call(null,x,ks);
|
||||
return cljs.core.assoc.call(null,m,ik,cljs.core.conj.call(null,cljs.core.get.call(null,m,ik,cljs.core.PersistentHashSet.EMPTY),x));
|
||||
}),cljs.core.PersistentArrayMap.EMPTY,xrel);
|
||||
});
|
||||
/**
|
||||
* Returns the map with the vals mapped to the keys.
|
||||
*/
|
||||
clojure.set.map_invert = (function clojure$set$map_invert(m){
|
||||
return cljs.core.reduce.call(null,(function (m__$1,p__27635){
|
||||
var vec__27636 = p__27635;
|
||||
var k = cljs.core.nth.call(null,vec__27636,(0),null);
|
||||
var v = cljs.core.nth.call(null,vec__27636,(1),null);
|
||||
return cljs.core.assoc.call(null,m__$1,v,k);
|
||||
}),cljs.core.PersistentArrayMap.EMPTY,m);
|
||||
});
|
||||
/**
|
||||
* When passed 2 rels, returns the rel corresponding to the natural
|
||||
* join. When passed an additional keymap, joins on the corresponding
|
||||
* keys.
|
||||
*/
|
||||
clojure.set.join = (function clojure$set$join(var_args){
|
||||
var G__27644 = arguments.length;
|
||||
switch (G__27644) {
|
||||
case 2:
|
||||
return clojure.set.join.cljs$core$IFn$_invoke$arity$2((arguments[(0)]),(arguments[(1)]));
|
||||
|
||||
break;
|
||||
case 3:
|
||||
return clojure.set.join.cljs$core$IFn$_invoke$arity$3((arguments[(0)]),(arguments[(1)]),(arguments[(2)]));
|
||||
|
||||
break;
|
||||
default:
|
||||
throw (new Error(["Invalid arity: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(arguments.length)].join('')));
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
clojure.set.join.cljs$core$IFn$_invoke$arity$2 = (function (xrel,yrel){
|
||||
if(((cljs.core.seq.call(null,xrel)) && (cljs.core.seq.call(null,yrel)))){
|
||||
var ks = clojure.set.intersection.call(null,cljs.core.set.call(null,cljs.core.keys.call(null,cljs.core.first.call(null,xrel))),cljs.core.set.call(null,cljs.core.keys.call(null,cljs.core.first.call(null,yrel))));
|
||||
var vec__27645 = (((cljs.core.count.call(null,xrel) <= cljs.core.count.call(null,yrel)))?new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [xrel,yrel], null):new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [yrel,xrel], null));
|
||||
var r = cljs.core.nth.call(null,vec__27645,(0),null);
|
||||
var s = cljs.core.nth.call(null,vec__27645,(1),null);
|
||||
var idx = clojure.set.index.call(null,r,ks);
|
||||
return cljs.core.reduce.call(null,((function (ks,vec__27645,r,s,idx){
|
||||
return (function (ret,x){
|
||||
var found = idx.call(null,cljs.core.select_keys.call(null,x,ks));
|
||||
if(cljs.core.truth_(found)){
|
||||
return cljs.core.reduce.call(null,((function (found,ks,vec__27645,r,s,idx){
|
||||
return (function (p1__27639_SHARP_,p2__27640_SHARP_){
|
||||
return cljs.core.conj.call(null,p1__27639_SHARP_,cljs.core.merge.call(null,p2__27640_SHARP_,x));
|
||||
});})(found,ks,vec__27645,r,s,idx))
|
||||
,ret,found);
|
||||
} else {
|
||||
return ret;
|
||||
}
|
||||
});})(ks,vec__27645,r,s,idx))
|
||||
,cljs.core.PersistentHashSet.EMPTY,s);
|
||||
} else {
|
||||
return cljs.core.PersistentHashSet.EMPTY;
|
||||
}
|
||||
});
|
||||
|
||||
clojure.set.join.cljs$core$IFn$_invoke$arity$3 = (function (xrel,yrel,km){
|
||||
var vec__27648 = (((cljs.core.count.call(null,xrel) <= cljs.core.count.call(null,yrel)))?new cljs.core.PersistentVector(null, 3, 5, cljs.core.PersistentVector.EMPTY_NODE, [xrel,yrel,clojure.set.map_invert.call(null,km)], null):new cljs.core.PersistentVector(null, 3, 5, cljs.core.PersistentVector.EMPTY_NODE, [yrel,xrel,km], null));
|
||||
var r = cljs.core.nth.call(null,vec__27648,(0),null);
|
||||
var s = cljs.core.nth.call(null,vec__27648,(1),null);
|
||||
var k = cljs.core.nth.call(null,vec__27648,(2),null);
|
||||
var idx = clojure.set.index.call(null,r,cljs.core.vals.call(null,k));
|
||||
return cljs.core.reduce.call(null,((function (vec__27648,r,s,k,idx){
|
||||
return (function (ret,x){
|
||||
var found = idx.call(null,clojure.set.rename_keys.call(null,cljs.core.select_keys.call(null,x,cljs.core.keys.call(null,k)),k));
|
||||
if(cljs.core.truth_(found)){
|
||||
return cljs.core.reduce.call(null,((function (found,vec__27648,r,s,k,idx){
|
||||
return (function (p1__27641_SHARP_,p2__27642_SHARP_){
|
||||
return cljs.core.conj.call(null,p1__27641_SHARP_,cljs.core.merge.call(null,p2__27642_SHARP_,x));
|
||||
});})(found,vec__27648,r,s,k,idx))
|
||||
,ret,found);
|
||||
} else {
|
||||
return ret;
|
||||
}
|
||||
});})(vec__27648,r,s,k,idx))
|
||||
,cljs.core.PersistentHashSet.EMPTY,s);
|
||||
});
|
||||
|
||||
clojure.set.join.cljs$lang$maxFixedArity = 3;
|
||||
|
||||
/**
|
||||
* Is set1 a subset of set2?
|
||||
*/
|
||||
clojure.set.subset_QMARK_ = (function clojure$set$subset_QMARK_(set1,set2){
|
||||
return (((cljs.core.count.call(null,set1) <= cljs.core.count.call(null,set2))) && (cljs.core.every_QMARK_.call(null,(function (p1__27652_SHARP_){
|
||||
return cljs.core.contains_QMARK_.call(null,set2,p1__27652_SHARP_);
|
||||
}),set1)));
|
||||
});
|
||||
/**
|
||||
* Is set1 a superset of set2?
|
||||
*/
|
||||
clojure.set.superset_QMARK_ = (function clojure$set$superset_QMARK_(set1,set2){
|
||||
return (((cljs.core.count.call(null,set1) >= cljs.core.count.call(null,set2))) && (cljs.core.every_QMARK_.call(null,(function (p1__27653_SHARP_){
|
||||
return cljs.core.contains_QMARK_.call(null,set1,p1__27653_SHARP_);
|
||||
}),set2)));
|
||||
});
|
||||
|
||||
//# sourceMappingURL=set.js.map?rel=1582812680387
|
||||
1
js/compiled/out/clojure/set.js.map
Normal file
1
js/compiled/out/clojure/set.js.map
Normal file
File diff suppressed because one or more lines are too long
289
js/compiled/out/clojure/string.cljs
Normal file
289
js/compiled/out/clojure/string.cljs
Normal file
|
|
@ -0,0 +1,289 @@
|
|||
; Copyright (c) Rich Hickey. All rights reserved.
|
||||
; The use and distribution terms for this software are covered by the
|
||||
; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)
|
||||
; which can be found in the file epl-v10.html at the root of this distribution.
|
||||
; By using this software in any fashion, you are agreeing to be bound by
|
||||
; the terms of this license.
|
||||
; You must not remove this notice, or any other, from this software.
|
||||
|
||||
(ns clojure.string
|
||||
(:refer-clojure :exclude [replace reverse])
|
||||
(:require [goog.string :as gstring])
|
||||
(:import [goog.string StringBuffer]))
|
||||
|
||||
(defn- seq-reverse
|
||||
[coll]
|
||||
(reduce conj () coll))
|
||||
|
||||
(def ^:private re-surrogate-pair
|
||||
(js/RegExp. "([\\uD800-\\uDBFF])([\\uDC00-\\uDFFF])" "g"))
|
||||
|
||||
(defn reverse
|
||||
"Returns s with its characters reversed."
|
||||
[s]
|
||||
(-> (.replace s re-surrogate-pair "$2$1")
|
||||
(.. (split "") (reverse) (join ""))))
|
||||
|
||||
(defn- replace-all
|
||||
[s re replacement]
|
||||
(let [r (js/RegExp. (.-source re)
|
||||
(cond-> "g"
|
||||
(.-ignoreCase re) (str "i")
|
||||
(.-multiline re) (str "m")
|
||||
(.-unicode re) (str "u")))]
|
||||
(.replace s r replacement)))
|
||||
|
||||
(defn- replace-with
|
||||
[f]
|
||||
(fn [& args]
|
||||
(let [matches (drop-last 2 args)]
|
||||
(if (= (count matches) 1)
|
||||
(f (first matches))
|
||||
(f (vec matches))))))
|
||||
|
||||
(defn replace
|
||||
"Replaces all instance of match with replacement in s.
|
||||
|
||||
match/replacement can be:
|
||||
|
||||
string / string
|
||||
pattern / (string or function of match).
|
||||
|
||||
See also replace-first.
|
||||
|
||||
The replacement is literal (i.e. none of its characters are treated
|
||||
specially) for all cases above except pattern / string.
|
||||
|
||||
For pattern / string, $1, $2, etc. in the replacement string are
|
||||
substituted with the string that matched the corresponding
|
||||
parenthesized group in the pattern.
|
||||
|
||||
Example:
|
||||
(clojure.string/replace \"Almost Pig Latin\" #\"\\b(\\w)(\\w+)\\b\" \"$2$1ay\")
|
||||
-> \"lmostAay igPay atinLay\""
|
||||
[s match replacement]
|
||||
(cond
|
||||
(string? match)
|
||||
(.replace s (js/RegExp. (gstring/regExpEscape match) "g") replacement)
|
||||
|
||||
(instance? js/RegExp match)
|
||||
(if (string? replacement)
|
||||
(replace-all s match replacement)
|
||||
(replace-all s match (replace-with replacement)))
|
||||
|
||||
:else (throw (str "Invalid match arg: " match))))
|
||||
|
||||
(defn replace-first
|
||||
"Replaces the first instance of match with replacement in s.
|
||||
|
||||
match/replacement can be:
|
||||
|
||||
string / string
|
||||
pattern / (string or function of match).
|
||||
|
||||
See also replace.
|
||||
|
||||
The replacement is literal (i.e. none of its characters are treated
|
||||
specially) for all cases above except pattern / string.
|
||||
|
||||
For pattern / string, $1, $2, etc. in the replacement string are
|
||||
substituted with the string that matched the corresponding
|
||||
parenthesized group in the pattern.
|
||||
|
||||
Example:
|
||||
(clojure.string/replace-first \"swap first two words\"
|
||||
#\"(\\w+)(\\s+)(\\w+)\" \"$3$2$1\")
|
||||
-> \"first swap two words\""
|
||||
[s match replacement]
|
||||
(.replace s match replacement))
|
||||
|
||||
(defn join
|
||||
"Returns a string of all elements in coll, as returned by (seq coll),
|
||||
separated by an optional separator."
|
||||
([coll]
|
||||
(loop [sb (StringBuffer.) coll (seq coll)]
|
||||
(if-not (nil? coll)
|
||||
(recur (. sb (append (str (first coll)))) (next coll))
|
||||
(.toString sb))))
|
||||
([separator coll]
|
||||
(loop [sb (StringBuffer.) coll (seq coll)]
|
||||
(if-not (nil? coll)
|
||||
(do
|
||||
(. sb (append (str (first coll))))
|
||||
(let [coll (next coll)]
|
||||
(when-not (nil? coll)
|
||||
(. sb (append separator)))
|
||||
(recur sb coll)))
|
||||
(.toString sb)))))
|
||||
|
||||
(defn upper-case
|
||||
"Converts string to all upper-case."
|
||||
[s]
|
||||
(.toUpperCase s))
|
||||
|
||||
(defn lower-case
|
||||
"Converts string to all lower-case."
|
||||
[s]
|
||||
(.toLowerCase s))
|
||||
|
||||
(defn capitalize
|
||||
"Converts first character of the string to upper-case, all other
|
||||
characters to lower-case."
|
||||
[s]
|
||||
(gstring/capitalize s))
|
||||
|
||||
;; The JavaScript split function takes a limit argument but the return
|
||||
;; value is not the same as the Java split function.
|
||||
;;
|
||||
;; Java: (.split "a-b-c" #"-" 2) => ["a" "b-c"]
|
||||
;; JavaScript: (.split "a-b-c" #"-" 2) => ["a" "b"]
|
||||
;;
|
||||
;; For consistency, the three arg version has been implemented to
|
||||
;; mimic Java's behavior.
|
||||
|
||||
(defn- pop-last-while-empty
|
||||
[v]
|
||||
(loop [v v]
|
||||
(if (identical? "" (peek v))
|
||||
(recur (pop v))
|
||||
v)))
|
||||
|
||||
(defn- discard-trailing-if-needed
|
||||
[limit v]
|
||||
(if (and (== 0 limit) (< 1 (count v)))
|
||||
(pop-last-while-empty v)
|
||||
v))
|
||||
|
||||
(defn- split-with-empty-regex
|
||||
[s limit]
|
||||
(if (or (<= limit 0) (>= limit (+ 2 (count s))))
|
||||
(conj (vec (cons "" (map str (seq s)))) "")
|
||||
(condp == limit
|
||||
1 (vector s)
|
||||
2 (vector "" s)
|
||||
(let [c (- limit 2)]
|
||||
(conj (vec (cons "" (subvec (vec (map str (seq s))) 0 c))) (subs s c))))))
|
||||
|
||||
(defn split
|
||||
"Splits string on a regular expression. Optional argument limit is
|
||||
the maximum number of splits. Not lazy. Returns vector of the splits."
|
||||
([s re]
|
||||
(split s re 0))
|
||||
([s re limit]
|
||||
(discard-trailing-if-needed limit
|
||||
(if (identical? "/(?:)/" (str re))
|
||||
(split-with-empty-regex s limit)
|
||||
(if (< limit 1)
|
||||
(vec (.split (str s) re))
|
||||
(loop [s s
|
||||
limit limit
|
||||
parts []]
|
||||
(if (== 1 limit)
|
||||
(conj parts s)
|
||||
(let [m (re-find re s)]
|
||||
(if-not (nil? m)
|
||||
(let [index (.indexOf s m)]
|
||||
(recur (.substring s (+ index (count m)))
|
||||
(dec limit)
|
||||
(conj parts (.substring s 0 index))))
|
||||
(conj parts s))))))))))
|
||||
|
||||
(defn split-lines
|
||||
"Splits s on \\n or \\r\\n."
|
||||
[s]
|
||||
(split s #"\n|\r\n"))
|
||||
|
||||
(defn trim
|
||||
"Removes whitespace from both ends of string."
|
||||
[s]
|
||||
(gstring/trim s))
|
||||
|
||||
(defn triml
|
||||
"Removes whitespace from the left side of string."
|
||||
[s]
|
||||
(gstring/trimLeft s))
|
||||
|
||||
(defn trimr
|
||||
"Removes whitespace from the right side of string."
|
||||
[s]
|
||||
(gstring/trimRight s))
|
||||
|
||||
(defn trim-newline
|
||||
"Removes all trailing newline \\n or return \\r characters from
|
||||
string. Similar to Perl's chomp."
|
||||
[s]
|
||||
(loop [index (.-length s)]
|
||||
(if (zero? index)
|
||||
""
|
||||
(let [ch (get s (dec index))]
|
||||
(if (or (identical? \newline ch)
|
||||
(identical? \return ch))
|
||||
(recur (dec index))
|
||||
(.substring s 0 index))))))
|
||||
|
||||
(defn ^boolean blank?
|
||||
"True is s is nil, empty, or contains only whitespace."
|
||||
[s]
|
||||
(gstring/isEmptySafe s))
|
||||
|
||||
(defn escape
|
||||
"Return a new string, using cmap to escape each character ch
|
||||
from s as follows:
|
||||
|
||||
If (cmap ch) is nil, append ch to the new string.
|
||||
If (cmap ch) is non-nil, append (str (cmap ch)) instead."
|
||||
[s cmap]
|
||||
(let [buffer (StringBuffer.)
|
||||
length (.-length s)]
|
||||
(loop [index 0]
|
||||
(if (== length index)
|
||||
(. buffer (toString))
|
||||
(let [ch (.charAt s index)
|
||||
replacement (get cmap ch)]
|
||||
(if-not (nil? replacement)
|
||||
(.append buffer (str replacement))
|
||||
(.append buffer ch))
|
||||
(recur (inc index)))))))
|
||||
|
||||
(defn index-of
|
||||
"Return index of value (string or char) in s, optionally searching
|
||||
forward from from-index or nil if not found."
|
||||
([s value]
|
||||
(let [result (.indexOf s value)]
|
||||
(if (neg? result)
|
||||
nil
|
||||
result)))
|
||||
([s value from-index]
|
||||
(let [result (.indexOf s value from-index)]
|
||||
(if (neg? result)
|
||||
nil
|
||||
result))))
|
||||
|
||||
(defn last-index-of
|
||||
"Return last index of value (string or char) in s, optionally
|
||||
searching backward from from-index or nil if not found."
|
||||
([s value]
|
||||
(let [result (.lastIndexOf s value)]
|
||||
(if (neg? result)
|
||||
nil
|
||||
result)))
|
||||
([s value from-index]
|
||||
(let [result (.lastIndexOf s value from-index)]
|
||||
(if (neg? result)
|
||||
nil
|
||||
result))))
|
||||
|
||||
(defn ^boolean starts-with?
|
||||
"True if s starts with substr."
|
||||
[s substr]
|
||||
(gstring/startsWith s substr))
|
||||
|
||||
(defn ^boolean ends-with?
|
||||
"True if s ends with substr."
|
||||
[s substr]
|
||||
(gstring/endsWith s substr))
|
||||
|
||||
(defn ^boolean includes?
|
||||
"True if s includes substr."
|
||||
[s substr]
|
||||
(gstring/contains s substr))
|
||||
1
js/compiled/out/clojure/string.cljs.cache.json
Normal file
1
js/compiled/out/clojure/string.cljs.cache.json
Normal file
File diff suppressed because one or more lines are too long
477
js/compiled/out/clojure/string.js
Normal file
477
js/compiled/out/clojure/string.js
Normal file
|
|
@ -0,0 +1,477 @@
|
|||
// Compiled by ClojureScript 1.10.520 {}
|
||||
goog.provide('clojure.string');
|
||||
goog.require('cljs.core');
|
||||
goog.require('goog.string');
|
||||
goog.require('goog.string.StringBuffer');
|
||||
clojure.string.seq_reverse = (function clojure$string$seq_reverse(coll){
|
||||
return cljs.core.reduce.call(null,cljs.core.conj,cljs.core.List.EMPTY,coll);
|
||||
});
|
||||
clojure.string.re_surrogate_pair = (new RegExp("([\\uD800-\\uDBFF])([\\uDC00-\\uDFFF])","g"));
|
||||
/**
|
||||
* Returns s with its characters reversed.
|
||||
*/
|
||||
clojure.string.reverse = (function clojure$string$reverse(s){
|
||||
return s.replace(clojure.string.re_surrogate_pair,"$2$1").split("").reverse().join("");
|
||||
});
|
||||
clojure.string.replace_all = (function clojure$string$replace_all(s,re,replacement){
|
||||
var r = (new RegExp(re.source,(function (){var G__20921 = "g";
|
||||
var G__20921__$1 = (cljs.core.truth_(re.ignoreCase)?[G__20921,"i"].join(''):G__20921);
|
||||
var G__20921__$2 = (cljs.core.truth_(re.multiline)?[G__20921__$1,"m"].join(''):G__20921__$1);
|
||||
if(cljs.core.truth_(re.unicode)){
|
||||
return [G__20921__$2,"u"].join('');
|
||||
} else {
|
||||
return G__20921__$2;
|
||||
}
|
||||
})()));
|
||||
return s.replace(r,replacement);
|
||||
});
|
||||
clojure.string.replace_with = (function clojure$string$replace_with(f){
|
||||
return (function() {
|
||||
var G__20922__delegate = function (args){
|
||||
var matches = cljs.core.drop_last.call(null,(2),args);
|
||||
if(cljs.core._EQ_.call(null,cljs.core.count.call(null,matches),(1))){
|
||||
return f.call(null,cljs.core.first.call(null,matches));
|
||||
} else {
|
||||
return f.call(null,cljs.core.vec.call(null,matches));
|
||||
}
|
||||
};
|
||||
var G__20922 = function (var_args){
|
||||
var args = null;
|
||||
if (arguments.length > 0) {
|
||||
var G__20923__i = 0, G__20923__a = new Array(arguments.length - 0);
|
||||
while (G__20923__i < G__20923__a.length) {G__20923__a[G__20923__i] = arguments[G__20923__i + 0]; ++G__20923__i;}
|
||||
args = new cljs.core.IndexedSeq(G__20923__a,0,null);
|
||||
}
|
||||
return G__20922__delegate.call(this,args);};
|
||||
G__20922.cljs$lang$maxFixedArity = 0;
|
||||
G__20922.cljs$lang$applyTo = (function (arglist__20924){
|
||||
var args = cljs.core.seq(arglist__20924);
|
||||
return G__20922__delegate(args);
|
||||
});
|
||||
G__20922.cljs$core$IFn$_invoke$arity$variadic = G__20922__delegate;
|
||||
return G__20922;
|
||||
})()
|
||||
;
|
||||
});
|
||||
/**
|
||||
* Replaces all instance of match with replacement in s.
|
||||
*
|
||||
* match/replacement can be:
|
||||
*
|
||||
* string / string
|
||||
* pattern / (string or function of match).
|
||||
*
|
||||
* See also replace-first.
|
||||
*
|
||||
* The replacement is literal (i.e. none of its characters are treated
|
||||
* specially) for all cases above except pattern / string.
|
||||
*
|
||||
* For pattern / string, $1, $2, etc. in the replacement string are
|
||||
* substituted with the string that matched the corresponding
|
||||
* parenthesized group in the pattern.
|
||||
*
|
||||
* Example:
|
||||
* (clojure.string/replace "Almost Pig Latin" #"\b(\w)(\w+)\b" "$2$1ay")
|
||||
* -> "lmostAay igPay atinLay"
|
||||
*/
|
||||
clojure.string.replace = (function clojure$string$replace(s,match,replacement){
|
||||
if(typeof match === 'string'){
|
||||
return s.replace((new RegExp(goog.string.regExpEscape(match),"g")),replacement);
|
||||
} else {
|
||||
if((match instanceof RegExp)){
|
||||
if(typeof replacement === 'string'){
|
||||
return clojure.string.replace_all.call(null,s,match,replacement);
|
||||
} else {
|
||||
return clojure.string.replace_all.call(null,s,match,clojure.string.replace_with.call(null,replacement));
|
||||
}
|
||||
} else {
|
||||
throw ["Invalid match arg: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(match)].join('');
|
||||
|
||||
}
|
||||
}
|
||||
});
|
||||
/**
|
||||
* Replaces the first instance of match with replacement in s.
|
||||
*
|
||||
* match/replacement can be:
|
||||
*
|
||||
* string / string
|
||||
* pattern / (string or function of match).
|
||||
*
|
||||
* See also replace.
|
||||
*
|
||||
* The replacement is literal (i.e. none of its characters are treated
|
||||
* specially) for all cases above except pattern / string.
|
||||
*
|
||||
* For pattern / string, $1, $2, etc. in the replacement string are
|
||||
* substituted with the string that matched the corresponding
|
||||
* parenthesized group in the pattern.
|
||||
*
|
||||
* Example:
|
||||
* (clojure.string/replace-first "swap first two words"
|
||||
* #"(\w+)(\s+)(\w+)" "$3$2$1")
|
||||
* -> "first swap two words"
|
||||
*/
|
||||
clojure.string.replace_first = (function clojure$string$replace_first(s,match,replacement){
|
||||
return s.replace(match,replacement);
|
||||
});
|
||||
/**
|
||||
* Returns a string of all elements in coll, as returned by (seq coll),
|
||||
* separated by an optional separator.
|
||||
*/
|
||||
clojure.string.join = (function clojure$string$join(var_args){
|
||||
var G__20926 = arguments.length;
|
||||
switch (G__20926) {
|
||||
case 1:
|
||||
return clojure.string.join.cljs$core$IFn$_invoke$arity$1((arguments[(0)]));
|
||||
|
||||
break;
|
||||
case 2:
|
||||
return clojure.string.join.cljs$core$IFn$_invoke$arity$2((arguments[(0)]),(arguments[(1)]));
|
||||
|
||||
break;
|
||||
default:
|
||||
throw (new Error(["Invalid arity: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(arguments.length)].join('')));
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
clojure.string.join.cljs$core$IFn$_invoke$arity$1 = (function (coll){
|
||||
var sb = (new goog.string.StringBuffer());
|
||||
var coll__$1 = cljs.core.seq.call(null,coll);
|
||||
while(true){
|
||||
if((!((coll__$1 == null)))){
|
||||
var G__20928 = sb.append(cljs.core.str.cljs$core$IFn$_invoke$arity$1(cljs.core.first.call(null,coll__$1)));
|
||||
var G__20929 = cljs.core.next.call(null,coll__$1);
|
||||
sb = G__20928;
|
||||
coll__$1 = G__20929;
|
||||
continue;
|
||||
} else {
|
||||
return sb.toString();
|
||||
}
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
clojure.string.join.cljs$core$IFn$_invoke$arity$2 = (function (separator,coll){
|
||||
var sb = (new goog.string.StringBuffer());
|
||||
var coll__$1 = cljs.core.seq.call(null,coll);
|
||||
while(true){
|
||||
if((!((coll__$1 == null)))){
|
||||
sb.append(cljs.core.str.cljs$core$IFn$_invoke$arity$1(cljs.core.first.call(null,coll__$1)));
|
||||
|
||||
var coll__$2 = cljs.core.next.call(null,coll__$1);
|
||||
if((coll__$2 == null)){
|
||||
} else {
|
||||
sb.append(separator);
|
||||
}
|
||||
|
||||
var G__20930 = sb;
|
||||
var G__20931 = coll__$2;
|
||||
sb = G__20930;
|
||||
coll__$1 = G__20931;
|
||||
continue;
|
||||
} else {
|
||||
return sb.toString();
|
||||
}
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
clojure.string.join.cljs$lang$maxFixedArity = 2;
|
||||
|
||||
/**
|
||||
* Converts string to all upper-case.
|
||||
*/
|
||||
clojure.string.upper_case = (function clojure$string$upper_case(s){
|
||||
return s.toUpperCase();
|
||||
});
|
||||
/**
|
||||
* Converts string to all lower-case.
|
||||
*/
|
||||
clojure.string.lower_case = (function clojure$string$lower_case(s){
|
||||
return s.toLowerCase();
|
||||
});
|
||||
/**
|
||||
* Converts first character of the string to upper-case, all other
|
||||
* characters to lower-case.
|
||||
*/
|
||||
clojure.string.capitalize = (function clojure$string$capitalize(s){
|
||||
return goog.string.capitalize(s);
|
||||
});
|
||||
clojure.string.pop_last_while_empty = (function clojure$string$pop_last_while_empty(v){
|
||||
var v__$1 = v;
|
||||
while(true){
|
||||
if(("" === cljs.core.peek.call(null,v__$1))){
|
||||
var G__20932 = cljs.core.pop.call(null,v__$1);
|
||||
v__$1 = G__20932;
|
||||
continue;
|
||||
} else {
|
||||
return v__$1;
|
||||
}
|
||||
break;
|
||||
}
|
||||
});
|
||||
clojure.string.discard_trailing_if_needed = (function clojure$string$discard_trailing_if_needed(limit,v){
|
||||
if(((((0) === limit)) && (((1) < cljs.core.count.call(null,v))))){
|
||||
return clojure.string.pop_last_while_empty.call(null,v);
|
||||
} else {
|
||||
return v;
|
||||
}
|
||||
});
|
||||
clojure.string.split_with_empty_regex = (function clojure$string$split_with_empty_regex(s,limit){
|
||||
if((((limit <= (0))) || ((limit >= ((2) + cljs.core.count.call(null,s)))))){
|
||||
return cljs.core.conj.call(null,cljs.core.vec.call(null,cljs.core.cons.call(null,"",cljs.core.map.call(null,cljs.core.str,cljs.core.seq.call(null,s)))),"");
|
||||
} else {
|
||||
var pred__20933 = cljs.core._EQ__EQ_;
|
||||
var expr__20934 = limit;
|
||||
if(cljs.core.truth_(pred__20933.call(null,(1),expr__20934))){
|
||||
return (new cljs.core.PersistentVector(null,1,(5),cljs.core.PersistentVector.EMPTY_NODE,[s],null));
|
||||
} else {
|
||||
if(cljs.core.truth_(pred__20933.call(null,(2),expr__20934))){
|
||||
return (new cljs.core.PersistentVector(null,2,(5),cljs.core.PersistentVector.EMPTY_NODE,["",s],null));
|
||||
} else {
|
||||
var c = (limit - (2));
|
||||
return cljs.core.conj.call(null,cljs.core.vec.call(null,cljs.core.cons.call(null,"",cljs.core.subvec.call(null,cljs.core.vec.call(null,cljs.core.map.call(null,cljs.core.str,cljs.core.seq.call(null,s))),(0),c))),cljs.core.subs.call(null,s,c));
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
/**
|
||||
* Splits string on a regular expression. Optional argument limit is
|
||||
* the maximum number of splits. Not lazy. Returns vector of the splits.
|
||||
*/
|
||||
clojure.string.split = (function clojure$string$split(var_args){
|
||||
var G__20937 = arguments.length;
|
||||
switch (G__20937) {
|
||||
case 2:
|
||||
return clojure.string.split.cljs$core$IFn$_invoke$arity$2((arguments[(0)]),(arguments[(1)]));
|
||||
|
||||
break;
|
||||
case 3:
|
||||
return clojure.string.split.cljs$core$IFn$_invoke$arity$3((arguments[(0)]),(arguments[(1)]),(arguments[(2)]));
|
||||
|
||||
break;
|
||||
default:
|
||||
throw (new Error(["Invalid arity: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(arguments.length)].join('')));
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
clojure.string.split.cljs$core$IFn$_invoke$arity$2 = (function (s,re){
|
||||
return clojure.string.split.call(null,s,re,(0));
|
||||
});
|
||||
|
||||
clojure.string.split.cljs$core$IFn$_invoke$arity$3 = (function (s,re,limit){
|
||||
return clojure.string.discard_trailing_if_needed.call(null,limit,((("/(?:)/" === cljs.core.str.cljs$core$IFn$_invoke$arity$1(re)))?clojure.string.split_with_empty_regex.call(null,s,limit):(((limit < (1)))?cljs.core.vec.call(null,cljs.core.str.cljs$core$IFn$_invoke$arity$1(s).split(re)):(function (){var s__$1 = s;
|
||||
var limit__$1 = limit;
|
||||
var parts = cljs.core.PersistentVector.EMPTY;
|
||||
while(true){
|
||||
if(((1) === limit__$1)){
|
||||
return cljs.core.conj.call(null,parts,s__$1);
|
||||
} else {
|
||||
var m = cljs.core.re_find.call(null,re,s__$1);
|
||||
if((!((m == null)))){
|
||||
var index = s__$1.indexOf(m);
|
||||
var G__20939 = s__$1.substring((index + cljs.core.count.call(null,m)));
|
||||
var G__20940 = (limit__$1 - (1));
|
||||
var G__20941 = cljs.core.conj.call(null,parts,s__$1.substring((0),index));
|
||||
s__$1 = G__20939;
|
||||
limit__$1 = G__20940;
|
||||
parts = G__20941;
|
||||
continue;
|
||||
} else {
|
||||
return cljs.core.conj.call(null,parts,s__$1);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
})())));
|
||||
});
|
||||
|
||||
clojure.string.split.cljs$lang$maxFixedArity = 3;
|
||||
|
||||
/**
|
||||
* Splits s on \n or \r\n.
|
||||
*/
|
||||
clojure.string.split_lines = (function clojure$string$split_lines(s){
|
||||
return clojure.string.split.call(null,s,/\n|\r\n/);
|
||||
});
|
||||
/**
|
||||
* Removes whitespace from both ends of string.
|
||||
*/
|
||||
clojure.string.trim = (function clojure$string$trim(s){
|
||||
return goog.string.trim(s);
|
||||
});
|
||||
/**
|
||||
* Removes whitespace from the left side of string.
|
||||
*/
|
||||
clojure.string.triml = (function clojure$string$triml(s){
|
||||
return goog.string.trimLeft(s);
|
||||
});
|
||||
/**
|
||||
* Removes whitespace from the right side of string.
|
||||
*/
|
||||
clojure.string.trimr = (function clojure$string$trimr(s){
|
||||
return goog.string.trimRight(s);
|
||||
});
|
||||
/**
|
||||
* Removes all trailing newline \n or return \r characters from
|
||||
* string. Similar to Perl's chomp.
|
||||
*/
|
||||
clojure.string.trim_newline = (function clojure$string$trim_newline(s){
|
||||
var index = s.length;
|
||||
while(true){
|
||||
if((index === (0))){
|
||||
return "";
|
||||
} else {
|
||||
var ch = cljs.core.get.call(null,s,(index - (1)));
|
||||
if(((("\n" === ch)) || (("\r" === ch)))){
|
||||
var G__20942 = (index - (1));
|
||||
index = G__20942;
|
||||
continue;
|
||||
} else {
|
||||
return s.substring((0),index);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
});
|
||||
/**
|
||||
* True is s is nil, empty, or contains only whitespace.
|
||||
*/
|
||||
clojure.string.blank_QMARK_ = (function clojure$string$blank_QMARK_(s){
|
||||
return goog.string.isEmptySafe(s);
|
||||
});
|
||||
/**
|
||||
* Return a new string, using cmap to escape each character ch
|
||||
* from s as follows:
|
||||
*
|
||||
* If (cmap ch) is nil, append ch to the new string.
|
||||
* If (cmap ch) is non-nil, append (str (cmap ch)) instead.
|
||||
*/
|
||||
clojure.string.escape = (function clojure$string$escape(s,cmap){
|
||||
var buffer = (new goog.string.StringBuffer());
|
||||
var length = s.length;
|
||||
var index = (0);
|
||||
while(true){
|
||||
if((length === index)){
|
||||
return buffer.toString();
|
||||
} else {
|
||||
var ch = s.charAt(index);
|
||||
var replacement = cljs.core.get.call(null,cmap,ch);
|
||||
if((!((replacement == null)))){
|
||||
buffer.append(cljs.core.str.cljs$core$IFn$_invoke$arity$1(replacement));
|
||||
} else {
|
||||
buffer.append(ch);
|
||||
}
|
||||
|
||||
var G__20943 = (index + (1));
|
||||
index = G__20943;
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
});
|
||||
/**
|
||||
* Return index of value (string or char) in s, optionally searching
|
||||
* forward from from-index or nil if not found.
|
||||
*/
|
||||
clojure.string.index_of = (function clojure$string$index_of(var_args){
|
||||
var G__20945 = arguments.length;
|
||||
switch (G__20945) {
|
||||
case 2:
|
||||
return clojure.string.index_of.cljs$core$IFn$_invoke$arity$2((arguments[(0)]),(arguments[(1)]));
|
||||
|
||||
break;
|
||||
case 3:
|
||||
return clojure.string.index_of.cljs$core$IFn$_invoke$arity$3((arguments[(0)]),(arguments[(1)]),(arguments[(2)]));
|
||||
|
||||
break;
|
||||
default:
|
||||
throw (new Error(["Invalid arity: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(arguments.length)].join('')));
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
clojure.string.index_of.cljs$core$IFn$_invoke$arity$2 = (function (s,value){
|
||||
var result = s.indexOf(value);
|
||||
if((result < (0))){
|
||||
return null;
|
||||
} else {
|
||||
return result;
|
||||
}
|
||||
});
|
||||
|
||||
clojure.string.index_of.cljs$core$IFn$_invoke$arity$3 = (function (s,value,from_index){
|
||||
var result = s.indexOf(value,from_index);
|
||||
if((result < (0))){
|
||||
return null;
|
||||
} else {
|
||||
return result;
|
||||
}
|
||||
});
|
||||
|
||||
clojure.string.index_of.cljs$lang$maxFixedArity = 3;
|
||||
|
||||
/**
|
||||
* Return last index of value (string or char) in s, optionally
|
||||
* searching backward from from-index or nil if not found.
|
||||
*/
|
||||
clojure.string.last_index_of = (function clojure$string$last_index_of(var_args){
|
||||
var G__20948 = arguments.length;
|
||||
switch (G__20948) {
|
||||
case 2:
|
||||
return clojure.string.last_index_of.cljs$core$IFn$_invoke$arity$2((arguments[(0)]),(arguments[(1)]));
|
||||
|
||||
break;
|
||||
case 3:
|
||||
return clojure.string.last_index_of.cljs$core$IFn$_invoke$arity$3((arguments[(0)]),(arguments[(1)]),(arguments[(2)]));
|
||||
|
||||
break;
|
||||
default:
|
||||
throw (new Error(["Invalid arity: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(arguments.length)].join('')));
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
clojure.string.last_index_of.cljs$core$IFn$_invoke$arity$2 = (function (s,value){
|
||||
var result = s.lastIndexOf(value);
|
||||
if((result < (0))){
|
||||
return null;
|
||||
} else {
|
||||
return result;
|
||||
}
|
||||
});
|
||||
|
||||
clojure.string.last_index_of.cljs$core$IFn$_invoke$arity$3 = (function (s,value,from_index){
|
||||
var result = s.lastIndexOf(value,from_index);
|
||||
if((result < (0))){
|
||||
return null;
|
||||
} else {
|
||||
return result;
|
||||
}
|
||||
});
|
||||
|
||||
clojure.string.last_index_of.cljs$lang$maxFixedArity = 3;
|
||||
|
||||
/**
|
||||
* True if s starts with substr.
|
||||
*/
|
||||
clojure.string.starts_with_QMARK_ = (function clojure$string$starts_with_QMARK_(s,substr){
|
||||
return goog.string.startsWith(s,substr);
|
||||
});
|
||||
/**
|
||||
* True if s ends with substr.
|
||||
*/
|
||||
clojure.string.ends_with_QMARK_ = (function clojure$string$ends_with_QMARK_(s,substr){
|
||||
return goog.string.endsWith(s,substr);
|
||||
});
|
||||
/**
|
||||
* True if s includes substr.
|
||||
*/
|
||||
clojure.string.includes_QMARK_ = (function clojure$string$includes_QMARK_(s,substr){
|
||||
return goog.string.contains(s,substr);
|
||||
});
|
||||
|
||||
//# sourceMappingURL=string.js.map?rel=1582812677039
|
||||
1
js/compiled/out/clojure/string.js.map
Normal file
1
js/compiled/out/clojure/string.js.map
Normal file
File diff suppressed because one or more lines are too long
98
js/compiled/out/clojure/walk.cljs
Normal file
98
js/compiled/out/clojure/walk.cljs
Normal file
|
|
@ -0,0 +1,98 @@
|
|||
; Copyright (c) Rich Hickey. All rights reserved.
|
||||
; The use and distribution terms for this software are covered by the
|
||||
; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)
|
||||
; which can be found in the file epl-v10.html at the root of this distribution.
|
||||
; By using this software in any fashion, you are agreeing to be bound by
|
||||
; the terms of this license.
|
||||
; You must not remove this notice, or any other, from this software.
|
||||
|
||||
;;; walk.cljs - generic tree walker with replacement
|
||||
|
||||
;; by Stuart Sierra
|
||||
;; Jul5 17, 2011
|
||||
|
||||
;; CHANGE LOG:
|
||||
;;
|
||||
;; * July 17, 2011: Port to ClojureScript
|
||||
;;
|
||||
;; * December 15, 2008: replaced 'walk' with 'prewalk' & 'postwalk'
|
||||
;;
|
||||
;; * December 9, 2008: first version
|
||||
|
||||
|
||||
(ns
|
||||
^{:author "Stuart Sierra",
|
||||
:doc "This file defines a generic tree walker for Clojure data
|
||||
structures. It takes any data structure (list, vector, map, set,
|
||||
seq), calls a function on every element, and uses the return value
|
||||
of the function in place of the original. This makes it fairly
|
||||
easy to write recursive search-and-replace functions, as shown in
|
||||
the examples.
|
||||
|
||||
Note: \"walk\" supports all Clojure data structures EXCEPT maps
|
||||
created with sorted-map-by. There is no (obvious) way to retrieve
|
||||
the sorting function."}
|
||||
clojure.walk)
|
||||
|
||||
(defn walk
|
||||
"Traverses form, an arbitrary data structure. inner and outer are
|
||||
functions. Applies inner to each element of form, building up a
|
||||
data structure of the same type, then applies outer to the result.
|
||||
Recognizes all Clojure data structures. Consumes seqs as with doall."
|
||||
|
||||
{:added "1.1"}
|
||||
[inner outer form]
|
||||
(cond
|
||||
(list? form) (outer (apply list (map inner form)))
|
||||
(map-entry? form)
|
||||
(outer (MapEntry. (inner (key form)) (inner (val form)) nil))
|
||||
(seq? form) (outer (doall (map inner form)))
|
||||
(record? form) (outer (reduce (fn [r x] (conj r (inner x))) form form))
|
||||
(coll? form) (outer (into (empty form) (map inner form)))
|
||||
:else (outer form)))
|
||||
|
||||
(defn postwalk
|
||||
"Performs a depth-first, post-order traversal of form. Calls f on
|
||||
each sub-form, uses f's return value in place of the original.
|
||||
Recognizes all Clojure data structures. Consumes seqs as with doall."
|
||||
{:added "1.1"}
|
||||
[f form]
|
||||
(walk (partial postwalk f) f form))
|
||||
|
||||
(defn prewalk
|
||||
"Like postwalk, but does pre-order traversal."
|
||||
{:added "1.1"}
|
||||
[f form]
|
||||
(walk (partial prewalk f) identity (f form)))
|
||||
|
||||
(defn keywordize-keys
|
||||
"Recursively transforms all map keys from strings to keywords."
|
||||
{:added "1.1"}
|
||||
[m]
|
||||
(let [f (fn [[k v]] (if (string? k) [(keyword k) v] [k v]))]
|
||||
;; only apply to maps
|
||||
(postwalk (fn [x] (if (map? x) (into {} (map f x)) x)) m)))
|
||||
|
||||
(defn stringify-keys
|
||||
"Recursively transforms all map keys from keywords to strings."
|
||||
{:added "1.1"}
|
||||
[m]
|
||||
(let [f (fn [[k v]] (if (keyword? k) [(name k) v] [k v]))]
|
||||
;; only apply to maps
|
||||
(postwalk (fn [x] (if (map? x) (into {} (map f x)) x)) m)))
|
||||
|
||||
(defn prewalk-replace
|
||||
"Recursively transforms form by replacing keys in smap with their
|
||||
values. Like clojure/replace but works on any data structure. Does
|
||||
replacement at the root of the tree first."
|
||||
{:added "1.1"}
|
||||
[smap form]
|
||||
(prewalk (fn [x] (if (contains? smap x) (smap x) x)) form))
|
||||
|
||||
(defn postwalk-replace
|
||||
"Recursively transforms form by replacing keys in smap with their
|
||||
values. Like clojure/replace but works on any data structure. Does
|
||||
replacement at the leaves of the tree first."
|
||||
{:added "1.1"}
|
||||
[smap form]
|
||||
(postwalk (fn [x] (if (contains? smap x) (smap x) x)) form))
|
||||
1
js/compiled/out/clojure/walk.cljs.cache.json
Normal file
1
js/compiled/out/clojure/walk.cljs.cache.json
Normal file
File diff suppressed because one or more lines are too long
127
js/compiled/out/clojure/walk.js
Normal file
127
js/compiled/out/clojure/walk.js
Normal file
|
|
@ -0,0 +1,127 @@
|
|||
// Compiled by ClojureScript 1.10.520 {}
|
||||
goog.provide('clojure.walk');
|
||||
goog.require('cljs.core');
|
||||
/**
|
||||
* Traverses form, an arbitrary data structure. inner and outer are
|
||||
* functions. Applies inner to each element of form, building up a
|
||||
* data structure of the same type, then applies outer to the result.
|
||||
* Recognizes all Clojure data structures. Consumes seqs as with doall.
|
||||
*/
|
||||
clojure.walk.walk = (function clojure$walk$walk(inner,outer,form){
|
||||
if(cljs.core.list_QMARK_.call(null,form)){
|
||||
return outer.call(null,cljs.core.apply.call(null,cljs.core.list,cljs.core.map.call(null,inner,form)));
|
||||
} else {
|
||||
if(cljs.core.map_entry_QMARK_.call(null,form)){
|
||||
return outer.call(null,(new cljs.core.MapEntry(inner.call(null,cljs.core.key.call(null,form)),inner.call(null,cljs.core.val.call(null,form)),null)));
|
||||
} else {
|
||||
if(cljs.core.seq_QMARK_.call(null,form)){
|
||||
return outer.call(null,cljs.core.doall.call(null,cljs.core.map.call(null,inner,form)));
|
||||
} else {
|
||||
if(cljs.core.record_QMARK_.call(null,form)){
|
||||
return outer.call(null,cljs.core.reduce.call(null,(function (r,x){
|
||||
return cljs.core.conj.call(null,r,inner.call(null,x));
|
||||
}),form,form));
|
||||
} else {
|
||||
if(cljs.core.coll_QMARK_.call(null,form)){
|
||||
return outer.call(null,cljs.core.into.call(null,cljs.core.empty.call(null,form),cljs.core.map.call(null,inner,form)));
|
||||
} else {
|
||||
return outer.call(null,form);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
/**
|
||||
* Performs a depth-first, post-order traversal of form. Calls f on
|
||||
* each sub-form, uses f's return value in place of the original.
|
||||
* Recognizes all Clojure data structures. Consumes seqs as with doall.
|
||||
*/
|
||||
clojure.walk.postwalk = (function clojure$walk$postwalk(f,form){
|
||||
return clojure.walk.walk.call(null,cljs.core.partial.call(null,clojure.walk.postwalk,f),f,form);
|
||||
});
|
||||
/**
|
||||
* Like postwalk, but does pre-order traversal.
|
||||
*/
|
||||
clojure.walk.prewalk = (function clojure$walk$prewalk(f,form){
|
||||
return clojure.walk.walk.call(null,cljs.core.partial.call(null,clojure.walk.prewalk,f),cljs.core.identity,f.call(null,form));
|
||||
});
|
||||
/**
|
||||
* Recursively transforms all map keys from strings to keywords.
|
||||
*/
|
||||
clojure.walk.keywordize_keys = (function clojure$walk$keywordize_keys(m){
|
||||
var f = (function (p__27750){
|
||||
var vec__27751 = p__27750;
|
||||
var k = cljs.core.nth.call(null,vec__27751,(0),null);
|
||||
var v = cljs.core.nth.call(null,vec__27751,(1),null);
|
||||
if(typeof k === 'string'){
|
||||
return new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [cljs.core.keyword.call(null,k),v], null);
|
||||
} else {
|
||||
return new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [k,v], null);
|
||||
}
|
||||
});
|
||||
return clojure.walk.postwalk.call(null,((function (f){
|
||||
return (function (x){
|
||||
if(cljs.core.map_QMARK_.call(null,x)){
|
||||
return cljs.core.into.call(null,cljs.core.PersistentArrayMap.EMPTY,cljs.core.map.call(null,f,x));
|
||||
} else {
|
||||
return x;
|
||||
}
|
||||
});})(f))
|
||||
,m);
|
||||
});
|
||||
/**
|
||||
* Recursively transforms all map keys from keywords to strings.
|
||||
*/
|
||||
clojure.walk.stringify_keys = (function clojure$walk$stringify_keys(m){
|
||||
var f = (function (p__27754){
|
||||
var vec__27755 = p__27754;
|
||||
var k = cljs.core.nth.call(null,vec__27755,(0),null);
|
||||
var v = cljs.core.nth.call(null,vec__27755,(1),null);
|
||||
if((k instanceof cljs.core.Keyword)){
|
||||
return new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [cljs.core.name.call(null,k),v], null);
|
||||
} else {
|
||||
return new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [k,v], null);
|
||||
}
|
||||
});
|
||||
return clojure.walk.postwalk.call(null,((function (f){
|
||||
return (function (x){
|
||||
if(cljs.core.map_QMARK_.call(null,x)){
|
||||
return cljs.core.into.call(null,cljs.core.PersistentArrayMap.EMPTY,cljs.core.map.call(null,f,x));
|
||||
} else {
|
||||
return x;
|
||||
}
|
||||
});})(f))
|
||||
,m);
|
||||
});
|
||||
/**
|
||||
* Recursively transforms form by replacing keys in smap with their
|
||||
* values. Like clojure/replace but works on any data structure. Does
|
||||
* replacement at the root of the tree first.
|
||||
*/
|
||||
clojure.walk.prewalk_replace = (function clojure$walk$prewalk_replace(smap,form){
|
||||
return clojure.walk.prewalk.call(null,(function (x){
|
||||
if(cljs.core.contains_QMARK_.call(null,smap,x)){
|
||||
return smap.call(null,x);
|
||||
} else {
|
||||
return x;
|
||||
}
|
||||
}),form);
|
||||
});
|
||||
/**
|
||||
* Recursively transforms form by replacing keys in smap with their
|
||||
* values. Like clojure/replace but works on any data structure. Does
|
||||
* replacement at the leaves of the tree first.
|
||||
*/
|
||||
clojure.walk.postwalk_replace = (function clojure$walk$postwalk_replace(smap,form){
|
||||
return clojure.walk.postwalk.call(null,(function (x){
|
||||
if(cljs.core.contains_QMARK_.call(null,smap,x)){
|
||||
return smap.call(null,x);
|
||||
} else {
|
||||
return x;
|
||||
}
|
||||
}),form);
|
||||
});
|
||||
|
||||
//# sourceMappingURL=walk.js.map?rel=1582812680495
|
||||
1
js/compiled/out/clojure/walk.js.map
Normal file
1
js/compiled/out/clojure/walk.js.map
Normal file
|
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"\/home\/simon\/workspace\/geocsv-lite\/js\/compiled\/out\/clojure\/walk.js","sources":["walk.cljs?rel=1582812680496"],"lineCount":127,"mappings":";AAsBA;;AAcA;;;;;;oBAAA,pBAAMA,gDAOHC,MAAMC,MAAMC;AAPf,AAQE,GACE,AAACC,gCAAMD;AAAW,OAACD,gBAAM,AAACG,0BAAMC,eAAK,AAACC,wBAAIN,MAAME;;AADlD,GAEE,AAACK,qCAAWL;AACZ,OAACD,gBAAM,KAAAO,iHAAA,9FAAW,AAACR,gBAAM,AAACS,wBAAIP,OAAO,AAACF,gBAAM,AAACU,wBAAIR;;AAHnD,GAIE,AAACS,+BAAKT;AAAY,OAACD,gBAAM,AAACW,0BAAM,AAACN,wBAAIN,MAAME;;AAJ7C,GAKE,AAACW,kCAAQX;AAAS,OAACD,gBAAM,AAACa,2BAAO,WAAKC,EAAEC;AAAP,AAAU,OAACC,yBAAKF,EAAE,AAACf,gBAAMgB;GAAKd,KAAKA;;AALtE,GAME,AAACgB,gCAAMhB;AAAW,OAACD,gBAAM,AAACkB,yBAAK,AAACC,0BAAMlB,MAAM,AAACI,wBAAIN,MAAME;;AANzD,AAOoB,OAACD,gBAAMC;;;;;;;;AAE7B;;;;;wBAAA,xBAAMmB,wDAKHC,EAAEpB;AALL,AAME,OAACH,4BAAK,AAACwB,4BAAQF,sBAASC,GAAGA,EAAEpB;;AAE\/B;;;uBAAA,vBAAMsB,sDAGHF,EAAEpB;AAHL,AAIE,OAACH,4BAAK,AAACwB,4BAAQC,qBAAQF,GAAGG,mBAAS,AAACH,YAAEpB;;AAExC;;;+BAAA,\/BAAMwB,sEAGHC;AAHH,AAIE,IAAML,IAAE,WAAAM;AAAA,AAAA,IAAAC,aAAAD;QAAA,AAAAE,wBAAAD,WAAA,IAAA,3CAAME;QAAN,AAAAD,wBAAAD,WAAA,IAAA,3CAAQG;AAAR,AAAY,GAAI,OAASD;AAAb,0FAAiB,AAACE,4BAAQF,GAAGC;;AAA7B,0FAAiCD,EAAEC;;;AAAvD,AAEE,OAACX,gCAAS;kBAAKL;AAAL,AAAQ,GAAI,AAACkB,+BAAKlB;AAAG,gCAAA,zBAACG,4DAAQ,AAACb,wBAAIgB,EAAEN;;AAAIA;;;CAAIW;;AAE3D;;;8BAAA,9BAAMQ,oEAGHR;AAHH,AAIE,IAAML,IAAE,WAAAc;AAAA,AAAA,IAAAC,aAAAD;QAAA,AAAAN,wBAAAO,WAAA,IAAA,3CAAMN;QAAN,AAAAD,wBAAAO,WAAA,IAAA,3CAAQL;AAAR,AAAY,GAAI,cAAAM,bAAUP;AAAd,0FAAkB,AAACQ,yBAAKR,GAAGC;;AAA3B,0FAA+BD,EAAEC;;;AAArD,AAEE,OAACX,gCAAS;kBAAKL;AAAL,AAAQ,GAAI,AAACkB,+BAAKlB;AAAG,gCAAA,zBAACG,4DAAQ,AAACb,wBAAIgB,EAAEN;;AAAIA;;;CAAIW;;AAE3D;;;;;+BAAA,\/BAAMa,sEAKHC,KAAKvC;AALR,AAME,OAACsB,+BAAQ,WAAKR;AAAL,AAAQ,GAAI,AAAC0B,oCAAUD,KAAKzB;AAAG,OAACyB,eAAKzB;;AAAGA;;GAAId;;AAEvD;;;;;gCAAA,hCAAMyC,wEAKHF,KAAKvC;AALR,AAME,OAACmB,gCAAS,WAAKL;AAAL,AAAQ,GAAI,AAAC0B,oCAAUD,KAAKzB;AAAG,OAACyB,eAAKzB;;AAAGA;;GAAId","names":["clojure.walk\/walk","inner","outer","form","cljs.core\/list?","cljs.core\/apply","cljs.core\/list","cljs.core\/map","cljs.core\/map-entry?","cljs.core\/MapEntry","cljs.core\/key","cljs.core\/val","cljs.core\/seq?","cljs.core\/doall","cljs.core\/record?","cljs.core\/reduce","r","x","cljs.core\/conj","cljs.core\/coll?","cljs.core\/into","cljs.core\/empty","clojure.walk\/postwalk","f","cljs.core\/partial","clojure.walk\/prewalk","cljs.core\/identity","clojure.walk\/keywordize-keys","m","p__27750","vec__27751","cljs.core\/nth","k","v","cljs.core\/keyword","cljs.core\/map?","clojure.walk\/stringify-keys","p__27754","vec__27755","cljs.core\/Keyword","cljs.core\/name","clojure.walk\/prewalk-replace","smap","cljs.core\/contains?","clojure.walk\/postwalk-replace"]}
|
||||
Loading…
Add table
Add a link
Reference in a new issue