Skip to main content

eval-str

functionv1.7

cljs.js/eval-str

(eval-str [state source cb] [state source name cb] [state source name opts cb])
Evalute ClojureScript source given as a string. The parameters: state (atom) the compiler state source (string) the ClojureScript source name (symbol or string) optional, the name of the source - used as key in :source-maps opts (map) compilation options. :eval - eval function to invoke, see *eval-fn* :load - library resolution function, see *load-fn* :source-map - set to true to generate inline source map information :cache-source - optional, a function to run side-effects with the compilation result prior to actual evalution. This function takes two arguments, the first is the eval map, the source will be under :source. The second argument is a callback of one argument. If an error occurs an :error key should be supplied. :def-emits-var - sets whether def (and derived) forms return either a Var (if set to true) or the def init value (if false). Default is false. :checked-arrays - if :warn or :error, checks inferred types and values passed to aget/aset. Logs for incorrect values if :warn, throws if :error. Defaults to false. :static-fns - employ static dispatch to specific function arities in emitted JavaScript, as opposed to making use of the `call` construct. Defaults to false. :fn-invoke-direct - if `true`, does not generate `.call(null...)` calls for unknown functions, but instead direct invokes via `f(a0,a1...)`. Defaults to `false`. :target - use `:nodejs` if targeting Node.js. Takes no other options at the moment. :ns - optional, the namespace in which to evaluate the source. :verbose - optional, emit details from compiler activity. Defaults to false. :context - optional, sets the context for the source. Possible values are `:expr`, `:statement` and `:return`. Defaults to `:statement`. cb (function) callback, will be invoked with a map. If succesful the map will contain a :value key with the result of evaluation and :ns the current namespace. If unsuccessful will contain a :error key with an ex-info instance describing the cause of failure.

No examples yet. Be the first to add one!