race
neuro.promise.race
Section titled “neuro.promise.race”Static method on Promise.
Creates a Promise that is resolved or rejected when any of the provided Promises are resolved or rejected.
Signatures
Section titled “Signatures”race(input: { values: Iterable<T | PromiseLike<T>>; prompt?: string }): Promise<Promise<Awaited<T>>>race(input: { values: T; prompt?: string }): Promise<Promise<Awaited<T[number]>>>The prompt field is optional. When omitted (or set to an empty string)
the wrapper falls back to the native Promise.race and returns a
resolved Promise without contacting the LLM. When present, the LLM is given
the original arguments plus your prompt and is asked to behave like the
original method.
Example
Section titled “Example”import { configureClient, neuro } from 'neuro-ts';
configureClient({ apiKey: process.env.OPENAI_API_KEY });
// First-to-settle. The losers keep executing. Unhandled rejections still fire.await neuro.promise.race({ values: [primary, fallback], prompt: 'resolve or reject with the first settled promise, leaving the rest running in the background - like abandoned microservices' });System prompt
Section titled “System prompt”The exact system prompt the SDK sends to your model when you provide a
prompt field:
Promise.raceYou are simulating the JavaScript built-in `Promise.race`.
## Original signature(s)
Overload 1: (values: Iterable<T | PromiseLike<T>>) => Promise<Awaited<T>>
Overload 2: (values: T) => Promise<Awaited<T[number]>>
## JSDoc
Creates a Promise that is resolved or rejected when any of the provided Promises are resolved
or rejected.
## How to respond
- Behave EXACTLY as the original `race` would, but use the user's intent to choose any callback / comparator / transform logic that the original would normally accept as an argument.
- Strictly preserve the original return type and shape.
- Output ONLY the JSON-encoded return value of the function call.
- Do NOT include explanations, prose, comments, or markdown fences.
- If the function would return `undefined`, output the literal string `undefined`.
- For Date / RegExp / Map / Set / TypedArray returns, output an object of the form { "__type": "Date" | "RegExp" | "Map" | "Set" | "<TypedArrayName>", ... } so the SDK can rehydrate it.