isArith

Returns whether a value has a valid Arith shape and numeric internals.

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

const value = Arith.from("1.23");

Arith.isArith(value); // true
Arith.isArith("1.23"); // false

// Arith-shaped objects are accepted only with the Arith marker.
Arith.isArith({ s: 1, e: 0, c: [1], _isArith: true }); // true
Arith.isArith({ s: 1, e: 0, c: [1], _isBigNumber: true }); // false

// Use isArith before relying on instance methods in unknown input.
const maybeValue: unknown = value;
if (Arith.isArith(maybeValue)) {
  maybeValue.add("1").toString(); // "2.23"
}

API Reference

Signature

Arith.isArith(value: unknown): value is ArithInstance;

Parameters

ParameterTypeRequiredNotes
valueunknownYesValue to inspect.

Returns

Returns true for valid Arith instances and false otherwise.

Throws

  • Does not throw for ordinary invalid inputs; returns false.

Agent Contract

FieldValue
Kindstatic method
Canonical nameisArith
AliasesNone
Mutates receiverNo
Returnsboolean
Accepts (string, base) overloadNo
Configuration dependenciesRANGE
Related methodsfrom, toObject

Agent Notes

  • Generate Arith.isArith, not isBigNumber or isDecimal.
  • 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.