Nodes/comfy-ovum/_.constant
ComfyUI Node

_.constant

A factory for “always return this exact value”

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

_.constant is one of the stranger entries in the underscore family, and its author description doesn't help: "High order of identity" is all it says. Here's what it actually is: a function that returns a function - and that returned function ignores whatever arguments it's called with and always returns the value you gave it.

In JavaScript, _.constant(5) gives you a function where fn(anything) === 5, forever. It's the classic "no-op iteratee" or "always this answer" stub used in functional code - when you need a callback that's guaranteed to return a fixed value no matter what's passed in. In this Python port, constant(*args) builds exactly that kind of closure.

How it works

Generated wrapper around underscore3, the bundled Python port of Underscore.js. The node's inputs are obj (the value to bake in) and args (an any-type socket; the tooltip notes JSON is allowed, and for multiple values you provide a JSON array). The output * is the resulting callable - a function that ignores its arguments and returns obj.

Where does that slot into a Comfy graph? The honest answer: it's niche. A bare constant function is only useful where some node expects a Python callable, which in this pack is the world of PY_FUNC-style inputs and iteratee sockets. If a _.filter or _.map iteratee socket needs "a function that always returns true" or "always returns this tag," a constant-function output is a clean way to supply it. If you're not feeding callables around, this node will sit on the shelf.

Inputs and output

  • obj (any type) - the value the returned function will always produce.
  • args (any type) - extra arguments, JSON-array-able if you want to pass several.
  • Output: * (any type) - the constant function itself.

Installing it

Part of sfinktah/comfy-ovum ("comfy-ovum"):

  • ComfyUI Manager: search "comfy-ovum", install, restart.
  • Manual: cd ComfyUI/custom_nodes && git clone https://github.com/sfinktah/comfy-ovum, restart.

No model downloads; light dependencies; underscore3 bundled in the repo.

Should you use it?

Only if you're already passing functions around your graph - via the pack's PY_FUNC exports (see the "underscore function" node) or Power Puter-style expression nodes. If you are, _.constant is a genuinely handy building block: a guaranteed-answer callback for predicate sockets. If you aren't, skip it; nothing here is going to add value as a standalone node. And as with the whole family, the author's README flags the underscore suite as work-in-progress - this one is honest to its name, just niche.

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
**