Attempt to host (large) JavaScript
This commit is contained in:
289
resources/public/js/optimized/clojure/string.cljs
Normal file
289
resources/public/js/optimized/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))
|
||||
478
resources/public/js/optimized/clojure/string.js
Normal file
478
resources/public/js/optimized/clojure/string.js
Normal file
@@ -0,0 +1,478 @@
|
||||
// Compiled by ClojureScript 1.10.520 {:static-fns true, :optimize-constants true}
|
||||
goog.provide('clojure.string');
|
||||
goog.require('cljs.core');
|
||||
goog.require('cljs.core.constants');
|
||||
goog.require('goog.string');
|
||||
goog.require('goog.string.StringBuffer');
|
||||
clojure.string.seq_reverse = (function clojure$string$seq_reverse(coll){
|
||||
return cljs.core.reduce.cljs$core$IFn$_invoke$arity$3(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__5537 = "g";
|
||||
var G__5537__$1 = (cljs.core.truth_(re.ignoreCase)?[G__5537,"i"].join(''):G__5537);
|
||||
var G__5537__$2 = (cljs.core.truth_(re.multiline)?[G__5537__$1,"m"].join(''):G__5537__$1);
|
||||
if(cljs.core.truth_(re.unicode)){
|
||||
return [G__5537__$2,"u"].join('');
|
||||
} else {
|
||||
return G__5537__$2;
|
||||
}
|
||||
})()));
|
||||
return s.replace(r,replacement);
|
||||
});
|
||||
clojure.string.replace_with = (function clojure$string$replace_with(f){
|
||||
return (function() {
|
||||
var G__5540__delegate = function (args){
|
||||
var matches = cljs.core.drop_last.cljs$core$IFn$_invoke$arity$2((2),args);
|
||||
if(cljs.core._EQ_.cljs$core$IFn$_invoke$arity$2(cljs.core.count(matches),(1))){
|
||||
var G__5538 = cljs.core.first(matches);
|
||||
return (f.cljs$core$IFn$_invoke$arity$1 ? f.cljs$core$IFn$_invoke$arity$1(G__5538) : f.call(null,G__5538));
|
||||
} else {
|
||||
var G__5539 = cljs.core.vec(matches);
|
||||
return (f.cljs$core$IFn$_invoke$arity$1 ? f.cljs$core$IFn$_invoke$arity$1(G__5539) : f.call(null,G__5539));
|
||||
}
|
||||
};
|
||||
var G__5540 = function (var_args){
|
||||
var args = null;
|
||||
if (arguments.length > 0) {
|
||||
var G__5541__i = 0, G__5541__a = new Array(arguments.length - 0);
|
||||
while (G__5541__i < G__5541__a.length) {G__5541__a[G__5541__i] = arguments[G__5541__i + 0]; ++G__5541__i;}
|
||||
args = new cljs.core.IndexedSeq(G__5541__a,0,null);
|
||||
}
|
||||
return G__5540__delegate.call(this,args);};
|
||||
G__5540.cljs$lang$maxFixedArity = 0;
|
||||
G__5540.cljs$lang$applyTo = (function (arglist__5542){
|
||||
var args = cljs.core.seq(arglist__5542);
|
||||
return G__5540__delegate(args);
|
||||
});
|
||||
G__5540.cljs$core$IFn$_invoke$arity$variadic = G__5540__delegate;
|
||||
return G__5540;
|
||||
})()
|
||||
;
|
||||
});
|
||||
/**
|
||||
* 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(s,match,replacement);
|
||||
} else {
|
||||
return clojure.string.replace_all(s,match,clojure.string.replace_with(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__5544 = arguments.length;
|
||||
switch (G__5544) {
|
||||
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(coll);
|
||||
while(true){
|
||||
if((!((coll__$1 == null)))){
|
||||
var G__5546 = sb.append(cljs.core.str.cljs$core$IFn$_invoke$arity$1(cljs.core.first(coll__$1)));
|
||||
var G__5547 = cljs.core.next(coll__$1);
|
||||
sb = G__5546;
|
||||
coll__$1 = G__5547;
|
||||
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(coll);
|
||||
while(true){
|
||||
if((!((coll__$1 == null)))){
|
||||
sb.append(cljs.core.str.cljs$core$IFn$_invoke$arity$1(cljs.core.first(coll__$1)));
|
||||
|
||||
var coll__$2 = cljs.core.next(coll__$1);
|
||||
if((coll__$2 == null)){
|
||||
} else {
|
||||
sb.append(separator);
|
||||
}
|
||||
|
||||
var G__5548 = sb;
|
||||
var G__5549 = coll__$2;
|
||||
sb = G__5548;
|
||||
coll__$1 = G__5549;
|
||||
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(v__$1))){
|
||||
var G__5550 = cljs.core.pop(v__$1);
|
||||
v__$1 = G__5550;
|
||||
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(v))))){
|
||||
return clojure.string.pop_last_while_empty(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(s)))))){
|
||||
return cljs.core.conj.cljs$core$IFn$_invoke$arity$2(cljs.core.vec(cljs.core.cons("",cljs.core.map.cljs$core$IFn$_invoke$arity$2(cljs.core.str,cljs.core.seq(s)))),"");
|
||||
} else {
|
||||
var pred__5551 = cljs.core._EQ__EQ_;
|
||||
var expr__5552 = limit;
|
||||
if(cljs.core.truth_((pred__5551.cljs$core$IFn$_invoke$arity$2 ? pred__5551.cljs$core$IFn$_invoke$arity$2((1),expr__5552) : pred__5551.call(null,(1),expr__5552)))){
|
||||
return (new cljs.core.PersistentVector(null,1,(5),cljs.core.PersistentVector.EMPTY_NODE,[s],null));
|
||||
} else {
|
||||
if(cljs.core.truth_((pred__5551.cljs$core$IFn$_invoke$arity$2 ? pred__5551.cljs$core$IFn$_invoke$arity$2((2),expr__5552) : pred__5551.call(null,(2),expr__5552)))){
|
||||
return (new cljs.core.PersistentVector(null,2,(5),cljs.core.PersistentVector.EMPTY_NODE,["",s],null));
|
||||
} else {
|
||||
var c = (limit - (2));
|
||||
return cljs.core.conj.cljs$core$IFn$_invoke$arity$2(cljs.core.vec(cljs.core.cons("",cljs.core.subvec.cljs$core$IFn$_invoke$arity$3(cljs.core.vec(cljs.core.map.cljs$core$IFn$_invoke$arity$2(cljs.core.str,cljs.core.seq(s))),(0),c))),cljs.core.subs.cljs$core$IFn$_invoke$arity$2(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__5555 = arguments.length;
|
||||
switch (G__5555) {
|
||||
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.cljs$core$IFn$_invoke$arity$3(s,re,(0));
|
||||
});
|
||||
|
||||
clojure.string.split.cljs$core$IFn$_invoke$arity$3 = (function (s,re,limit){
|
||||
return clojure.string.discard_trailing_if_needed(limit,((("/(?:)/" === cljs.core.str.cljs$core$IFn$_invoke$arity$1(re)))?clojure.string.split_with_empty_regex(s,limit):(((limit < (1)))?cljs.core.vec(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.cljs$core$IFn$_invoke$arity$2(parts,s__$1);
|
||||
} else {
|
||||
var m = cljs.core.re_find(re,s__$1);
|
||||
if((!((m == null)))){
|
||||
var index = s__$1.indexOf(m);
|
||||
var G__5557 = s__$1.substring((index + cljs.core.count(m)));
|
||||
var G__5558 = (limit__$1 - (1));
|
||||
var G__5559 = cljs.core.conj.cljs$core$IFn$_invoke$arity$2(parts,s__$1.substring((0),index));
|
||||
s__$1 = G__5557;
|
||||
limit__$1 = G__5558;
|
||||
parts = G__5559;
|
||||
continue;
|
||||
} else {
|
||||
return cljs.core.conj.cljs$core$IFn$_invoke$arity$2(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.cljs$core$IFn$_invoke$arity$2(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.cljs$core$IFn$_invoke$arity$2(s,(index - (1)));
|
||||
if(((("\n" === ch)) || (("\r" === ch)))){
|
||||
var G__5560 = (index - (1));
|
||||
index = G__5560;
|
||||
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.cljs$core$IFn$_invoke$arity$2(cmap,ch);
|
||||
if((!((replacement == null)))){
|
||||
buffer.append(cljs.core.str.cljs$core$IFn$_invoke$arity$1(replacement));
|
||||
} else {
|
||||
buffer.append(ch);
|
||||
}
|
||||
|
||||
var G__5561 = (index + (1));
|
||||
index = G__5561;
|
||||
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__5563 = arguments.length;
|
||||
switch (G__5563) {
|
||||
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__5566 = arguments.length;
|
||||
switch (G__5566) {
|
||||
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);
|
||||
});
|
||||
Reference in New Issue
Block a user