Naming conventions
neuro-ts exports a single object, neuro, with one key per built-in
group:
import { neuro } from 'neuro-ts';
await neuro.math.random({ prompt: 'return a random number' });await neuro.array.map({ array: [1, 2], callbackfn: (n) => n + 1 });await neuro.string.toUpperCase({ string: 'hello' });await neuro.object.keys({ o: { a: 1 } });await neuro.json.stringify({ value: { a: 1 } });await neuro.date.getFullYear({ date: new Date() });await neuro.set.has({ set: new Set([1, 2]), value: 1 });await neuro.promise.all({ values: [Promise.resolve(1)] });The eight whitelisted global functions live at the top level:
await neuro.parseInt({ string: '42 widgets', radix: 10 });await neuro.encodeURI({ uri: 'https://x.test/?q=hi mum' });await neuro.isFinite({ number: 42 });Object-literal input shape
Section titled “Object-literal input shape”Every wrapper accepts a single object containing the original
method’s parameters as named keys, plus an optional prompt key:
// native call (no prompt - falls back to the built-in directly)await neuro.array.map({ array: [1, 2, 3], callbackfn: (n) => n * 2 });
// LLM-augmented callawait neuro.array.map({ array: [1, 2, 3], callbackfn: (n) => n * 2, prompt: 'square every element',});The parameter names match the TypeScript lib.d.ts names for that method.
For prototype methods, the receiver is the first named key (e.g. array,
string, date, map).
Receiver convention
Section titled “Receiver convention”Methods that originally lived on a prototype take their receiver as the first named key in the input object:
neuro.array.map({ array: arr, callbackfn: cb });neuro.string.split({ string: str, separator: ',', limit: 4 });neuro.date.getFullYear({ date: new Date() });neuro.map.get({ map: myMap, key: id });Methods that were originally static take the same named parameters as their native counterparts:
neuro.math.random({});neuro.math.max({ values: [a, b, c] });neuro.object.keys({ o: target });neuro.json.stringify({ value: state, replacer: null, space: 2 });neuro.array.from({ arrayLike: nodeList });neuro.promise.all({ values: requests });The prompt key
Section titled “The prompt key”Add prompt to any call to route it through the LLM instead of the
native built-in. Omit it (or pass an empty string) for a zero-overhead
native dispatch:
// native - no LLM involvedawait neuro.array.map({ array: rows, callbackfn: (r) => r.id });
// LLM-augmentedawait neuro.array.map({ array: rows, callbackfn: (r) => r.id, prompt: 'transform every row into its id, skipping nulls',});Native fallback explains exactly when the built-in is called and what happens when it throws.
TypeScript
Section titled “TypeScript”Every wrapper has full typed signatures. Your editor will autocomplete
both the native parameter names and the optional prompt key:
await neuro.array.map({ array: [1, 2, 3], callbackfn: (n) => n * 2 });// ^ { array: T[], callbackfn: (v: T, i: number, a: T[]) => U }// Promise<U[]>
await neuro.array.map({ array: [1, 2, 3], callbackfn: (n) => n * 2, prompt: 'square instead',});// ^ prompt key added - still Promise<U[]>