ReadonlyisOverflow: booleantrue if the generated position overflowed, false otherwise.
Readonlyposition: IPositionThe position that overflowed.
ReadonlyisDangerous: booleantrue if the generated position reached the threshold, false otherwise.
Readonlyposition: IPositionThe position that reached the threshold.
ReadonlyisMismatch: booleantrue if the position was created by another number system, false otherwise.
Readonlyposition: IPositionThe position created by another system.
Readonlyindex: numberThe index of the first invalid character.
ReadonlyisInvalid: booleantrue if the string contains a character that is not a digit of the system, false otherwise.
Readonlystring: stringThe string that was forged.
import Staquia, { InvalidCharacterError, ThresholdReachedError } from "staquia";
const system = Staquia.create("!", "a", "z", 5, 15, 0.15);
const result = system.forge("abC");
if (!result.ok) {
if (result.error instanceof InvalidCharacterError) console.log("Not a digit at", result.error.index);
else if (result.error instanceof ThresholdReachedError) console.log("Valid, but rebalance soon");
else console.log(result.error.message);
}
Any error returned by the position functions: an
OverflowError, aThresholdReachedError, aSystemMismatchErroror anInvalidCharacterError. Useinstanceofwith the error classes (or theirtruediscriminator fields) to know which one it is.