ComfyUI Node

_.mixin

Give the Underscore Object Your Own Functions

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

_.mixin is the underscore-family node for the one percent. It lets you bolt your own Python functions onto the shared underscore object, so a custom callback you define once can be called by name inside a chain of other _.* nodes. In a world where every other node in this pack is "pick the list apart," this one is "install your own extension."

What it does

The idea comes straight from underscore.js: _.mixin(obj) copies every function in a dictionary onto the _ object itself, and - because these nodes chain - onto the wrapper instances too. Feed it {"double": lambda x: x * 2} and suddenly a chained node could invoke double like any built-in method.

The interface is about as minimal as it gets:

  • obj - a dictionary of {name: callable} pairs

Output: the same dictionary you put in, echoed back as ANY so you can keep the graph flowing.

The practical catch

There's a gap between the idea and the graph: ComfyUI nodes pass data, not functions. To feed mixin a dictionary of real Python callables, you need an upstream node that produces callables - a lambda/function node from another pack, or the pack's own underscore function export node, which hands out the raw _ factory. If you're not already comfortable passing functions around your graph, this node will mostly sit there looking mysterious, because there's no widget that can express "here's a function."

The mechanism itself is solid: the bundled port does setattr on the underscore class for each key, then re-exports the statics. I verified a simple case - register a myFn, and it's available as an attribute on the factory afterward. The friction is purely in getting a callable into the graph in the first place.

When you'd actually reach for it

If you're building a reusable template workflow where the same custom iteratee keeps showing up in _.map, _.filter or _.reduce nodes, defining it once via mixin and then referencing it by name beats duplicating the logic. That's the legit use. For everyone else - and honestly, that's most people - this is a node you can safely ignore; the family's bread-and-butter list and dict operations don't need it.

Installing

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

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

Restart. No models, no extra pip dependencies for the underscore nodes - the underscore.js port ships in the repo. The pack's heavier requirements.txt entries serve its other nodes, not this family.

The bottom line

_.mixin is a real, working extension hook buried in a utility pack. If you never touch it, you're not missing anything. If you're the kind of person who builds custom function nodes anyway, it's a tidy way to make those functions first-class citizens of the underscore chain.

Categoryovum/underscore

Inputs (1)

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

Outputs (1)

NameTypeDescription
**