Nodes/comfy-ovum/_.reject
ComfyUI Node

_.reject

Keep Everything That Fails

By sfinktah·Created about a year ago·Updated 10 months ago· 7
_.reject
  • list_or_dict
  • predicate
  • LIST
predicate_json

_.reject is the filter that keeps the losers. You give it a list and a truth test; it returns a new list of every element that fails the test. Where filter says "keep what matches," _.reject says "drop what matches" - the same operation with the logic inverted. It's the clean way to say "remove the bad ones" without writing a negated predicate.

How it works

It applies your predicate to every element and keeps the ones where it returns falsy. The output is a LIST; the input collection is never mutated - you get a new list, so the source stays intact for other branches. I verified the basics: reject the odd numbers from [1,2,3,4,5] and you get [2,4].

Inputs:

  • list_or_dict - the collection (or a _.CHAIN)
  • predicate - an ANY socket for a function, key string, or object shorthand
  • predicate_json - the multiline text fallback, used when the socket isn't connected

The shorthand makes it usable

The predicate doesn't have to be a function - this is where the family earns its keep. Feed it a property name and it becomes a property accessor; feed it an object and it becomes a matcher. I tested reject("a") on a list of dicts and it correctly dropped every element whose a field was truthy. So "drop everything with disabled: true" is a JSON object in the widget, not a function node. That's the difference between this node being practical and it being a curiosity.

Two things to keep in mind:

  • The predicate is called with one argument per element (the value), so a function fed via the socket should take at least one arg
  • The shorthand strings are property names - reject("flag") drops items where flag is truthy

Reject vs. the alternatives

Rejecting is the natural way to strip an out-group from a list - "remove the failures before the next stage," "drop everything past the cutoff." If you'd rather split the list into both groups at once, _.partition does that in a single pass. If you're working on a dict and want to drop whole keys, _.omit is the sibling for that. Reject is for when you want the survivors of a "not this" test, as a plain list.

Installing

Part of comfy-ovum. ComfyUI Manager → search comfy-ovum → Install, or:

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

Restart ComfyUI. No models, no extra pip packages for the underscore nodes - the port is bundled in the repo.

The bottom line

Filter's negated twin, and a genuinely useful one thanks to the key-string and matcher shorthand. Keep the predicate one-argument and it'll behave.

Categoryovum/underscore

Inputs (3)

NameTypeDefaultDescription
list_or_dictopt*Primary input object (expected collection). You can still pass any JSON-serializable value. Also accepts _.CHAIN to continue chaining.
predicateopt*predicate: ANY input to override widget. Accepts function, key string, or object shorthand.
predicate_jsonoptSTRINGpredicate_json: JSON or key selector. Used when 'predicate' input is not connected.

Outputs (1)

NameTypeDescription
LISTLIST