Liking cljdoc? Tell your friends :D

total-reader

Clojars Project Build Status

[total-reader "1.0.0"]

A clojure reader which can read keywords with namespace aliases.

It should be able to read all idiomatic clojure files.

Built on top of org.clojure/tools.reader.

Extracted from https://github.com/jonase/kibit, which introduced this functionality to fix https://github.com/jonase/kibit/issues/14

Why use this library?

If you want to be able to read a file containing namespace aliased keywords, map namespace syntax or namespaced map binding destructuring.

Example file containing these features:

(ns keyword-namespace-test
  (:require [clojure.string :as string]))

;; namespace aliased keyword
::string/test

;; map namespace syntax using an alias
(let [m #::string{:key1 "val"
                  :key2 "other val"}
       ;; namespaced map binding destructuring using an alias
      {::string/keys [key1 key2]} m]
  [key1 key2])

Usage

(require 'total-reader.core :as reader)

(reader/read-file
 (-> "path/to/file.clj"
     io/reader
     LineNumberingPushbackReader.)
 'user)

License

Copyright © 2018 Timo Freiberg

Distributed under the Eclipse Public License either version 1.0 or (at your option) any later version.

Can you improve this documentation?Edit on GitHub

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

× close