-
Notifications
You must be signed in to change notification settings - Fork 0
Types & Interfaces
HvdW144 edited this page Oct 28, 2024
·
7 revisions
Here all types & interfaces that are available to the user are documented, so all types & interfaces that aren't exported will not be discussed here.
(For contributors: These are the types exported in types.ts
with different names).
Purpose:
Contains all the information to be able to validate a kropki dot when using .validateKropki()
-method on an herbdoku instance.
Properties:
interface KropkiDot {
/**
* The first index of the kropki dot. The first cell that touches the dot.
*/
x1: number;
/**
* The second index of the kropki dot. The second cell that touches the dot.
*/
x2: number;
/**
* The value of the kropki dot.
* For white kropki, the difference between the two values should be this value, default is 1.
* For black kropki, the two values should be in a ratio of this value, default is 2.
*/
kropkiValue?: number;
/**
* The type of the kropki dot. Can be either `"white" (0)` or `"black" (1)`.
*/
kropkiType: "white" | "black" | 0 | 1;
}
Example:
const herbdoku = new Herbdoku("1234341221434321", 4);
const kropkiDotArray: KropkiDot[] = [{
x1: 5,
x2: 6,
kropkiValue: 3,
kropkiType: "white",
}];
const result = herbdoku.validateKropki(kropkiDotArray).build();
console.log(result);
Related:
- The
.validateKropki
-method
Purpose:
Contains all the information to be able to validate a thermometer when using .validateThermo()
-method on an herbdoku instance.
Properties:
interface Thermometer {
/**
* The indexes through which the thermometer passes, starting from the bulb.
*/
indexes: number[];
/**
* The value of the thermo. This is the minimum difference between two adjacent cells in the thermo.
* Use `0` for a slow thermo (eg. 12337).
* Default is `1`.
*/
thermoDifference?: number;
}
Example:
const herbdoku = new Herbdoku("1234341221434321", 4);
const thermoArray: Thermometer[] = [
{ indexes: [9, 7, 2, 13] }, /* 13 is invalid, 12 would be valid */
];
const result = herbdoku.validateThermo(thermoArray).build();
console.log(result);
Related:
- The
.validateThermo
-method
Purpose:
This will be the format that you get back after calling the .build()
-method on an herbdoku instance.
Properties:
interface ValidatorResult {
/**
* Contains true when all issued checks are found valid.
*/
isValid: boolean;
/**
* Contains all returned messages, like warnings, errors and further information.
*/
messages: string[];
/**
* Contains all (unique) **indexes** that are found invalid by one or more of the issued checks.
*/
invalidIndexes: number[];
}
Example:
const herbdoku = new Herbdoku("452891763391627854687435912716582439529314687834976521148753296973268145265149378");
const validatorResult = herbdoku.validateDefault().build();
console.log(validatorResult);
Related:
- The
.build()
-method