_.uniq
Dedupe a list and keep the first occurrence
- py_list
- iteratee
- LIST
If you've ever had the same tag or filename show up three times in a prompt list, _.uniq is the dedupe node you're looking for. It produces a duplicate-free copy of an array, keeping only the first occurrence of each value and preserving order - which makes it the sane choice for tag lists and seed lists, unlike a set() which would reorder everything.
This is one of the more fully-featured members of the ovum/underscore family in comfy-ovum. It's an auto-generated wrapper around underscore3 (the vendored Python port of Underscore.js), and it exposes the extra knobs Underscore's uniq actually has: a sorted fast-path and an iteratee. Just remember the family disclaimer - the README calls these nodes "an absolute disaster to use in production," WIP, not recommended for live workflows. uniq is closer to the sane end of that spectrum, but it's still a tool for assembling graphs, not a load-bearing beam.
How it works
Standard Underscore uniq: walk the list, keep an item the first time you see it, drop it every time after. "Using === to test object equality" in JS-speak, which in the Python port means equality on the values themselves.
Two optional behaviors:
isSorted(BOOLEAN widget, default off): if your list is already sorted, flip this on and it runs a faster algorithm that only compares neighbors. Handy for big lists, but wrong if the list isn't actually sorted.iteratee: compute uniqueness based on a transformation rather than the raw value - e.g., unique bylen(item)or by a dict key. You can supply this two ways: wire an input into theiterateesocket (any object/function), or, if nothing's connected, type JSON or a key selector into theiteratee_jsonmultiline widget.
Inputs and output
py_list- the array to dedupe (type*, optional; also accepts a_.CHAINto continue a chain).isSorted- BOOLEAN, defaultfalse.iteratee/iteratee_json- the transformation, input socket or JSON widget.- Output:
LIST.
Install
Manager: search comfy-ovum, install, restart. Or:
cd ComfyUI/custom_nodes
git clone https://github.com/sfinktah/comfy-ovum
Restart. No model downloads; underscore3 is bundled, so nothing extra for this node.
When it's worth it
Deduping assembled tag lists before they hit the prompt, or cleaning a list of file paths that a batch process generated twice. Skip isSorted unless your data's actually sorted; skip the iteratee unless you know what you're transforming on. For the common case it's just: wire a list in, get a cleaner list out.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| py_listopt | * | Primary input object (expected array). You can still pass any JSON-serializable value. Also accepts _.CHAIN to continue chaining. | |
| isSortedopt | BOOLEAN | false | isSorted (boolean) |
| iterateeopt | * | iteratee: ANY input to override widget. Accepts function, key string, or object shorthand. | |
| iteratee_jsonopt | STRING | iteratee_json: JSON or key selector. Used when 'iteratee' input is not connected. |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| LIST | LIST | — |