Liking cljdoc? Tell your friends :D

vl-data-insert.utils


append-ifclj

(append-if m k v)

Appends v to the value of k. If k does not exist in m, k [v] is assoced. If k does exist in m, v is conjed.

Example:

(append-if {:Value [1 2 3]} :Value 4)
;; {:Value [1 2 3 4]}
Appends `v` to the value of `k`. If `k` does not exist in `m`,
`k [v]` is assoced.  If `k` does exist in `m`, `v` is conjed.

Example:
```clojure
(append-if {:Value [1 2 3]} :Value 4)
;; {:Value [1 2 3 4]}
```
sourceraw docstring

check-kwclj

(check-kw m kw)
source

ensure-mapclj

(ensure-map x v)

Ensures xto be a map. If x is a value a map is constucted from the last keyword and the value.

Example:

(ensure-map 10 [:a :b :c])
;; =>
;; [{:c 10} [:a :b]]
(ensure-map {:d 10} [:a :b :c])
;; =>
;; [{:d 10} [:a :b :c]]
Ensures `x`to be a map. If `x` is a value a map is constucted from
the last keyword and the value.

Example:
```clojure
(ensure-map 10 [:a :b :c])
;; =>
;; [{:c 10} [:a :b]]
(ensure-map {:d 10} [:a :b :c])
;; =>
;; [{:d 10} [:a :b :c]]
```
sourceraw docstring

ensure-vecclj

(ensure-vec v)

Ensures that v is a vector even if v is nil.

Example:

;; important:
(ensure-vec nil) 
;;=> [nil]
;; ^^ because:
(concat [1 2] nil)
;; => (1 2) ; but we need:
(concat [1 2] [nil])
;; => (1 2 nil)
;; to ensure that all
;; Value-vectors keep the same length
(ensure-vec 1)
;; [1]
(ensure-vec [1])
;; [1]
Ensures that `v` is a vector even if `v` is `nil`.

Example:
```clojure
;; important:
(ensure-vec nil) 
;;=> [nil]
;; ^^ because:
(concat [1 2] nil)
;; => (1 2) ; but we need:
(concat [1 2] [nil])
;; => (1 2 nil)
;; to ensure that all
;; Value-vectors keep the same length
(ensure-vec 1)
;; [1]
(ensure-vec [1])
;; [1]
```
sourceraw docstring

path->kw-vecclj

(path->kw-vec s)

Turns the path into a vector of keywords.

Example:

(path->kw-vec "a.b.c")
;; [:a :b :c]
Turns the path into a vector of keywords.

Example:
```clojure
(path->kw-vec "a.b.c")
;; [:a :b :c]
```
sourceraw docstring

replace-ifclj

(replace-if m k v)

Replaces value of key in struct if vis not nil.

Example:

(replace-if {:Type "a"} :Type "b")
;; {:Type "b"}
Replaces `v`alue of `k`ey in struct if `v`is not `nil`.

Example:
```clojure
(replace-if {:Type "a"} :Type "b")
;; {:Type "b"}
```
sourceraw docstring

vector-ifclj

(vector-if m kw)

Makes the value v of keyword kw a vector also if v is nil.

Makes the value `v` of keyword `kw` a vector also if `v` is  `nil`.
sourceraw docstring

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

× close