add js docs

This commit is contained in:
codetorso 2024-06-17 06:13:07 -06:00
parent be7165529c
commit 88289d1228
2 changed files with 10 additions and 0 deletions

View file

@ -1,5 +1,8 @@
import nlp from "compromise";
/**
* Split text into chunks of specified max size with some overlap for continuity.
*/
export default function chunkText(
text: string,
maxChunkSize: number,

View file

@ -1,5 +1,9 @@
import { MersenneTwister19937, integer } from "random-js";
/**
* Hashes a string to a 32-bit integer.
* @param {string} seed - The input string to hash.
*/
function hashString(seed: string) {
let hash = 0;
for (let i = 0; i < seed.length; i++) {
@ -10,6 +14,9 @@ function hashString(seed: string) {
return hash;
}
/**
* returns a funtion that generates same sequence of random numbers for a given seed between 0 and 1.
*/
export function seededRandom(seed: string) {
const seedHash = hashString(seed);
const engine = MersenneTwister19937.seed(seedHash);