clone

Creates a cloned Arith API with isolated configuration state.

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

Arith.config({ DECIMAL_PLACES: 5 });
const BN = Arith.clone({ DECIMAL_PLACES: 9 });

const x = Arith.from("1");
const y = BN.from("1");

x.div("3").toString(); // "0.33333"
y.div("3").toString(); // "0.333333333"

// clone() without options creates another independent Arith API.
const Rounded = Arith.clone();
Rounded.config({ DECIMAL_PLACES: 2 });
Rounded.from("1").div("3").toString(); // "0.33"

// Restore the default constructor after examples that change global config.
Arith.config({ DECIMAL_PLACES: 20 });

API Reference

Signature

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

Parameters

ParameterTypeRequiredNotes
objectArithConfigNoOptional configuration for the cloned constructor.

Returns

Returns a cloned Arith API. Values created by the clone use that clone's configuration.

Throws

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

Agent Contract

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

Agent Notes

  • Prefer Arith.clone() over shared Arith.config() in reusable libraries.
  • Do not import or generate a top-level clone(...); use Arith.clone(...).
  • Import with import { Arith } from "@teakit/arith"; default imports are unsupported.
  • 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.