Back

key-comparator (clj)

(source)

function

(key-comparator graph)
Create a key comparator from the dependency graph of a configuration map. The comparator is deterministic; it will always result in the same key order.

Examples

integrant
(ns integrant.core-test
  (:require #?(:clj  [clojure.test :refer [are deftest is testing]]
               :cljs [cljs.test :refer-macros [are deftest is testing]])
            [integrant.core :as ig]
            [weavejester.dependency :as dep]))

(deftest key-comparator-test
  (let [graph (ig/dependency-graph {::a (ig/ref ::ppp) ::p 1, ::b 2})]
    (is (= (sort (ig/key-comparator graph) [::b ::a ::p])
           [::p ::a ::b]))))