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';
nerdamer.set('USE_SINGLE_LETTER_VARIABLES', true);
console.log(nerdamer('2ab').text()); // 2*a*b
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. |
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 LANGUAGE setting selects among the error-message catalogs included in the current Nerdamer build. 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. |
eng. Setting LANGUAGE does not load another catalog at runtime. A targeted build such as --env language=spa,fra contains English, Spanish, and French; it starts with Spanish selected and allows runtime switching among those included catalogs. To switch freely among every supported language, build with --env language=all. See Language-targeted browser builds.When the requested catalog is included in the build, set it 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 an error-message catalog that is already present in the build. It does not load a catalog, translate Nerdamer Notation, translate function names, or translate 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 describes the supported catalog codes; the selected catalog must still be included in the build:
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 an error-message catalog that is included in the current build. |
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.
Parser.set('LANGUAGE', ...) has the same build-time requirement as nerdamer.set('LANGUAGE', ...). The default browser build contains only eng; selecting another language requires a bundle built with that catalog, a comma-separated subset containing it, or language=all.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();
Reserved settings
The following setting names are present in the current API but do not currently change Nerdamer's behavior. Do not rely on them until they are documented as active settings.
| 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.
