Settings and configuration
Shared runtime settings are exposed through nerdamer.set(...) and nerdamer.get(...). Settings affect subsequent operations, so application code that changes a setting temporarily should restore its previous value when it is finished.
import nerdamer from 'nerdamer';
const previous = nerdamer.get('USE_SINGLE_LETTER_VARIABLES');
try {
nerdamer.set('USE_SINGLE_LETTER_VARIABLES', true);
console.log(nerdamer('2ab').text()); // 2*a*b
}
finally {
nerdamer.set('USE_SINGLE_LETTER_VARIABLES', previous);
}
Several settings can also be changed together:
nerdamer.set({
ALLOW_IMPLICIT_MULTIPLICATION: false,
INDEX_BASE: 1
});
Notation and indexing
These settings directly change how Nerdamer Notation is interpreted. The Expression syntax page shows them in context.
| Setting | Default | Effect |
|---|---|---|
ALLOW_IMPLICIT_MULTIPLICATION | true | Allows multiplication to be inferred in forms such as 2x, x(9), and (a+b)(c+d). Set it to false when input should require an explicit *. |
USE_SINGLE_LETTER_VARIABLES | false | Treats adjacent letters as separate variables when enabled. For example, ab is interpreted as a*b. Registered function names are still recognized as functions. |
INDEX_BASE | 0 | Controls the public index base used by vector and matrix access. Use 0 for zero-based indexing or 1 for one-based indexing. |
Evaluation, substitution, and expression handling
| Setting | Default | Effect |
|---|---|---|
EVALUATE | false | Enables numerical evaluation paths used by constants, functions, powers, and other operations that can produce a numerical value. |
SUBSTITUTE | true | Allows values stored in the shared variable state to substitute automatically during parsing. |
SORT_TERMS | false | Sorts expression terms during text conversion. The default avoids the additional sorting work unless ordered output is requested. |
DEFER_SIMPLIFICATION | false | Preserves more unevaluated operation structure instead of immediately applying the normal simplification paths. This is primarily useful for lower-level parser work. |
ALLOW_RAT_SUBS | false | Allows substitution matching to use non-integer rational multipliers where the substitution routine can support them. |
expression.text({ sort: true }) when only one rendered result needs conventional term ordering. That option does not change SORT_TERMS globally. See Text output and public helpers.Localized error messages
The library can select the language used by its built-in error message catalog through the LANGUAGE setting. English is the default.
Supported language catalog
| Language | Code | Notes |
|---|---|---|
| English | eng | Default catalog. |
| Spanish | spa | Spanish error messages. |
| French | fra | French error messages. |
| German | deu | German error messages. |
| Portuguese | por | Portuguese error messages. |
| Italian | ita | Italian error messages. |
| Dutch | nld | Dutch error messages. |
Set the catalog before running the operation whose errors should use that language:
import nerdamer from 'nerdamer';
const previousLanguage = nerdamer.get('LANGUAGE');
try {
nerdamer.set('LANGUAGE', 'spa');
try {
nerdamer('0^0');
}
catch (error) {
if (error instanceof Error) {
console.log(error.message);
// ¡0^0 no está definido!
}
}
}
finally {
nerdamer.set('LANGUAGE', previousLanguage);
}
LANGUAGE selects the error-message catalog. It does not translate Nerdamer Notation, function names, or the JavaScript / TypeScript API.The language setting is shared just like the other runtime settings. If an application changes it temporarily, restore the previous value when that operation is finished.
Typed parser consumers can also import the supported language type. The Language type is derived from the available catalog keys, so it stays aligned with the supported codes:
import type { Language } from 'nerdamer/parser';
const language: Language = 'fra';
nerdamer.set('LANGUAGE', language);
Limits and numeric precision
| Setting | Default | Effect |
|---|---|---|
MAX_PRODUCT_AND_SUMMATION_ITERATION | 10000 | Limits direct finite iteration performed by sum and product. Larger ranges can remain symbolic instead of being expanded term by term. |
MAX_LOOP_ITERATIONS | 10000 | Limits completed iterations in Nerdamer Scripting control-flow loops. |
MAX_FRAC_INT | BigInt(1e60) | Caps integer sizes used by exact root extraction paths so very large numerator or denominator values do not trigger impractical work. |
LANGUAGE | 'eng' | Selects one of the supported error-message catalogs listed above. |
PRECISION | current numeric precision | Controls the shared arbitrary-precision decimal setting and keeps finite-precision values of pi and e synchronized. PRECISION is handled specially by the root nerdamer.set/get API. |
Direct parser access
If you import the parser API directly, the same shared settings can be read and changed with Parser.get(...) and Parser.set(...). Precision uses the parser's dedicated precision methods.
import { Parser } from 'nerdamer/parser';
Parser.set('INDEX_BASE', 1);
Parser.set('LANGUAGE', 'deu');
const base = Parser.get('INDEX_BASE');
const language = Parser.get('LANGUAGE');
Parser.setPrecision(40);
const precision = Parser.getPrecision();
Settings retained in the source object without an active runtime read
The current SettingsType also contains the names below, but the runtime does not currently read them outside the settings declaration. They are therefore not documented as active behavior switches.
| Setting | Current default |
|---|---|
USE_FRACTIONS | true |
ALLOW_BIGINT | true |
REWRITE_SQRT | true |
IMMUTABLE_VALUE_SETS | true |
INITIALIZE_RULES | true |
Code should not rely on those names changing behavior unless they acquire an active runtime use in a later release.
