Skip to content

codePointAt

Instance method on String.prototype.

Returns a nonnegative integer Number less than 1114112 (0x110000) that is the code point value of the UTF-16 encoded code point starting at the string element at position pos in the String resulting from converting this object to a String. If there is no element at that position, the result is undefined. If a valid UTF-16 surrogate pair does not begin at pos, the result is the code unit at pos.

codePointAt(input: { string: <receiver>; pos: number; prompt?: string }): Promise<number>

The prompt field is optional. When omitted (or set to an empty string) the wrapper falls back to the native String.prototype.codePointAt 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 });
// Astral-aware code point; the position is still UTF-16-counted, which is the trap.
await neuro.string.codePointAt({ string: emoji, pos: 0, prompt: 'return the full Unicode code point at pos, combining surrogate pairs the way charCodeAt refused to, and remember pos is still a UTF-16 index' });

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

Generated promptString.prototype.codePointAt
You are simulating the JavaScript built-in `String.prototype.codePointAt`.
## Original signature(s)
  Overload 1: (pos: number) => number
## JSDoc
Returns a nonnegative integer Number less than 1114112 (0x110000) that is the code point
value of the UTF-16 encoded code point starting at the string element at position pos in
the String resulting from converting this object to a String.
If there is no element at that position, the result is undefined.
If a valid UTF-16 surrogate pair does not begin at pos, the result is the code unit at pos.

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