(first async-seq)Returns async expression yielding first element, or nil if empty.
Convenience wrapper around anext.
Returns async expression yielding first element, or nil if empty. Convenience wrapper around anext.
(for seq-exprs body-expr)Async sequence comprehension. Takes a vector of one or more binding-form/collection-expr pairs, each followed by zero or more modifiers, and yields a lazy async sequence of evaluations of expr.
Collections are iterated in a nested fashion, rightmost fastest, and nested coll-exprs can refer to bindings created in prior binding-forms. Supported modifiers are: :let [binding-form expr ...], :while test, :when test.
Unlike clojure.core/for, allows await in body and returns PAsyncSeq. Use namespace aliasing to distinguish from standard for: (require '[is.simm.partial-cps.sequence :as seq]) (seq/for [x xs] (await (fetch x)))
Examples: (for [x [1 2 3]] (await (fetch x)))
(for [x (range 10) :when (even? x) :let [y (* x 2)]] (await (process y)))
(for [x [1 2 3] y [:a :b]] [x y]) ; Cross-product: [1 :a] [1 :b] [2 :a] ...
Async sequence comprehension. Takes a vector of one or more
binding-form/collection-expr pairs, each followed by zero or more
modifiers, and yields a lazy async sequence of evaluations of expr.
Collections are iterated in a nested fashion, rightmost fastest,
and nested coll-exprs can refer to bindings created in prior
binding-forms. Supported modifiers are: :let [binding-form expr ...],
:while test, :when test.
Unlike clojure.core/for, allows await in body and returns PAsyncSeq.
Use namespace aliasing to distinguish from standard for:
(require '[is.simm.partial-cps.sequence :as seq])
(seq/for [x xs] (await (fetch x)))
Examples:
(for [x [1 2 3]]
(await (fetch x)))
(for [x (range 10)
:when (even? x)
:let [y (* x 2)]]
(await (process y)))
(for [x [1 2 3]
y [:a :b]]
[x y]) ; Cross-product: [1 :a] [1 :b] [2 :a] ...(make-generator-seq generator-fn initial-state)Create async sequence from generator function and initial state.
The generator-fn should take state and return async expression yielding [value next-state] or nil.
The sequence is purely functional - each anext returns a new sequence with advanced state, leaving the original unchanged. This allows safe sharing and multiple independent consumers.
Create async sequence from generator function and initial state. The generator-fn should take state and return async expression yielding [value next-state] or nil. The sequence is purely functional - each anext returns a new sequence with advanced state, leaving the original unchanged. This allows safe sharing and multiple independent consumers.
Protocol for asynchronous sequences.
Async sequences are lazy, pull-based sequences of values that may require asynchronous computation. Unlike regular Clojure seqs, each step returns an async expression that must be awaited.
Protocol for asynchronous sequences. Async sequences are lazy, pull-based sequences of values that may require asynchronous computation. Unlike regular Clojure seqs, each step returns an async expression that must be awaited.
(anext this)Returns async expression yielding [value rest-seq] or nil if sequence is exhausted.
Example: (async (when-let [[value rest-seq] (await (anext aseq))] (process value) (recur rest-seq)))
Returns async expression yielding [value rest-seq] or nil if sequence is exhausted.
Example:
(async
(when-let [[value rest-seq] (await (anext aseq))]
(process value)
(recur rest-seq)))Protocol for managing shared transducer state
Protocol for managing shared transducer state
(-ensure-buffer! this idx)Ensure buffer has element at idx
Ensure buffer has element at idx
(rest async-seq)Returns async expression yielding rest of sequence after first element.
Returns nil if sequence is exhausted.
Convenience wrapper around anext.
Returns async expression yielding rest of sequence after first element. Returns nil if sequence is exhausted. Convenience wrapper around anext.
(sequence xform source-seq)Transform an AsyncSeq with a transducer, returning a new lazy AsyncSeq. The transducer is applied lazily as elements are consumed.
Example: (sequence (map inc) async-seq) (sequence (filter even?) async-seq) (sequence (partition-all 3) async-seq)
Transform an AsyncSeq with a transducer, returning a new lazy AsyncSeq. The transducer is applied lazily as elements are consumed. Example: (sequence (map inc) async-seq) (sequence (filter even?) async-seq) (sequence (partition-all 3) async-seq)
(transduce xform f init async-seq)Transduce over an AsyncSeq eagerly, returning a Promise of the final result.
Transduce over an AsyncSeq eagerly, returning a Promise of the final result.
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |