I am trying to assess whether my CLJS function declaration is idiomatic. Here is my attempt to convert a JS function into its corresponding CLJS function. (You can ignore the actual content of the function).
JavaScript function:
var dir = require('node-dir');
function jsFunc(path) {
dir.files(path, function(err, files) {
if (err) throw err;
files = files.filter(function (file) {
return file.endsWith('.dec');
});
console.log(files);
});
}
My translation into ClojureScript:
(defn cljs-func [input-path]
(let [dir (node/require "node-dir")]
(.files dir input-path (fn [err files]
(println (.filter files (fn [file] (.endsWith file ".dec")))))))