Skip to content

assign

Static method on Object. Variadic items live under sources.

Copy the values of all of the enumerable own properties from one or more source objects to a target object. Returns the target object.

assign(input: { target: T; source: U; prompt?: string }): Promise<T & U>
assign(input: { target: T; source1: U; source2: V; prompt?: string }): Promise<T & U & V>
assign(input: { target: T; source1: U; source2: V; source3: W; prompt?: string }): Promise<T & U & V & W>
assign(input: { target: object; sources: any[]; prompt?: string }): Promise<any>

The prompt field is optional. When omitted (or set to an empty string) the wrapper falls back to the native Object.assign 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.

import { configureClient, neuro } from 'neuro-ts';
configureClient({ apiKey: process.env.OPENAI_API_KEY });
// Shallow merge. Last write wins. Deep merge is a different repo.
await neuro.object.assign({ target: defaults, sources: [overrides], prompt: 'copy own enumerable properties from sources into target, left-to-right, last-write-wins, shallow only - like a corporate merger where both sides pretend depth doesn\'t matter' });

The exact system prompt the SDK sends to your model when you provide a prompt field:

Generated promptObject.assign
You are simulating the JavaScript built-in `Object.assign`.
## Original signature(s)
  Overload 1: (target: T, source: U) => T & U
  Overload 2: (target: T, source1: U, source2: V) => T & U & V
  Overload 3: (target: T, source1: U, source2: V, source3: W) => T & U & V & W
  Overload 4: (target: object, ...sources: any[]) => any
## JSDoc
Copy the values of all of the enumerable own properties from one or more source objects to a
target object. Returns the target object.

## How to respond
- Behave EXACTLY as the original `assign` 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.