Common utility functions.
Common utility functions.
Like str->bool, except parsing is avoided if value is already a boolean.
Like str->bool, except parsing is avoided if value is already a boolean.
Like str->double, except parsing is avoided if value is already a double precision number.
Like str->double, except parsing is avoided if value is already a double precision number.
(any->duration the-key duration)
Like str->duration, except it accepts [long-int java.util.concurrent.TimeUnit/string/keyword] too.
Like str->duration, except it accepts [long-int java.util.concurrent.TimeUnit/string/keyword] too.
(any->edn the-key value)
(any->edn pred expectation the-key value)
Like str->edn, except parsing is avoided if value is already non-string.
Like str->edn, except parsing is avoided if value is already non-string.
Like str->float, except parsing is avoided if value is already a floating point number.
Like str->float, except parsing is avoided if value is already a floating point number.
Like str->int, except parsing is avoided if value is already an integer.
Like str->int, except parsing is avoided if value is already an integer.
Like str->long, except parsing is avoided if value is already a long integer.
Like str->long, except parsing is avoided if value is already a long integer.
Like str->map, except parsing is avoided if value is already a map.
Like str->map, except parsing is avoided if value is already a map.
Like str->nested, except parsing is avoided if value is already a vector of nested vectors.
Like str->nested, except parsing is avoided if value is already a vector of nested vectors.
(any->time-unit the-key time-unit)
Like str->time-unit, except it accepts java.util.concurrent.TimeUnit/string/keyword as time-unit.
Like str->time-unit, except it accepts java.util.concurrent.TimeUnit/string/keyword as time-unit.
(any->tuples ks the-key value)
Like str->tuples, except parsing is avoided if value is already tuples.
Like str->tuples, except parsing is avoided if value is already tuples.
Like str->var, except parsing is avoided if value is already a var.
Like str->var, except parsing is avoided if value is already a var.
Like str->var->deref, except parsing is avoided if value is already a var (which is deref'ed before returning).
Like str->var->deref, except parsing is avoided if value is already a var (which is deref'ed before returning).
Like str->vec, except parsing is avoided if value is already a vector.
Like str->vec, except parsing is avoided if value is already a vector.
(any? _)
Dummy validator. Always return true. Same as clojure.core/any? in Clojure 1.9+.
Dummy validator. Always return true. Same as clojure.core/any? in Clojure 1.9+.
(atom? x)
Return true if argument is a Clojure atom, false otherwise.
Return true if argument is a Clojure atom, false otherwise.
(bool? x)
Return true if the argument is of boolean type, false otherwise.
Return true if the argument is of boolean type, false otherwise.
(clojurize-data data)
(clojurize-data f data)
Process a data structure recursively passing each element through specified fn. Turn Java oriented data structures into Clojure equivalent.
Process a data structure recursively passing each element through specified fn. Turn Java oriented data structures into Clojure equivalent.
(clojurize-subst data)
(clojurize-subst lookup data)
Variable substitution for EDN data. Symbols and keywords starting with '$' (e.g. $foo.bar or :$foo.bar) are looked up and substituted by their respective values as follows: Variable Description Lookup as
$foo.bar Symbol variable "foo.bar" $:foo.bar Keyword variable :foo.bar :$foo.bar Keyword variable :foo.bar $$foo.bar Escaped variable -- (not substituted) :$$foo.bar Escaped variable -- (not substituted)
Note:
Variable substitution for EDN data. Symbols and keywords starting with '$' (e.g. $foo.bar or :$foo.bar) are looked up and substituted by their respective values as follows: Variable Description Lookup as -------- ----------- --------- $foo.bar Symbol variable "foo.bar" $:foo.bar Keyword variable :foo.bar :$foo.bar Keyword variable :foo.bar $$foo.bar Escaped variable -- (not substituted) :$$foo.bar Escaped variable -- (not substituted) Note: 1. Missing variables cause IllegalArgumentException to be thrown. 2. You can escape the variable marker '$' using '$$' (interpreted as '$') to avoid substitution.
(comp-parser & parsers)
Compose multiple parsers (where parser is arity-2 fn accepting key and parseable value) into one. Composition is
applied right-to-left, as in clojure.core/comp
.
Compose multiple parsers (where parser is arity-2 fn accepting key and parseable value) into one. Composition is applied right-to-left, as in `clojure.core/comp`.
(deref? pred)
Wrap a predicate such that it derefs the argument before applying the predicate.
Wrap a predicate such that it derefs the argument before applying the predicate.
(duration? x)
Return true if the argument is a duration, false otherwise.
Return true if the argument is a duration, false otherwise.
(fqvn? x)
Return true if the argument has the 'syntax' of a fully qualified var name, false otherwise.
Return true if the argument has the 'syntax' of a fully qualified var name, false otherwise.
(identity-parser the-key parseable-val)
Return the value to be parsed without doing any actual parsing.
Return the value to be parsed without doing any actual parsing.
(make-logger info-logger error-logger)
Make a logger instance from info-logger (fn [info-msg]) and error-logger (fn [error-msg]).
Make a logger instance from info-logger (fn [info-msg]) and error-logger (fn [error-msg]).
(regex->tokenizer regex)
(regex->tokenizer token-processor regex)
Given a regex, return a fn that tokenizes a text. Each token can be processed using an optional arity-1 fn, which by default trims the tokens.
Given a regex, return a fn that tokenizes a text. Each token can be processed using an optional arity-1 fn, which by default trims the tokens.
(str->any pred str-parser expected-msg)
Given a predicate fn and a string parser fn, return a parser fn that parses the value only when the predicate fn return false and the value is a string.
Given a predicate fn and a string parser fn, return a parser fn that parses the value only when the predicate fn return false and the value is a string.
(str->bool the-key x)
Given a boolean value in string form, parse and return the boolean value.
Given a boolean value in string form, parse and return the boolean value.
(str->coll entity-tokenizer entity-processor the-key text)
Given a delimited text tokenize it (using an arity-1 fn) as a collection and process it (using an arity-1 fn) to return the result.
Given a delimited text tokenize it (using an arity-1 fn) as a collection and process it (using an arity-1 fn) to return the result.
(str->double the-key x)
Given a double precision value in string form, parse and return the double precision value.
Given a double precision value in string form, parse and return the double precision value.
(str->duration the-key duration-str)
Given a duration string, parse it as a vector [long java.util.concurrent.TimeUnit] and return it.
Given a duration string, parse it as a vector [long java.util.concurrent.TimeUnit] and return it.
(str->edn the-key text)
(str->edn pred expectation the-key text)
Given a string representation of EDN, parse it as EDN and return it.
Given a string representation of EDN, parse it as EDN and return it.
(str->float the-key x)
Given a floating point value in string form, parse and return the floating point value.
Given a floating point value in string form, parse and return the floating point value.
(str->fn the-key fq-var-name)
Given a fully qualified var name (eg. 'com.example.foo/add-item'), resolve the var, deref it and return the value assuming it is a function.
Given a fully qualified var name (eg. 'com.example.foo/add-item'), resolve the var, deref it and return the value assuming it is a function.
(str->int the-key x)
Given an integer value in string form, parse and return the integer value.
Given an integer value in string form, parse and return the integer value.
(str->long the-key x)
Given a long int value in string form, parse and return the long int value.
Given a long int value in string form, parse and return the long int value.
(str->map the-key text)
(str->map pair-tokenizer kv-tokenizer the-key text)
Given a delimted text, where each token is a delimited pair text, tokenize it and return a map of tokens. By default, the pair delimiter is a comma and the key-value delimiter is a colon. Example: => (str->map :foo "a: 10, b: 20, c: 30") {"a" "10" "b" "20" "c" "30"}
Given a delimted text, where each token is a delimited pair text, tokenize it and return a map of tokens. By default, the pair delimiter is a comma and the key-value delimiter is a colon. Example: => (str->map :foo "a: 10, b: 20, c: 30") {"a" "10" "b" "20" "c" "30"}
(str->nested the-key text)
(str->nested outer-tokenizer inner-tokenizer the-key text)
Given a delimited text, where each token is again a delimited text, tokenize it and return a vector of nested vectors of tokens. By default, the outer delimiter is a comma and the inner delimiter is a colon. Example: => (str->nested :foo "joe: 30: male, sue: 35: female, max: 40: male") [["joe" "30" "male"] ["sue" "35" "female"] ["max" "40" "male"]]
Given a delimited text, where each token is again a delimited text, tokenize it and return a vector of nested vectors of tokens. By default, the outer delimiter is a comma and the inner delimiter is a colon. Example: => (str->nested :foo "joe: 30: male, sue: 35: female, max: 40: male") [["joe" "30" "male"] ["sue" "35" "female"] ["max" "40" "male"]]
(str->time-unit the-key unit-str)
Given a time unit string, resolve it as java.util.concurrent.TimeUnit instance.
Given a time unit string, resolve it as java.util.concurrent.TimeUnit instance.
(str->tuples ks the-key text)
(str->tuples outer-tokenizer inner-tokenizer ks the-key text)
Given a delimited text, where each token is again a delimited text, tokenize it and return a vector of maps. By default, the outer delimiter is a comma and the inner delimiter is a colon. Example: => (str->tuples [:name :age :gender] :foo "joe: 30: male, sue: 35: female, max: 40: male") [{:name "joe" :age "30" :gender "male"} {:name "sue" :age "35" :gender "female"} {:name "max" :age "40" :gender "male"}]
Given a delimited text, where each token is again a delimited text, tokenize it and return a vector of maps. By default, the outer delimiter is a comma and the inner delimiter is a colon. Example: => (str->tuples [:name :age :gender] :foo "joe: 30: male, sue: 35: female, max: 40: male") [{:name "joe" :age "30" :gender "male"} {:name "sue" :age "35" :gender "female"} {:name "max" :age "40" :gender "male"}]
(str->var the-key fq-var-name)
Given a fully qualified var name (eg. 'com.example.foo/bar'), resolve the var and return it.
Given a fully qualified var name (eg. 'com.example.foo/bar'), resolve the var and return it.
(str->var->deref the-key fq-var-name)
Given a fully qualified var name (eg. 'com.example.foo/bar'), resolve the var, deref it and return the value.
Given a fully qualified var name (eg. 'com.example.foo/bar'), resolve the var, deref it and return the value.
(str->vec the-key text)
(str->vec tokenizer the-key text)
Given a delimited text, tokenize it and return a vector of tokens. By default, the delimiter is a comma. Example: => (str->vec :foo "a, b, c") ["a" "b" "c"]
Given a delimited text, tokenize it and return a vector of tokens. By default, the delimiter is a comma. Example: => (str->vec :foo "a, b, c") ["a" "b" "c"]
(symstr->any pred str-parser expected-msg)
Given a predicate fn and a string parser fn, return a parser fn that parses the value only when the predicate fn return false and the value is a string or symbol.
Given a predicate fn and a string parser fn, return a parser fn that parses the value only when the predicate fn return false and the value is a string or symbol.
(vec? pred)
Wrap a predicate to verify the argument as a vector before applying the predicate to all elements in it.
Wrap a predicate to verify the argument as a vector before applying the predicate to all elements in it.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close