_.take
The first element — or the first n, with a surprising twist
- obj
- default
- *
_.take returns the first element of a list - and if you pass n, the first n elements. ["a","b","c"] → "a". With n=2 → ["a","b"]. It's the "head of the list" node, aliased in Underscore.js as head and take.
There's a twist baked into the semantics that the node's description calls out explicitly, and it bites people: not passing n returns the first item as a bare value; passing n=1 returns a list containing only the first item. Same data, different shape - one is a scalar, the other is a one-element list. This is faithful to Underscore.js, but if you're mid-graph and wondering why a downstream node got a scalar when you asked for "one," that's the answer. It's also a place where the comfy-ovum wrapper's generic * output type won't warn you: there's no type mismatch to catch, because there's no type on the wire.
Inputs and output
- obj (
*) - the list. Expects an array; typed*so it accepts anything list-like. - n (INT, default 1) - how many leading elements to keep. Leave it alone to get the first item as a scalar.
- default (
*) - what to return when the list is empty. Underscore'sfirst(list, n, guard)lets you provide a fallback; the wrapper exposes it as a JSON-typed input. If you're taking from a list that might be empty, this is the safety net that keepsNonefrom flowing downstream.
Output is a single * - either the first element or a list of the first n. The family chain behavior applies: feed a _.CHAIN in as obj and you get a chain back (unwrap with _.value), which is how you build "random item" or "top of the sorted list" pipelines in one string of nodes.
Why you'd reach for it
Anywhere you need "just the first one": grab the first prompt from a batch, the first filename, the first LoRA in a stack. Combined with _.sortBy it becomes "the best one" (sort ascending, take first). Combined with _.shuffle it becomes "a random one." It's the most immediately useful of the array-access nodes in this family.
Family caveat, stated once: these ovum/underscore nodes are auto-generated wrappers around the bundled underscore3 Python port, and the author's README calls the family a work in progress, "not recommended for use in workflows." For a take, the risk is low - just respect the scalar-vs-list quirk.
Install
# via ComfyUI Manager: search "comfy-ovum"
cd ComfyUI/custom_nodes
git clone https://github.com/sfinktah/comfy-ovum
# restart ComfyUI
No model downloads; pure Python, deps (aiohttp, pillow, numpy, requests, etc.) via Manager, underscore3 bundled in the repo. If your downstream node rejects the output as the wrong shape, you've hit the scalar/list distinction - set n and feed the result through a list cast, or take from a one-item slice of your list first.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| objopt | * | Primary input object. Also accepts _.CHAIN to continue chaining. | |
| nopt | INT | 1 | n (int) |
| defaultopt | * | default: JSON allowed for arrays/objects where applicable. |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| * | * | — |