The number system to use for the position functions
Optional
value: PositionValueUsed to set a default value for the position
Private
#nLeft number for after and before operations
Private
#systemReference number sytem
Private
#zRight number for diverge and between operations
Unique symbol attached to every position instance, helps to validate that
an object is a pure
position and it was not instanciated with another
seemingly class or prototype
Private
#parseReturns the value that lies between the current postion and another
import { staquia } from "staquia";
// Given a system like this
let zero = "!"; // Would be like 0
let first = "a"; // Would be like 1
let middle = "n"; // Would be like 14
let last = "z"; // Would be like 26
// The middle character between two positions
// can be seen as Math.ceil((first + last) / 2);
let n = staquia.position(first).core(last); // Will result in "n"
// When there is no room between 2 positions, the "middle" value
// from the system will be attached to the last position.
// This is where the "threshold" and "overflow" handling
// logic will be applied
let am = staquia.position("a").core("b"); // Will result in "am"
The position that should go before or after thi current position
Compares an object or a string to see if it is equals to the current instance
const original = staquia.position("nnnnnz");
// Can be compared with another instance
const instance = staquia.position("nnnnnz");
original.toEquals(instance);
// Can be compared with a valid position string
const string = "nnnnnz";
original.toEquals(string);
// Can be compared with a valid position object
const object = { n: "nnnnn", z: "z"};
original.toEquals(object);
The value to compare against
Gets the n
and z
values
// Asuming the "n" segment length is like below
let ln = 5;
// Create it as a string
const position = staquia.position("n");
postion.toObject
// Will look like this
let object = {
n: "!!!!n",
z: "!"
}
Concatenates the n
value with the z
// Asuming the "n" segment length is like below
let ln = 5;
// Create it as an object
const position = staquia.position({
n: "n",
z: "zzzz",
});
// Will print "!!!!nzzzz" as will attach leading zeroes
const string = position.toString();
Updates the position based on an input value
With this function the position instances can be compared
as plain strings
with the less than <
and greater than >
operators
// Create your positions
const a = staquia.position("a");
const b = staquia.position("b");
// Just compare them as plain objects
a < b // Will return false
a > b // Will return true
Static
isStatic
isDetermines if a plain object is a valid position object
Optional
value: anyGenerated using TypeDoc
This objects represents a postion instace that can be divided in:
n
as the part that helps the position to move up and downz
as the part that helps to expand on reinsertionsEach instance contains functions that helps to get the next, previous or even between positions values. Plus validation and comparation logic.
By default this position will be generated using the defined
staquia
number sytem as reference.Example