kaabalah 1.0.4 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/gematria/index.d.mts +11 -10
- package/dist/gematria/index.d.ts +11 -10
- package/dist/gematria/index.js +80 -72
- package/dist/gematria/index.js.map +1 -1
- package/dist/gematria/index.mjs +80 -72
- package/dist/gematria/index.mjs.map +1 -1
- package/dist/index.js +80 -72
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +80 -72
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/gematria/index.mjs
CHANGED
|
@@ -2357,99 +2357,107 @@ var calculateGematria = (word, options = {}, tree) => {
|
|
|
2357
2357
|
if (!tree) {
|
|
2358
2358
|
tree = createTree({ system: SYSTEM2, parts: [] });
|
|
2359
2359
|
}
|
|
2360
|
-
const includedLetters =
|
|
2361
|
-
const
|
|
2360
|
+
const includedLetters = [];
|
|
2361
|
+
const words = word.toUpperCase().trim().split(" ");
|
|
2362
2362
|
let vowelsSum = 0;
|
|
2363
2363
|
let consonantsSum = 0;
|
|
2364
|
-
const
|
|
2365
|
-
|
|
2366
|
-
|
|
2367
|
-
|
|
2368
|
-
|
|
2369
|
-
|
|
2370
|
-
|
|
2371
|
-
|
|
2372
|
-
|
|
2373
|
-
|
|
2374
|
-
|
|
2375
|
-
|
|
2364
|
+
const includedGematriaValues = /* @__PURE__ */ new Set();
|
|
2365
|
+
const letterPercentages = {
|
|
2366
|
+
percentageOfVowels: 0,
|
|
2367
|
+
percentageOfConsonants: 0,
|
|
2368
|
+
letters: {}
|
|
2369
|
+
};
|
|
2370
|
+
for (const word2 of words) {
|
|
2371
|
+
const letters = word2.split("");
|
|
2372
|
+
for (let i = 0; i < letters.length; i++) {
|
|
2373
|
+
const letter = letters[i].toLocaleUpperCase();
|
|
2374
|
+
const nextLetter = letters[i + 1]?.toLocaleLowerCase() || "";
|
|
2375
|
+
if (["P", "T", "K", "S", "C"].includes(letter) && nextLetter) {
|
|
2376
|
+
const combinedLetter = letter + nextLetter;
|
|
2377
|
+
const isEnding2 = i > 0 && i === letters.length - 2;
|
|
2378
|
+
const latinLetterId2 = `letter:${combinedLetter}`;
|
|
2379
|
+
const [mapping2] = tree.walk(latinLetterId2, 2, "hebrewLetter");
|
|
2380
|
+
if (mapping2?.data) {
|
|
2381
|
+
let value = mapping2.data.gematriaValue;
|
|
2382
|
+
if (isEnding2 && mapping2.data.gematriaValueWhenEnding !== void 0) {
|
|
2383
|
+
value = mapping2.data.gematriaValueWhenEnding;
|
|
2384
|
+
}
|
|
2385
|
+
includedGematriaValues.add(value);
|
|
2386
|
+
includedLetters.push({ latinLetterId: latinLetterId2, value, hebrewLetterId: mapping2.id, isVowel: isVowel(letter) });
|
|
2387
|
+
consonantsSum += value;
|
|
2388
|
+
i++;
|
|
2389
|
+
continue;
|
|
2376
2390
|
}
|
|
2377
|
-
presentGematriaNumbers.add(value);
|
|
2378
|
-
includedLetters.set(mapping2.id, { letter: combinedLetter, value, hebrewLetter: mapping2.data, isVowel: isVowel(letter) });
|
|
2379
|
-
consonantsSum += value;
|
|
2380
|
-
i++;
|
|
2381
|
-
continue;
|
|
2382
|
-
}
|
|
2383
|
-
}
|
|
2384
|
-
let mapping;
|
|
2385
|
-
const isStarting = i === 0;
|
|
2386
|
-
if (isStarting && letter === "O") {
|
|
2387
|
-
mapping = tree.getNode(`letter:${HEBREW_LETTERS.AIN}`);
|
|
2388
|
-
} else {
|
|
2389
|
-
mapping = tree.walk(`letter:${letter}`, 2, "hebrewLetter").at(0);
|
|
2390
|
-
}
|
|
2391
|
-
const isEnding = i > 0 && i === letters.length - 1;
|
|
2392
|
-
if (mapping?.data) {
|
|
2393
|
-
let value = mapping.data.gematriaValue;
|
|
2394
|
-
if (isEnding && mapping.data.gematriaValueWhenEnding !== void 0) {
|
|
2395
|
-
value = mapping.data.gematriaValueWhenEnding;
|
|
2396
2391
|
}
|
|
2397
|
-
|
|
2398
|
-
|
|
2399
|
-
|
|
2400
|
-
|
|
2392
|
+
let mapping;
|
|
2393
|
+
let latinLetterId = `letter:${letter}`;
|
|
2394
|
+
const isStarting = i === 0;
|
|
2395
|
+
if (isStarting && letter === "O") {
|
|
2396
|
+
latinLetterId = `letter:${HEBREW_LETTERS.AIN}`;
|
|
2397
|
+
mapping = tree.getNode(latinLetterId);
|
|
2401
2398
|
} else {
|
|
2402
|
-
|
|
2399
|
+
mapping = tree.walk(latinLetterId, 2, "hebrewLetter").at(0);
|
|
2400
|
+
}
|
|
2401
|
+
const isEnding = i > 0 && i === letters.length - 1;
|
|
2402
|
+
if (mapping?.data) {
|
|
2403
|
+
let value = mapping.data.gematriaValue;
|
|
2404
|
+
if (isEnding && mapping.data.gematriaValueWhenEnding !== void 0) {
|
|
2405
|
+
value = mapping.data.gematriaValueWhenEnding;
|
|
2406
|
+
}
|
|
2407
|
+
includedGematriaValues.add(value);
|
|
2408
|
+
includedLetters.push({ latinLetterId, value, hebrewLetterId: mapping.id, isVowel: isVowel(letter) });
|
|
2409
|
+
if (isVowel(letter)) {
|
|
2410
|
+
vowelsSum += value;
|
|
2411
|
+
} else {
|
|
2412
|
+
consonantsSum += value;
|
|
2413
|
+
}
|
|
2403
2414
|
}
|
|
2404
2415
|
}
|
|
2416
|
+
if (options?.calculateLetterPercentages) {
|
|
2417
|
+
const letterCount = letters.length;
|
|
2418
|
+
let vowelsCount = 0;
|
|
2419
|
+
let consonantsCount = 0;
|
|
2420
|
+
for (const letter of new Set(letters)) {
|
|
2421
|
+
const occurrences = letters.filter((l) => l === letter).length;
|
|
2422
|
+
letterPercentages.letters[letter] = occurrences / letterCount * 100;
|
|
2423
|
+
if (isVowel(letter)) {
|
|
2424
|
+
vowelsCount += occurrences;
|
|
2425
|
+
} else {
|
|
2426
|
+
consonantsCount += occurrences;
|
|
2427
|
+
}
|
|
2428
|
+
}
|
|
2429
|
+
letterPercentages.percentageOfVowels = vowelsCount / letterCount * 100;
|
|
2430
|
+
letterPercentages.percentageOfConsonants = consonantsCount / letterCount * 100;
|
|
2431
|
+
}
|
|
2405
2432
|
}
|
|
2406
2433
|
const vowelsReduction = reduceToSingleDigitWithSteps(vowelsSum);
|
|
2407
2434
|
const consonantsReduction = reduceToSingleDigitWithSteps(consonantsSum);
|
|
2408
2435
|
const synthesisReduction = reduceToSingleDigitWithSteps(
|
|
2409
2436
|
vowelsSum + consonantsSum
|
|
2410
2437
|
);
|
|
2411
|
-
const
|
|
2412
|
-
if (options?.
|
|
2438
|
+
const missingGematriaValues = [];
|
|
2439
|
+
if (options?.calculateMissingGematriaValues) {
|
|
2413
2440
|
for (const hebrewLetter of Object.values(HEBREW_LETTERS)) {
|
|
2414
2441
|
const hebrewLetterNode = tree.getNode(`letter:${hebrewLetter}`);
|
|
2415
2442
|
if (!hebrewLetterNode?.data) {
|
|
2416
2443
|
continue;
|
|
2417
2444
|
}
|
|
2418
|
-
if (!
|
|
2419
|
-
|
|
2420
|
-
|
|
2421
|
-
|
|
2445
|
+
if (!includedGematriaValues.has(hebrewLetterNode.data.gematriaValue)) {
|
|
2446
|
+
missingGematriaValues.push({
|
|
2447
|
+
value: hebrewLetterNode.data.gematriaValue,
|
|
2448
|
+
hebrewLetter,
|
|
2449
|
+
whenEnding: false
|
|
2422
2450
|
});
|
|
2423
2451
|
}
|
|
2424
|
-
if (hebrewLetterNode.data.gematriaValueWhenEnding && !
|
|
2425
|
-
|
|
2426
|
-
|
|
2427
|
-
|
|
2452
|
+
if (hebrewLetterNode.data.gematriaValueWhenEnding && !includedGematriaValues.has(hebrewLetterNode.data.gematriaValueWhenEnding)) {
|
|
2453
|
+
missingGematriaValues.push({
|
|
2454
|
+
value: hebrewLetterNode.data.gematriaValueWhenEnding,
|
|
2455
|
+
hebrewLetter,
|
|
2456
|
+
whenEnding: true
|
|
2428
2457
|
});
|
|
2429
2458
|
}
|
|
2430
2459
|
}
|
|
2431
|
-
|
|
2432
|
-
}
|
|
2433
|
-
const letterPercentages = {
|
|
2434
|
-
percentageOfVowels: 0,
|
|
2435
|
-
percentageOfConsonants: 0,
|
|
2436
|
-
letters: {}
|
|
2437
|
-
};
|
|
2438
|
-
if (options?.calculateLetterPercentage) {
|
|
2439
|
-
const letterCount = letters.length;
|
|
2440
|
-
let vowelsCount = 0;
|
|
2441
|
-
let consonantsCount = 0;
|
|
2442
|
-
for (const [_, letter] of includedLetters) {
|
|
2443
|
-
const occurrences = letters.filter((l) => l === letter.letter).length;
|
|
2444
|
-
letterPercentages.letters[letter.letter] = occurrences / letterCount * 100;
|
|
2445
|
-
if (letter.isVowel) {
|
|
2446
|
-
vowelsCount += occurrences;
|
|
2447
|
-
} else {
|
|
2448
|
-
consonantsCount += occurrences;
|
|
2449
|
-
}
|
|
2450
|
-
}
|
|
2451
|
-
letterPercentages.percentageOfVowels = vowelsCount / letterCount * 100;
|
|
2452
|
-
letterPercentages.percentageOfConsonants = consonantsCount / letterCount * 100;
|
|
2460
|
+
missingGematriaValues.sort((a, b) => a.value - b.value);
|
|
2453
2461
|
}
|
|
2454
2462
|
return {
|
|
2455
2463
|
vowels: {
|
|
@@ -2468,8 +2476,8 @@ var calculateGematria = (word, options = {}, tree) => {
|
|
|
2468
2476
|
finalValue: synthesisReduction.finalValue
|
|
2469
2477
|
},
|
|
2470
2478
|
includedLetters,
|
|
2471
|
-
|
|
2472
|
-
letterPercentages: options?.
|
|
2479
|
+
missingGematriaValues: options?.calculateMissingGematriaValues ? missingGematriaValues : void 0,
|
|
2480
|
+
letterPercentages: options?.calculateLetterPercentages ? letterPercentages : void 0
|
|
2473
2481
|
};
|
|
2474
2482
|
};
|
|
2475
2483
|
export {
|