0.3.4 • Published 7 months ago

staquia v0.3.4

Weekly downloads
-
License
MIT
Repository
github
Last release
7 months ago

Staquia

This is a configurable lexicographic position based algorithm, used to get the core, next or previous number for a nth base number system. This project was created with the intention to solve the reinsertion and sorting problem when using long lists.

To have a full detailed explanation you can go to the documentation site.

You can install with all its dependencies as below.

  npm install guardex, staquia --save-dev

Or use it from the unpkg cdn as a simple script tag via the browser to have it as a global object named staquia.

<script src="https://unpkg.com/staquia@0.3.4/umd/index.js"></script>
<script type="module">
  console.log(staquia); // Now can be used globally in the HTML app
</script>

Note: As umd must contain only one default exported object, all named imports (like symbol) are contained within the global object staquia.

All of the examples in this document uses ECMA syntax to import or export code from the library, but this supports CommonJS syntax as well.

// ECMA Syntax
import staquia from "staquia";

// CommonJS Syntax
const { staquia } = require("staquia");

// Some libraries will support conditional imports poorly
// or not even support it.
// For these cases you can force the imports like below.

// For ECMA Scripts
import staquia from "staquia/esm";
// For CommonJS Scripts
const { staquia } = require("staquia/cjs");
// For browser applications UMD
import * as staquia from "staquia/umd";
const staquia = require("staquia/umd");

Settings

You can pass as settings the options to create the best system that fits your needs.

import { staquia } from "staquia";

// This example has an 27th base number set [a - z]
staquia.setup({
  // z
  zero: "!",
  // sf
  first: "a",
  // s0
  last: "z",
  // kappa
  ϰ: 0.15,
  // `n` and `z`
  segments: {
    n: 5,
    z: 15,
  },
});

Note: All of the following examples are shown using the above system in the example.

Position

Is an object that represents a position that can be used either on on a table or a stack.

This contains functions to get the next, previous or even the core position that lays between this and another position.

The system from this position is based on a string that contains two sections, the n part and the z part.

This uses the property of string comparison where depending on the unicode number that represents the character, this may be bigger or smaller than other.

// Unicode \u0061 (61)
const a = "a";

// Unicode \u0062 (62)
const b = "b";

// Will print true as 61 < 62
console.log(a < b);

Section n

This section was designed with the sole purpose the to move up or down one position when the next or previous algorithm is used.

import { staquia } from "staquia";

// This example uses the 27th base number set [a - z]
const xy = staquia.position("xy");
const xz = xy.next();
// Prints - The following character is !!xz"
console.log("The following character is " & xz);

// This example uses the 27th base number set [a - z] with character zero as !
const b0 = staquia.position("b!");
const az = b0.previous();
// Prints - The previous character is !!az"
console.log("The previous character is " & az);

Section z

This section was designed with the sole purpose the to go to the mid value from two positions when the core algorithm is used.

import { staquia } from "staquia";

// This example uses the 27th base number set [a - z]
const a = staquia.position("a");
const b = staquia.position("b");

const am = a.core(b);

// Prints - The following character is !!!am"
console.log("The following character is ", am);

Above explains how the position systems works but there is more if you want to get the full power from this algorithm as mention in the beggining please visit documentation site.

0.3.4

7 months ago

0.3.3

1 year ago

0.3.2

1 year ago

0.3.1

1 year ago

0.3.0

1 year ago

0.2.4

1 year ago

0.2.3

1 year ago

0.2.2

1 year ago

0.2.1

1 year ago

0.2.0

1 year ago

0.1.5

1 year ago

0.1.4

1 year ago

0.1.3

1 year ago

0.1.2

1 year ago

0.1.1

1 year ago

0.1.0

1 year ago

0.0.1

1 year ago