Liking cljdoc? Tell your friends :D

keypin.util

Common utility functions.

Common utility functions.
raw docstring

any->boolclj

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.
sourceraw docstring

any->doubleclj

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.
sourceraw docstring

any->durationclj

(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.
sourceraw docstring

any->ednclj

(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.
sourceraw docstring

any->floatclj

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.
sourceraw docstring

any->intclj

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.
sourceraw docstring

any->longclj

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.
sourceraw docstring

any->mapclj

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.
sourceraw docstring

any->nestedclj

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.
sourceraw docstring

any->time-unitclj

(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.
sourceraw docstring

any->tuplesclj

(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.
sourceraw docstring

any->varclj

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.
sourceraw docstring

any->var->derefclj

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).
sourceraw docstring

any->vecclj

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.
sourceraw docstring

any?clj

(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+.
sourceraw docstring

atom?clj

(atom? x)

Return true if argument is a Clojure atom, false otherwise.

Return true if argument is a Clojure atom, false otherwise.
sourceraw docstring

bool?clj

(bool? x)

Return true if the argument is of boolean type, false otherwise.

Return true if the argument is of boolean type, false otherwise.
sourceraw docstring

clojurize-dataclj

(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.
sourceraw docstring

clojurize-substclj

(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:

  1. Missing variables cause IllegalArgumentException to be thrown.
  2. You can escape the variable marker '$' using '$$' (interpreted as '$') to avoid substitution.
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.
sourceraw docstring

colon-tokenizerclj

source

comma-tokenizerclj

source

comp-parserclj

(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`.
sourceraw docstring

default-loggerclj

source

deref?clj

(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.
sourceraw docstring

duration?clj

(duration? x)

Return true if the argument is a duration, false otherwise.

Return true if the argument is a duration, false otherwise.
sourceraw docstring

fqvn?clj

(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.
sourceraw docstring

identity-parserclj

(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.
sourceraw docstring

make-loggerclj

(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]).
sourceraw docstring

regex->tokenizerclj

(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.
sourceraw docstring

str->anyclj

(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.
sourceraw docstring

str->boolclj

(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.
sourceraw docstring

str->collclj

(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.
sourceraw docstring

str->doubleclj

(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.
sourceraw docstring

str->durationclj

(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.
sourceraw docstring

str->ednclj

(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.
sourceraw docstring

str->floatclj

(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.
sourceraw docstring

str->fnclj

(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.
sourceraw docstring

str->intclj

(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.
sourceraw docstring

str->longclj

(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.
sourceraw docstring

str->mapclj

(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"}
sourceraw docstring

str->nestedclj

(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"]]
sourceraw docstring

str->time-unitclj

(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.
sourceraw docstring

str->tuplesclj

(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"}]
sourceraw docstring

str->varclj

(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.
sourceraw docstring

str->var->derefclj

(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.
sourceraw docstring

str->vecclj

(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"]
sourceraw docstring

symstr->anyclj

(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.
sourceraw docstring

vec?clj

(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.
sourceraw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close