vl-data-insert.utils

append-if

(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]}

ensure-vec

(ensure-vec v)

Ensures that v is a vector.

Example:

(ensure-vec nil) ;!
;; nil
(ensure-vec 1)
;; [1]
(ensure-vec [1])
;; [1]

path->kw-vec

(path->kw-vec s)

Turns the path into a vector of keywords.

Example:

(path->kw-vec "a.b.c")
;; [:a :b :c]

replace-if

(replace-if m k v)

Replaces value of key in struct if vis not nil.

Example:

(replace-if {:Type "a"} :Type "b")
;; {:Type "b"}

vector-if

(vector-if m kw)

Makes the value v behind the keyword kw a vector if v is not nil.