Nodes/comfy-ovum/_.extend
ComfyUI Node

_.extend

Merge dicts, later wins

By sfinktah·Created about a year ago·Updated 10 months ago· 7
_.extend
  • py_dict
  • sources
  • DICT

_.extend merges dicts together: it copies every property from one or more source dicts onto a destination dict and returns the result. The author's description is the canonical Underscore one: "Shallowly copy all of the properties in the source objects over to the destination object… It's in-order, so the last source will override properties of the same name in previous arguments."

That "last source wins" is the personality of this node - it's the exact opposite of _.defaults, where the first value wins. _.defaults fills gaps; _.extend overwrites. If you're composing configs and you want a later layer to override an earlier one - widget values beating a base template, per-item settings beating a global default - this is the node.

How it works

Generated wrapper around underscore3, the bundled Python port of Underscore.js. Semantics:

  • Properties from each source are copied onto the destination in order.
  • When two sources define the same key, the last one wins.
  • It's shallow: nested dicts and lists are copied by reference, not duplicated. Overwriting a top-level key is safe; mutating a nested structure still reaches back into the shared object.

_.extend({"a": 1}, {"b": 2}, {"a": 9}){"a": 9, "b": 2}. In-order, last wins.

Inputs and output

  • py_dict (any type) - the destination dict.
  • sources (any type) - one or more source dicts; the tooltip notes JSON is allowed for arrays/objects, and for multiple values you can provide a JSON array.
  • Output: DICT - the merged result.

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.

The pairing to remember

Think of _.extend and _.defaults as two halves of one mental model: defaults fills what's missing without touching what's there; extend overwrites whatever the later source says. Pick based on which side you trust to win. For flat dict merges this is predictable and quick. The usual family caveat applies - the author flags the underscore suite as work-in-progress in the README - and if you need nested keys merged recursively rather than replaced wholesale, that's _.extendDeep's job, not this one's.

Categoryovum/underscore

Inputs (2)

NameTypeDefaultDescription
py_dictopt*Primary input object (expected object). You can still pass any JSON-serializable value. Also accepts _.CHAIN to continue chaining.
sourcesopt*sources: JSON allowed for arrays/objects where applicable. For multiple values, provide a JSON array (e.g., [1,2,3]).

Outputs (1)

NameTypeDescription
DICTDICT