Liking cljdoc? Tell your friends :D

clj-foundation.data

Convert data between various forms; provide useful guard functions. For example:

  • any? - Return coll if any element in coll satisfies predicate
  • replace-nil - If value is not nil, return it, otherwise return replacement
  • keywordize - Turn string or named value into an idiomatic Clojure :keyword
  • ->SNAKE_CASE - Turn string or named value into a string in SNAKE_CASE form
  • Various functions for parsing and processing XML
Convert data between various forms; provide useful guard functions.  For example:
* any? - Return coll if any element in coll satisfies predicate
* replace-nil - If value is not nil, return it, otherwise return replacement
* keywordize - Turn string or named value into an idiomatic Clojure :keyword
* ->SNAKE_CASE - Turn string or named value into a string in SNAKE_CASE form
* Various functions for parsing and processing XML
raw docstring

->uppercase-with-spacesclj

(->uppercase-with-spaces value)

Inputs: [value :- (types s/Str Named)] Returns: s/Str

Convert - or _ to ' ' and captialize string.

Inputs: [value :- (types s/Str Named)]
Returns: s/Str

Convert - or _ to ' ' and captialize string.
sourceraw docstring

any?clj

(any? predicate coll)

Returns coll if any element in coll satisfies predicate.

Returns coll if any element in coll satisfies predicate.
sourceraw docstring

constant-seqclj

(constant-seq c)

Return an infinite lazy seq of cs

Return an infinite lazy seq of cs
sourceraw docstring

dasherizeclj

(dasherize match value)

Replace all instance of match with '-' in value.

Replace all instance of match with '-' in value.
sourceraw docstring

extract-root-xml-elementclj

(extract-root-xml-element root-element xml)

Extract root xml element from the given XML document.

Extract root xml element from the given XML document.
sourceraw docstring

getterclj

(getter property-name)

Inputs: [property-name :- s/Str] Returns: s/Str

Inputs: [property-name :- s/Str]
Returns: s/Str
sourceraw docstring

identity->nilclj

(identity->nil value)
(identity->nil value identity-p)

Inputs: ([value :- s/Any identity-p :- (=> s/Bool [s/Any])] [value :- s/Any]) Returns: s/Any

