Liking cljdoc? Tell your friends :D

lambdacd.stepresults.merge

Functions that can help merge several step results into one

Functions that can help merge several step results into one

merge-step-results

(merge-step-results step-results merge-two-results-fn)

Takes a list of step results (e.g. whats in the :outputs key of a nesting step-result) and merges it into one step result with the help of a function that can merge two step results:

> (merge-step-results [{:status :success}
                       {:foo :bar}
                       {:foo :baz}]
                      merge)
{:status :success
 :foo    :baz}
Takes a list of step results (e.g. whats in the `:outputs` key of a nesting step-result)
and merges it into one step result with the help of a function that can merge two step results:

```clojure
> (merge-step-results [{:status :success}
                       {:foo :bar}
                       {:foo :baz}]
                      merge)
{:status :success
 :foo    :baz}
```
sourceraw docstring

merge-two-step-results

(merge-two-step-results
  a
  b
  &
  {:keys [resolvers],
   :or {resolvers [merge-resolvers/status-resolver
                   merge-resolvers/merge-nested-maps-resolver
                   merge-resolvers/combine-to-list-resolver
                   merge-resolvers/second-wins-resolver]}})

Takes two step results and merges them:

> (merge-two-step-results {:status :failure
                           :m      {:a :b}
                           :s      "a"}
                          {:status :success
                           :m      {:b :c}
                           :s      "b"})
{:status :failure
 :m      {:a :b
          :b :c}
 :s      "b"}

Optionally, merge-two-step-results takes a list of functions to customize how to resolve conflicts. Resolver-functions take the key where the conflict occurred and the two values and a merged result or nil if they can't merge the conflict. If one resolver can't resolve a conflict, the next one in the list is tried.

Takes two step results and merges them:

```clojure
> (merge-two-step-results {:status :failure
                           :m      {:a :b}
                           :s      "a"}
                          {:status :success
                           :m      {:b :c}
                           :s      "b"})
{:status :failure
 :m      {:a :b
          :b :c}
 :s      "b"}
```

Optionally, `merge-two-step-results` takes a list of functions to customize how to resolve conflicts.
Resolver-functions take the key where the conflict occurred and the two values and a merged result or nil if they can't merge the conflict.
If one resolver can't resolve a conflict, the next one in the list is tried.
sourceraw docstring

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

× close