mirror of
https://github.com/penpot/penpot.git
synced 2026-09-11 14:39:35 +00:00
✨ Add the ability to retrieve a set of keys from map schemas
This commit is contained in:
parent
3d61924162
commit
5c225a51ce
@ -5,7 +5,7 @@
|
|||||||
;; Copyright (c) KALEIDOS INC
|
;; Copyright (c) KALEIDOS INC
|
||||||
|
|
||||||
(ns app.common.schema
|
(ns app.common.schema
|
||||||
(:refer-clojure :exclude [deref merge parse-uuid parse-long parse-double parse-boolean type])
|
(:refer-clojure :exclude [deref merge parse-uuid parse-long parse-double parse-boolean type keys])
|
||||||
#?(:cljs (:require-macros [app.common.schema :refer [ignoring]]))
|
#?(:cljs (:require-macros [app.common.schema :refer [ignoring]]))
|
||||||
(:require
|
(:require
|
||||||
[app.common.data :as d]
|
[app.common.data :as d]
|
||||||
@ -118,6 +118,21 @@
|
|||||||
[& transformers]
|
[& transformers]
|
||||||
(apply mt/transformer transformers))
|
(apply mt/transformer transformers))
|
||||||
|
|
||||||
|
(defn entries
|
||||||
|
"Get map entires of a map schema"
|
||||||
|
[schema]
|
||||||
|
(m/entries schema default-options))
|
||||||
|
|
||||||
|
(def ^:private xf:map-key
|
||||||
|
(map key))
|
||||||
|
|
||||||
|
(defn keys
|
||||||
|
"Given a map schema, return all keys as set"
|
||||||
|
[schema]
|
||||||
|
(->> (entries schema)
|
||||||
|
(into #{} xf:map-key)))
|
||||||
|
|
||||||
|
|
||||||
;; (defn key-transformer
|
;; (defn key-transformer
|
||||||
;; [& {:as opts}]
|
;; [& {:as opts}]
|
||||||
;; (mt/key-transformer opts))
|
;; (mt/key-transformer opts))
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user