Liking cljdoc? Tell your friends :D

re-com.util


assoc-in-if-emptycljs

(assoc-in-if-empty m ks v)

Only assoc-in if no value exists at ks

Only assoc-in if no value exists at ks
sourceraw docstring

deep-mergecljs

(deep-merge & vals)

Recursively merges maps. If vals are not maps, the last value wins.

Recursively merges maps. If vals are not maps, the last value wins.
sourceraw docstring

deref-or-valuecljs

(deref-or-value val-or-atom)

Takes a value or an atom If it's a value, returns it If it's a Reagent object that supports IDeref, returns the value inside it by derefing

Takes a value or an atom
If it's a value, returns it
If it's a Reagent object that supports IDeref, returns the value inside it by derefing
sourceraw docstring

deref-or-value-peekcljs

(deref-or-value-peek val-or-atom)

Takes a value or an atom If it's a value, returns it If it's a Reagent object that supports IDeref, returns the value inside it, but WITHOUT derefing

The arg validation code uses this, since calling deref-or-value adds this arg to the watched ratom list for the component in question, which in turn can cause different rendering behaviour between dev (where we validate) and prod (where we don't).

This was experienced in popover-content-wrapper with the position-injected atom which was not derefed there, however the dev-only validation caused it to be derefed, modifying its render behaviour and causing mayhem and madness for the developer.

See below that different Reagent types have different ways of retrieving the value without causing capture, although in the case of Track, we just deref it as there is no peek or state, so hopefully this won't cause issues (surely this is used very rarely).

Takes a value or an atom
If it's a value, returns it
If it's a Reagent object that supports IDeref, returns the value inside it, but WITHOUT derefing

The arg validation code uses this, since calling deref-or-value adds this arg to the watched ratom list for the component
in question, which in turn can cause different rendering behaviour between dev (where we validate) and prod (where we don't).

This was experienced in popover-content-wrapper with the position-injected atom which was not derefed there, however
the dev-only validation caused it to be derefed, modifying its render behaviour and causing mayhem and madness for the developer.

See below that different Reagent types have different ways of retrieving the value without causing capture, although in the case of
Track, we just deref it as there is no peek or state, so hopefully this won't cause issues (surely this is used very rarely).
sourceraw docstring

enumeratecljs

(enumerate coll)

(for [[index item first? last?] (enumerate coll)] ...)

(for [[index item first? last?] (enumerate coll)] ...)
sourceraw docstring

fmapcljs

(fmap f m)

Takes a function 'f' amd a map 'm'. Applies 'f' to each value in 'm' and returns. (fmap inc {:a 4 :b 2}) => {:a 5 :b 3}

Takes a function 'f' amd a map 'm'.  Applies 'f' to each value in 'm' and returns.
(fmap  inc  {:a 4  :b 2})   =>   {:a 5  :b 3}
sourceraw docstring

get-element-by-idcljs

(get-element-by-id id)
source

insert-nthcljs

(insert-nth vect index item)
source

item-for-idcljs

(item-for-id id v & {:keys [id-fn] :or {id-fn :id}})

Takes a vector of maps 'v'. Returns the first item in 'v' whose id-fn (default :id) matches 'id'. Returns nil if id not found

Takes a vector of maps 'v'. Returns the first item in 'v' whose id-fn (default :id) matches 'id'.
Returns nil if id not found
sourceraw docstring

now->utccljs

(now->utc)

Return a goog.date.UtcDateTime based on local date/time.

Return a goog.date.UtcDateTime based on local date/time.
sourceraw docstring

pad-zerocljs

(pad-zero s len)

Left pad a string 's' with '0', until 's' has length 'len'. Return 's' unchanged, if it is already len or greater

Left pad a string 's' with '0', until 's' has length 'len'. Return 's' unchanged, if it is already len or greater
sourceraw docstring

pad-zero-numbercljs

(pad-zero-number num len)

return 'num' as a string of 'len' characters, left padding with '0' as necessary

return 'num' as a string of 'len' characters, left padding with '0' as necessary
sourceraw docstring

pluralizecljs

(pluralize num singular & [plural])

Return a pluralized phrase, appending an s to the singular form if no plural is provided. For example: (pluralize 5 "month") => "5 months" (pluralize 1 "month") => "1 month" (pluralize 1 "radius" "radii") => "1 radius" (pluralize 9 "radius" "radii") => "9 radii" From https://github.com/flatland/useful/blob/194950/src/flatland/useful/string.clj#L25-L33

Return a pluralized phrase, appending an s to the singular form if no plural is provided.
For example:
   (pluralize 5 "month") => "5 months"
   (pluralize 1 "month") => "1 month"
   (pluralize 1 "radius" "radii") => "1 radius"
   (pluralize 9 "radius" "radii") => "9 radii"
   From https://github.com/flatland/useful/blob/194950/src/flatland/useful/string.clj#L25-L33
sourceraw docstring

position-for-idcljs

(position-for-id id v & {:keys [id-fn] :or {id-fn :id}})

Takes a vector of maps 'v'. Returns the position of the first item in 'v' whose id-fn (default :id) matches 'id'. Returns nil if id not found

Takes a vector of maps 'v'. Returns the position of the first item in 'v' whose id-fn (default :id) matches 'id'.
Returns nil if id not found
sourceraw docstring

pxcljs

(px val & negative)

takes a number (and optional :negative keyword to indicate a negative value) and returns that number as a string with 'px' at the end

takes a number (and optional :negative keyword to indicate a negative value) and returns that number as a string with 'px' at the end
sourceraw docstring

px-ncljs

(px-n & vals)

takes n numbers (could also be strings) and converts them to a space separated px string e.g. (px-n 10 2 30 4) => '10px 2px 30px 4px' for use in :padding, :margin etc. Most useful when the args are calculations e.g. (px-n top-margin (inc h-width) (- top-margin 5) (dec h-width)) Note: Doesn't support :negative like px above but it will work with negative numbers

takes n numbers (could also be strings) and converts them to a space separated px string
e.g. (px-n 10 2 30 4) => '10px 2px 30px 4px' for use in :padding, :margin etc.
Most useful when the args are calculations
e.g. (px-n top-margin (inc h-width) (- top-margin 5) (dec h-width))
Note: Doesn't support :negative like px above but it will work with negative numbers
sourceraw docstring

remove-id-itemcljs

(remove-id-item id v & {:keys [id-fn] :or {id-fn :id}})

Takes a vector of maps 'v', each of which has an id-fn (default :id) key. Return v where item matching 'id' is excluded

Takes a vector of maps 'v', each of which has an id-fn (default :id) key.
Return v where item matching 'id' is excluded
sourceraw docstring

remove-nthcljs

(remove-nth v n)

Removes the item at position n from a vector v, returning a shrunk vector

Removes the item at position n from a vector v, returning a shrunk vector
sourceraw docstring

sum-scroll-offsetscljs

(sum-scroll-offsets node)

Given a DOM node, I traverse through all ascendant nodes (until I reach body), summing any scrollLeft and scrollTop values and return these sums in a map

Given a DOM node, I traverse through all ascendant nodes (until I reach body), summing any scrollLeft and scrollTop values
and return these sums in a map
sourceraw docstring

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

× close