Skip to content

Instantly share code, notes, and snippets.

View viebel's full-sized avatar

Yehonathan Sharvit viebel

View GitHub Profile
@viebel
viebel / spec_example.cljs
Last active April 27, 2017 01:00 — forked from bhb/spec-example.clj
Recursive spec with clojure.spec
(ns viebel.gist-57d9ebad3381e727c2f0a373e1bd4eec.raw.spec-example
(:require [cljs.spec :as s]))
(s/def ::tag (s/cat :type #{:div}
:attrs map?
:children (s/spec (s/* ::tag))))
(s/explain ::tag [:div {} [[:div {} []]]])
;; In: [2 0] val: [:div {} []] fails spec: _ at: [:children :type] predicate: #{:div}
@viebel
viebel / regex_as_a_function.cljs
Last active June 10, 2016 07:51 — forked from alandipert/reinvoke.cljs
Make a regex behave like a function
; Make a regex behave like a function
; Inspired by: http://blog.klipse.tech/clojure/2016/04/07/ifn.html
(extend-type js/RegExp
IFn
(-invoke ([this s] (re-find this s))))
(#"clojure" "clojurescript")