Merge pull request #70 from CodeTorso/codetorso

add js docs
This commit is contained in:
Dhravya Shah 2024-06-17 07:26:58 -05:00 committed by GitHub
commit 5af20f7b6f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
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);