Files
hyperstitionstudio-core/packages-js/ciphers-aq/index.js
T

28 lines
777 B
JavaScript

/**
* @hyperstitionstud.io/ciphers-aq (urn:io:hyperstitionstud:js:ciphers-aq:1.2.0)
* 100% Offline Base-36 Alphanumeric Qabbala (AQ) & Repdigit Evaluator for Browser (file:// & http://) and Node ESM.
*/
export function computeAQ(text) {
let total = 0;
const s = String(text || "").toLowerCase();
for (let i = 0; i < s.length; i++) {
const code = s.charCodeAt(i);
if (code >= 48 && code <= 57) {
total += code - 48;
} else if (code >= 97 && code <= 122) {
total += code - 87;
}
}
return total;
}
export function isRepdigit37(n) {
return n > 0 && n % 111 === 0;
}
if (typeof window !== "undefined") {
window.HyperstitionStudio = window.HyperstitionStudio || {};
window.HyperstitionStudio.Ciphers = { computeAQ, isRepdigit37 };
}