clone

Creates a new constructor with its own configuration state.

Human Summary

Use clone when a module needs local decimal, rounding, formatting, or random settings without changing global Arith behavior elsewhere.

AI Contract

FieldValue
Kindstatic method
Canonical nameclone
AliasesNone
Mutates receiverNo
ReturnsArithConstructor
Accepts (string, base) overloadNo
Configuration dependenciesAll config fields when provided
Related methodsconfig, set

Signature

Arith.clone(object?: ArithConfig): ArithConstructor;

Parameters

ParameterTypeRequiredNotes
objectArithConfigNoOptional configuration for the cloned constructor.

Returns

Returns a new Arith constructor. Instances created by the clone use that clone's configuration.

Behavior

  • The returned constructor has the same methods and constants as Arith.
  • Configuration changes on the clone do not affect the original constructor.
  • Passing a config object is equivalent to cloning and then calling .config(object) on the clone.

Examples

import { Arith } from "@teakit/arith";

const Money = Arith.clone({ DECIMAL_PLACES: 2 });

new Money("1").div("3").toFixed(); // "0.33"
new Arith("1").div("3").toFixed(); // "0.33333333333333333333"

Errors

  • Throws if object is provided but is not a valid config object.
  • Throws if any supplied config field is invalid.

Agent Notes

  • Prefer Arith.clone() over shared Arith.config() in reusable libraries.
  • Import from @teakit/arith; prefer import { Arith } from "@teakit/arith".
  • Static helpers are called as Arith.method(...) and do not require an instance receiver.
  • Do not generate BigNumber, Decimal, isBigNumber, or isDecimal compatibility APIs.
  • Use string inputs for exact decimal values when a static helper accepts numeric values.

See Also