Nodes/comfy-ovum/_.include
ComfyUI Node

_.include

The 'is this value in this list?' check that feeds your if/else

By sfinktah·Created about a year ago·Updated 10 months ago· 7
_.include
  • obj
  • value
  • BOOLEAN
fromIndex0

_.include answers one question: is this value present in this collection? It returns a real BOOLEAN, which is exactly what you need to drive a conditional branch in your workflow - the difference between "run the detailer" and "skip it."

It's Underscore.js's _.contains (aliased to _.include), ported to Python. If you're used to writing if "foo" in my_list: in Python, this is that, as a node.

How it works

Under the hood it's a membership check wrapped in the pack's underscore3 library. The interesting detail is that it handles both lists and dicts:

  • For a list (or tuple/string), it checks whether your value is an element.
  • For a dict, it checks against the dict's values, not its keys.

There's also a fromIndex option that skips ahead before searching - handy when you know the match, if it exists, will be late in a long list and you want to skip the early section. Negative indexes count from the end, mirroring Python slicing behavior.

The inputs that matter

  • obj - the primary input, typed *. It's the list (or dict, or chain) you're searching. Also accepts a _.CHAIN to continue a chain.
  • value - what you're looking for. Typed *, so it can be a string, number, or nested object.
  • fromIndex - an INT (default 0). Start the search at this position. Blank means start at the beginning.

Output is a single BOOLEAN - clean, typed, and ready to plug straight into an IfElse or branch node. Unlike Python's ValueError-raising .index(), this one can't crash your run on a missing value; it just returns False.

Where you'd actually use it

The genuinely useful pattern: build a list of allowed tags, seeds, or model names somewhere upstream, then use _.include to test whether a runtime value is in it. Combined with the pack's _.indexBy or a few list builders, you can write readable conditionals like "apply the lora only if the checkpoint is in my approved list" without a single line of script.

It also composes with the chain system: _.chain_.include_.value if you're mid-pipeline and want to test the current state.

Installing

Part of comfy-ovum (MIT). ComfyUI Manager → search comfy-ovum → install → restart, or:

cd ComfyUI/custom_nodes
git clone https://github.com/sfinktah/comfy-ovum

The underscore nodes themselves need nothing extra - they use the underscore3 port bundled in the repo. Installing the pack does pull its requirements.txt (including pymediainfo, which can need the system libmediainfo on Linux), but that's pack-wide, not specific to this node.

Gotchas

The pack's author labels the whole underscore family as work-in-progress and not production-ready, and that caveat lands here too: fromIndex only applies when the input is a list/tuple/string, and dict searches ignore it entirely. For most "is it in there?" checks - the common case - _.include is solid and won't surprise you.

Categoryovum/underscore

Inputs (3)

NameTypeDefaultDescription
objopt*Primary input object. Also accepts _.CHAIN to continue chaining.
valueopt*value: JSON allowed for arrays/objects where applicable.
fromIndexoptINT0fromIndex (int)

Outputs (1)

NameTypeDescription
BOOLEANBOOLEAN