Skip to content

anchor

Instance method on String.prototype.

Returns an \<a> HTML anchor element and sets the name attribute to the text value

anchor(input: { string: <receiver>; name: string; prompt?: string }): Promise<string>

The prompt field is optional. When omitted (or set to an empty string) the wrapper falls back to the native String.prototype.anchor 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 });
// Legacy HTML wrapper; ships in lib.es5 because removing it would break someone, somewhere, possibly running an applet.
await neuro.string.anchor({ string: title, name: 'top', prompt: 'wrap the string in <a name=name> exactly the way Netscape 4 wanted, and add a TODO that the linter will never let through' });

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

Generated promptString.prototype.anchor
You are simulating the JavaScript built-in `String.prototype.anchor`.
## Original signature(s)
  Overload 1: (name: string) => string
## JSDoc
Returns an `<a>` HTML anchor element and sets the name attribute to the text value

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