ComfyUI Node

_.each

Visit every element, and pass the list through

By sfinktah·Created about a year ago·Updated 10 months ago· 7
_.each
  • list_or_dict
  • *

_.each is Underscore's iteration workhorse: it walks a list or dict and calls a function on every element. The author's description is the library's canonical one: "Iterates over a list of elements, yielding each in turn to an iteratee function… Each invocation of iteratee is called with three arguments: (element, index, list). If list is a JavaScript object, iteratee's arguments will be (value, key, list). Returns the list for chaining."

That last phrase is the part that matters for how this node behaves in the graph: _.each returns the collection, unchanged. It's for side effects, not transformations - if you want a new list out, that's _.map or _.filter.

How it works

Generated wrapper around underscore3, the bundled Python port of Underscore.js. Like several of its siblings, though, this generated node exposes only the primary list_or_dict input - the iteratee function socket isn't wired up in this build. Without an iteratee connected, the node's practical behavior is to walk the collection and hand back the same list so the chain can continue. Its real value in the family is as a chain-compatible pass-through: you keep the _.CHAIN alive and the semantics stay honest about "everything got visited."

If you need the actual per-element work, the _.map/_.filter nodes with full iteratee controls are the ones that do something visible. For side-effect-style iteration you'd normally need to get a Python callable into the chain, which is where the pack's PY_FUNC exports come in.

Inputs and output

  • list_or_dict (any type) - the collection to iterate. Accepts a _.CHAIN to continue a chain.
  • Output: * (any type) - the collection itself, returned for chaining.

No widgets.

Installing it

Part of sfinktah/comfy-ovum ("comfy-ovum"):

  • ComfyUI Manager: search "comfy-ovum", install, restart.
  • Manual: cd ComfyUI/custom_nodes && git clone https://github.com/sfinktah/comfy-ovum, restart.

No model downloads; light dependencies; underscore3 bundled in the repo.

The honest take

_.each is the node you reach for when you want the "iterate everything" intent in a chain without changing the data - and in this build, that's basically all it does, because the iteratee isn't exposed. It's a good illustration of why the author flags the whole underscore suite as a work-in-progress: the method is faithful, the wiring isn't complete. Keep it in mind as a chain-pass-through, reach for _.map and _.filter when you actually want results, and don't build a production pipeline on it until the wrappers mature.

Categoryovum/underscore

Inputs (1)

NameTypeDefaultDescription
list_or_dictopt*Primary input object (expected collection). You can still pass any JSON-serializable value. Also accepts _.CHAIN to continue chaining.

Outputs (1)

NameTypeDescription
**