Synopsis: (identity->nil []) --> nil (identity->nil "") --> nil (identity->nil 1 #{1}) --> nil ; e.g.: Under multiplication (identity->nil "none" #{"nil" "none" " "}) --> nil

If value is empty (for its type's natural definition of empty), returns nil. Otherwise returns value.

  • Non-numeric values are empty iff (empty? value).
  • Numbers default to zero as their identity value.
  • The identity predicate may optionally be overridden in the second parameter.
Inputs: ([value :- s/Any identity-p :- (=> s/Bool [s/Any])] [value :- s/Any])
Returns: s/Any

Synopsis:
   (identity->nil [])                                  --> nil
   (identity->nil "")                                --> nil
   (identity->nil 1 #{1})                              --> nil   ; e.g.: Under multiplication
   (identity->nil "none" #{"nil" "none" " "})  --> nil

If value is empty (for its type's natural definition of empty), returns nil.  Otherwise returns
value.

* Non-numeric values are empty iff (empty? value).
* Numbers default to zero as their identity value.
* The identity predicate may optionally be overridden in the second parameter.
sourceraw docstring

keywordizeclj

(keywordize name)

Return dasherized keyword from camelCase underscore_names, namespaced/names, etc. See the unit tests for the complete set of supported cases.

Ex. camelCase -> :camel-case some_name -> :some-name customer.firstName -> :customer.first-name

Return dasherized keyword from camelCase underscore_names, namespaced/names, etc.
See the unit tests for the complete set of supported cases.

Ex. camelCase          -> :camel-case
    some_name          -> :some-name
    customer.firstName -> :customer.first-name
sourceraw docstring

nothing->identityclj

(nothing->identity identity-value value)

Inputs: [identity-value :- s/Any value :- s/Any] Returns: s/Any

Takes nil or Nothing to the specified identity value for the type and computation in context, otherwise returns value. An identity value can be applied to a value of the given type under the operation in context without affecting the result. For example 0 is the identity value for rational numbers under addition. The empty string is the identity value for strings under concatination.

Note that Nothing is already an identity value for maps and seqs. This function is only useful for types where the Nothing type is ill-behaved (e.g.: Strings, Numbers, ...) for a given operation.

Another name for this concept is the monadic zero for the type/operation.

Inputs: [identity-value :- s/Any value :- s/Any]
Returns: s/Any

Takes nil or Nothing to the specified identity value for the type and computation in context,
otherwise returns value.  An identity value can be applied to a value of the given type under the
operation in context without affecting the result.  For example 0 is the identity value for rational
numbers under addition.  The empty string is the identity value for strings under concatination.

Note that Nothing is already an identity value for maps and seqs.  This function is only useful
for types where the Nothing type is ill-behaved (e.g.: Strings, Numbers, ...) for a given operation.

Another name for this concept is the monadic zero for the type/operation.
sourceraw docstring

parse-xmlclj

(parse-xml xml)

Parse XML from a String

Parse XML from a String
sourceraw docstring

remove-header-rowclj

(remove-header-row data)

When processing CSV, frequently we want to throw out the header row.

When processing CSV, frequently we want to throw out the header row.
sourceraw docstring

replace-ifclj

(replace-if value predicate)
(replace-if value predicate replacement)

Inputs: ([value :- s/Any predicate :- (=> s/Any [s/Any])] [value :- s/Any predicate :- (=> s/Any [s/Any]) replacement :- s/Any]) Returns: s/Any

In the binary form, replace value with the result of running predicate against value if that result is truthy. In the terniary form, replace value with replacement if the result of running predicate against value is truthy.

An idiomatic way to use this function is to pass a set of disallowed values as predicate, and a replacement value as replacement.

Inputs: ([value :- s/Any predicate :- (=> s/Any [s/Any])] [value :- s/Any predicate :- (=> s/Any [s/Any]) replacement :- s/Any])
Returns: s/Any

In the binary form, replace value with the result of running predicate against value
 if that result is truthy.  In the terniary form, replace value with replacement if
 the result of running predicate against value is truthy.

 An idiomatic way to use this function is to pass a set of disallowed values as
 predicate, and a replacement value as replacement.
sourceraw docstring

replace-nilclj

(replace-nil maybe-nil replacement)

Inputs: [maybe-nil :- s/Any replacement :- s/Any] Returns: s/Any

Accepts a value that cannot be nil; if it is not nil it returns it, else it returns its replacement.

Inputs: [maybe-nil :- s/Any replacement :- s/Any]
Returns: s/Any

Accepts a value that cannot be nil; if it is not nil it returns it, else it
returns its replacement.
sourceraw docstring

set-map-entriesclj

(set-map-entries m entries new-value)

Inputs: [m :- #:s{Keyword s/Any} entries :- [s/Keyword] new-value :- s/Any] Returns: #:s{Any s/Any}

Returns a new copy of m where for all [k v] => if k is in entries, v is set to new-value.

Inputs: [m :- #:s{Keyword s/Any} entries :- [s/Keyword] new-value :- s/Any]
Returns: #:s{Any s/Any}

Returns a new copy of m where for all [k v] => if k is in entries, v is set to new-value.
sourceraw docstring

something-orclj

(something-or value f)

Inputs: [value :- s/Any f :- (=> s/Any [s/Any])] Returns: s/Any

If value is not Nothing return value, else run f and return its result.

Inputs: [value :- s/Any f :- (=> s/Any [s/Any])]
Returns: s/Any

If value is not Nothing return value, else run f and return its result.
sourceraw docstring

string->keywordclj

(string->keyword name)
(string->keyword name naming-exceptions)

Inputs: ([name :- s/Str naming-exceptions :- #{s/Str}] [name :- s/Str]) Returns: s/Keyword

Convert string name to a keyword respecting naming-exceptions. Ex. some_name -> :some-name

Inputs: ([name :- s/Str naming-exceptions :- #{s/Str}] [name :- s/Str])
Returns: s/Keyword

Convert string name to a keyword respecting naming-exceptions.
 Ex. some_name -> :some-name
sourceraw docstring

string-list->keywordsclj

(string-list->keywords list)
(string-list->keywords list naming-exceptions)

Convert a list of strings to a list of keywords

Convert a list of strings to a list of keywords
sourceraw docstring

undasherizeclj

(undasherize replacement value)

Inputs: [replacement :- s/Str value :- (types s/Str Named)] Returns: s/Str

Replace all instances of '-' or '_' with replacement

Inputs: [replacement :- s/Str value :- (types s/Str Named)]
Returns: s/Str

Replace all instances of '-' or '_' with replacement
sourceraw docstring

value-orclj

(value-or value f)

Inputs: [value :- s/Any f :- (=> s/Any [s/Any])] Returns: s/Any

If value is nil or an instance of Nothing, run f and return its result. Else, return value.

Inputs: [value :- s/Any f :- (=> s/Any [s/Any])]
Returns: s/Any

If value is nil or an instance of Nothing, run f and return its result.  Else, return value.
sourceraw docstring

xml-element->kv-pairclj

(xml-element->kv-pair element)

Return key-value pair where key is the tag name, and value is content of the xml element.

Return key-value pair where key is the tag name,
and value is content of the xml element.
sourceraw docstring

xml-elements->mapclj

(xml-elements->map elements)

Return a map of key-value pairs from the given xml elements.

Return a map of key-value pairs from the given xml elements.
sourceraw docstring

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

× close