ComfyUI Node

_.times

Run a function n times — if you can supply the function

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

_.times is Underscore's "do this repeatedly" utility: give it a count n and an iteratee, and it invokes the iteratee n times - each call getting an index argument - and collects the return values into a list. times(3, i => i * 2)[0, 2, 4]. In graph form, that's "build me a list of n things."

Now the part you need before you get excited. This node is the poster child for the comfy-ovum underscore family's rough edges, and the author's README is blunt about the whole family: work in progress, "not recommended for use in workflows." The wrapper generated for _.times exposes obj (the count) and args - but the iteratee, the function that actually does the repeating work, is exactly the input that didn't get exposed. Look at the node and there's no socket or widget to hand it a callable. Without one, running it calls the iteratee as None and blows up. Which is to say: as shipped, this node is essentially unusable for the thing its name promises, unless you're feeding it a function from some other node that can produce a PY_FUNC-style value.

Inputs and output

  • obj (*) - the count n, the number of times to run. The underlying method iterates range(n).
  • args (*) - a leftover from the varargs handling; JSON allowed. Not where the iteratee goes, despite appearances.

Output is a single * carrying the list of produced values - if it ever runs.

The honest recommendation

Don't build with this one. If you want "a list of n copies of the same thing," the pack's own RepeatItem node (same repo, but in the maintained Pystructure list-utility section rather than the auto-generated underscore family) does exactly that with a sane count input and no function required. If you want "n different things," the pack's XRange node ticks through values with a cursor, and ComfyUI-LogicUtils (which this pack explicitly complements) covers the rest of the iteration space with far more discipline.

_.times is a decent illustration of why the author attached the disaster warning: it's a faithful-enough mechanical wrapper of a JavaScript API concept that doesn't map cleanly onto what a node graph can actually express. Understanding it helps you understand the family. Running it in production shouldn't be on your to-do list.

Install

# via ComfyUI Manager: search "comfy-ovum"
cd ComfyUI/custom_nodes
git clone https://github.com/sfinktah/comfy-ovum
# restart ComfyUI

No model downloads; pure Python, deps (aiohttp, pillow, numpy, requests, etc.) via Manager, underscore3 bundled in the repo.

Categoryovum/underscore

Inputs (2)

NameTypeDefaultDescription
objopt*Primary input object. Also accepts _.CHAIN to continue chaining.
argsopt*args: JSON allowed for arrays/objects where applicable. For multiple values, provide a JSON array (e.g., [1,2,3]).

Outputs (1)

NameTypeDescription
**