Nodes/comfy-ovum/_.isEmpty
ComfyUI Node

_.isEmpty

One check for empty strings, lists, dicts, and nothing at all

By sfinktah·Created about a year ago·Updated 10 months ago· 7
_.isEmpty
  • py_dict
  • BOOLEAN

ComfyUI workflows leak empties everywhere. A prompt builder hands you an empty string. A dynamic list node spits out a zero-length list. An optional input never got connected, so it arrives as None. _.isEmpty from the sfinktah/comfy-ovum pack answers all three with one node: is this thing empty? It's the pragmatic sibling of _.isNone - None is empty, but so is "", [], and {}, which is usually the question you actually care about when you're deciding whether to skip a branch.

This lives in the pack's ovum/underscore family, which wraps underscore3, a Python port of Underscore.js. The whole family is generated automatically from that library's methods, and the author's README is blunt about it: work in progress, "an absolute disaster to use in production," not recommended. That's aimed mostly at the exotic method nodes. _.isEmpty is one of the few worth fishing out of the wreckage.

What it does

The Python port's isEmpty is, honestly, a bit of a franken-check:

  • None → empty.
  • Strings → empty if strip() gives you "" (so whitespace-only text counts as empty - handy when a text widget is full of stray newlines).
  • Dicts → empty if there are zero keys.
  • Anything else → empty if len() returns 0.

That last branch is the catch: it calls len() on whatever's left. Feed it a bare number - _.isEmpty(42) - and you get a TypeError instead of a boolean. The JavaScript docs say numbers and booleans are "always empty," but this Python port never implemented that special case. It just crashes. So treat the intended inputs as collections, strings, dicts, or None.

Like every node in the family, it accepts a plain value (and gives you a boolean back) or a _.CHAIN from the _.chain node, in which case it runs on the wrapped object and passes the chain onward.

Inputs and outputs

  • py_dict - the only input, type *, optional. Yes, it's named py_dict even though you can feed it a string or list; that's the generated input name for "object" category methods, and the tooltip says any JSON-serializable value works.
  • Output - a single BOOLEAN. Unlike most of the family, this one gets a proper typed boolean socket, so it plugs straight into IfElse, switch, and comparison nodes without a cast.

Where it fits

This pairs beautifully with the pack's own data nodes. Run a Pystructure list operation or a New Multi-type Dictionary, and check the result with _.isEmpty before fanning out - if it's empty, route to a fallback instead of crashing an index node three hops later. It's also the right tool for validating prompt text: _.isEmpty catches both genuinely blank strings and strings that are only whitespace, which a naive "is this None" check won't.

Installing it

ComfyUI Manager, search comfy-ovum, install. Or:

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

Restart after. No extra dependencies for this node - underscore3 is bundled in the repo - and Manager resolves the pack's requirements.txt for you.

Gotchas

  • Don't feed it numbers or booleans - it raises instead of returning False.
  • False, 0, and "" are not the same thing: _.isEmpty(0) crashes, _.isEmpty(False) crashes, and _.isEmpty(0.0) crashes. If you need "is this a usable number," that's a different check entirely.
  • Whitespace-only strings count as empty. Usually that's what you want; occasionally it's not (a caption that's legitimately a single space is pathological enough to ignore).
Categoryovum/underscore

Inputs (1)

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

Outputs (1)

NameTypeDescription
BOOLEANBOOLEAN