Nodes/comfy-ovum/_.iteratee
ComfyUI Node

_.iteratee

The quiet engine behind map, filter and max — a callback factory in node form.

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

Every time you use _.map, _.filter, or _.max you're leaning on an iteratee - the function that gets applied to each element. _.iteratee is the factory that turns your shorthand into that function. It's not flashy, but it's the piece that makes the whole family's shorthand work, and once you get it, half the underscore nodes in sfinktah/comfy-ovum click into place.

What it is

One node in the ovum/underscore family, wrapping the iteratee method of underscore3, a Python port of Underscore.js. It mirrors Underscore's shorthand rules exactly:

  • Nothing → an identity function, lambda x: x.
  • A callable → passed through as-is.
  • A dict → returns a matcher predicate: does the input contain all these key:value pairs?
  • Anything else → returns a property accessor for that key or path.

That last one is why _.map with an iteratee of "name" plucks the name field out of every dict in a list. It's also why _.max with an iteratee of "score" finds the highest-scoring item. The iteratee node just makes the raw mechanism visible and reusable.

How it works

One optional input, obj (type *) - the value that defines the callback - and one output, typed * (ANY). At runtime that output is a Python function. Feed it a plain value and you get the callback out; feed it a _.CHAIN and you get a chain back to keep going. The natural move is to wire its output into another underscore node's iteratee socket, or combine it with the pack's underscore function node if you want the raw _ factory itself.

The one thing to watch

A function is a live Python object, and live Python objects do not survive a save/reload as JSON. Build your iteratees in a live session; if you reload a workflow and a function socket comes up empty, rebuild it. The durable path for cross-session work is the JSON key selector (iteratee_json) on the map/max/filter nodes, which stores as text and rebuilds on load. And don't expect the status preview to show you much - it renders the type and a short repr, not the function body.

Installing comfy-ovum

ComfyUI Manager: search for comfy-ovum, install, restart. Or manually:

cd ComfyUI/custom_nodes
git clone https://github.com/sfinktah/comfy-ovum
pip install -r comfy-ovum/requirements.txt

Restart and you're set. No model downloads, no CUDA - pure-Python utilities. The family caveat applies here more than most: the README calls these nodes a work in progress, and the iteratee machinery is exactly the part that feels experimental. It works, but treat it as such.

Categoryovum/underscore

Inputs (1)

NameTypeDefaultDescription
objopt*Primary input object. Also accepts _.CHAIN to continue chaining.

Outputs (1)

NameTypeDescription
**