change args

This commit is contained in:
dervperson 2025-01-31 17:39:47 -05:00
parent e2aa17980b
commit 9a8111224b

11
site.js
View file

@ -4,14 +4,15 @@ import { rankCalc } from "./rank.js";
let cache = {}; let cache = {};
let site = process.env.site || 'darflen'; let site = process.env.site || 'darflen';
let route = process.env.route || './test.txt';
let hh; let hh;
async function textCollector(word, path, file) { async function textCollector(word, path, file) {
if (!hh) hh = await readFile(file,'utf8'); if (!hh) hh = await readFile(file, 'utf8');
hh = hh.toLowerCase(); hh = hh.toLowerCase();
let words = hh.split(/[\n.]+/g).filter(x => word.length == 0 || ` ${x} `.includes(` ${word} `)) ; let words = hh.split(/[\n.]+/g).filter(x => word.length == 0 || ` ${x} `.includes(` ${word} `));
words = words.join(' ').split(/[^a-zA-Z0-9']+/g); words = words.join(' ').split(/[^a-zA-Z0-9']+/g);
words = [...new Set(words)]; words = [...new Set(words)];
return words; return words;
@ -22,8 +23,8 @@ async function siteCollector(user, path, site) {
let i = 1; let i = 1;
let out = []; let out = [];
if (site.startsWith('text_')) { if (site == 'file') {
return await textCollector(user, path, site.split('text_')[1]); return await textCollector(user, path, route);
} }
while (true) { while (true) {
@ -96,7 +97,7 @@ async function siteCollector(user, path, site) {
break; break;
} }
} }
data[u] = {followers: [], following: []}; data[u] = { followers: [], following: [] };
p.push(async function (k) { p.push(async function (k) {
let j1 = await siteCollector(u, 'followers', site); let j1 = await siteCollector(u, 'followers', site);