Liking cljdoc? Tell your friends :D

fogus.adverbs

Various functions that modify other functions that are not (currently) available in clojure.core.

Various functions that modify other functions that are not
(currently) available in clojure.core.
raw docstring

apply-layeringclj

(apply-layering aspects f args)

Layers a collection of aspects with a base function and immediately invokes with the provided arguments. Supports early termination via (reduced val).

Layers a collection of aspects with a base function and immediately invokes
with the provided arguments. Supports early termination via (reduced val).
raw docstring

cps->fnclj

(cps->fn f callback)

Takes a function f that takes a callback and returns a new fn that runs synchronously. If callback throws then the exception will be propagated outward.

Takes a function f that takes a callback and returns a new fn
that runs synchronously. If callback throws then the exception
will be propagated outward.
raw docstring

kwargifyclj

(kwargify f)

Takes a function that expects a map and returns a function that accepts keyword arguments on its behalf.

Takes a function that expects a map and returns a function that
accepts keyword arguments on its behalf.
raw docstring

layerclj

(layer f aspects)

Layers multiple aspects around a base function by repeatedly nesting them. Aspects are applied left-to-right, with earlier aspects applying closer to f.

An aspect is a higher-order function with signature (fn [next-fn & args] ...) that can intercept, transform, or short-circuit execution before/after calling next-fn. This provides the full range of before/after/around "advice" patterns:

  • (fn [next-fn arg] (next-fn (before arg)))
  • (fn [next-fn arg] (after (next-fn arg)))
  • (fn [next-fn arg] (let [r (next-fn (before arg))] (after r)))

Each aspect receives the nested result of all previous aspects as its first argument. Aspects can return (reduced val) to short-circuit remaining layers, preventing inner aspects from executing.

Layers multiple aspects around a base function by repeatedly nesting them.
Aspects are applied left-to-right, with earlier aspects applying closer
to f.

An aspect is a higher-order function with signature (fn [next-fn & args] ...)
that can intercept, transform, or short-circuit execution before/after calling next-fn.
This provides the full range of before/after/around "advice" patterns:

- (fn [next-fn arg] (next-fn (before arg)))
- (fn [next-fn arg] (after (next-fn arg)))
- (fn [next-fn arg] (let [r (next-fn (before arg))] (after r)))

Each aspect receives the nested result of all previous aspects as its first
argument. Aspects can return (reduced val) to short-circuit remaining layers,
preventing inner aspects from executing.
raw docstring

nestclj

(nest inner outer)

Nests one function inside of another. The outer function receives the inner function as its first argument, creating a nested execution context where the outer potentially controls how/when the inner is invoked.

Supports early termination: if outer returns (reduced val), execution halts.

Nests one function inside of another. The outer function receives the inner
function as its first argument, creating a nested execution context where
the outer potentially controls how/when the inner is invoked.

Supports early termination: if outer returns (reduced val), execution halts.
raw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
Move to previous article
Move to next article
Ctrl+/Jump to the search field
× close