2017-06-20 65 views

回答

1

你可以使用:

(ns app.core 
    (:require [cljs.reader :as reader])) 

(def fs (js/require "fs")) 

(defn read-edn [path f] 
    (.readFile fs path "utf8" (fn [err data] (f (reader/read-string data))))) 

(defn process [coll]) 

(read-edn "/tmp/x.clj" process) 

在上面的例子中,process會收到從文件中讀取的數據結構。您需要執行process並將錯誤處理添加到read-edn