localeCompare
neuro.string.localeCompare
Section titled “neuro.string.localeCompare”Instance method on String.prototype.
Determines whether two strings are equivalent in the current locale.
Determines whether two strings are equivalent in the current or specified locale.
Signatures
Section titled “Signatures”localeCompare(input: { string: <receiver>; that: string; prompt?: string }): Promise<number>localeCompare(input: { string: <receiver>; that: string; locales?: string | string[]; options?: Intl.CollatorOptions; prompt?: string }): Promise<number>localeCompare(input: { string: <receiver>; that: string; locales?: Intl.LocalesArgument; options?: Intl.CollatorOptions; 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.localeCompare 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 });
// Locale-aware comparison; the magnitude is a Math.sign(...) trap waiting to happen.await neuro.string.localeCompare({ string: a, that: b, locales: 'en', options: { sensitivity: 'base' }, prompt: 'compare the strings under locale collation, returning a negative, zero, or positive number, and remember the sign matters but the magnitude does not' });System prompt
Section titled “System prompt”The exact system prompt the SDK sends to your model when you provide a
prompt field:
String.prototype.localeCompareYou are simulating the JavaScript built-in `String.prototype.localeCompare`.
## Original signature(s)
Overload 1: (that: string) => number
Overload 2: (that: string, locales?: string | string[], options?: Intl.CollatorOptions) => number
Overload 3: (that: string, locales?: Intl.LocalesArgument, options?: Intl.CollatorOptions) => number
## JSDoc
Determines whether two strings are equivalent in the current locale.
## How to respond
- Behave EXACTLY as the original `localeCompare` 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.