Skip to content

Commit

Permalink
fix: functions before instalization
Browse files Browse the repository at this point in the history
  • Loading branch information
Dreamyplayer committed Oct 11, 2022
1 parent 6e09059 commit fa9e423
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 23 deletions.
37 changes: 14 additions & 23 deletions src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,9 @@ import { setTimeout } from 'node:timers';
import ProxyAgent from 'proxy-agent';
import { checker } from '../config.js';
import { LogoMain, Welcome } from '../utils/Entry.js';
import { compactMode, wait } from '../utils/funtions.js';
import { compactMode, dbug, formatCode, wait } from '../utils/funtions.js';

const { interval, autoGrabProxies, updateRate, proxy, proxiesType, proxiesfile, debug, codesfile, bURL, params } =
checker;
const { interval, autoGrabProxies, updateRate, proxy, proxiesType, proxiesfile, codesfile, bURL, params } = checker;

let wss;

Expand All @@ -34,6 +33,18 @@ let pause = false;
let pauseLog = 0;
let lastGrab = 0;

const log = e => {
pauseLog
? wait(pauseLog).then(() => {
(pauseLog = 0), log(e);
})
: (console.log(e),
wss &&
clients.forEach(o => {
o.send(JSON.stringify({ type: 'log', message: e.replace(/\[\d{1,2}m/g, '') }));
}));
};

process.on('SIGINT', () => end(performance.now()));

console.clear();
Expand Down Expand Up @@ -67,26 +78,6 @@ wss &&
});
}, updateRate);

const log = e => {
pauseLog
? wait(pauseLog).then(() => {
(pauseLog = 0), log(e);
})
: (console.log(e),
wss &&
clients.forEach(o => {
o.send(JSON.stringify({ type: 'log', message: e.replace(/\[\d{1,2}m/g, '') }));
}));
};

const dbug = o => {
debug && log(`${yellow('[DBUG]')} ${o}`);
};

const formatCode = o => {
return { code: o, c: !1, t: 1 / 0 };
};

const actualizeCodes = async () => {
let e = codes
.filter(e => !e.c || e.c === 'ongoing')
Expand Down
11 changes: 11 additions & 0 deletions utils/funtions.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import { yellow } from 'colorette';
import { checker } from '../config.js';

export const wait = milliseconds => new Promise(resolve => setTimeout(resolve, milliseconds));

export const compactMode = ({ date, formatType = 'Date' }) => {
Expand All @@ -9,3 +12,11 @@ export const compactMode = ({ date, formatType = 'Date' }) => {
export const getRandomInt = (min = 1, max = 15) => {
return Math.floor(Math.random() * (max - min + 1)) + min;
};

export const formatCode = o => {
return { code: o, c: !1, t: 1 / 0 };
};

export const dbug = o => {
checker.debug && console.log(`${yellow('[DBUG]')} ${o}`);
};

0 comments on commit fa9e423

Please sign in to comment.