Skip to content

Commit

Permalink
fix: dead code and dead randoms
Browse files Browse the repository at this point in the history
  • Loading branch information
Dreamyplayer committed Oct 10, 2022
1 parent e4b1ed9 commit 3776ff1
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 74 deletions.
45 changes: 45 additions & 0 deletions src/Generator.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import { bgBlue, cyan, green, red } from 'colorette';
import mkdir from 'mkdirp';
import ms from 'ms';
import { createWriteStream, existsSync, unlinkSync } from 'node:fs';
import { generator } from '../config.js';
import { getRan } from '../utils/GenFunctions.js';
import { compactMode, getRandomInt, wait } from '../utils/funtions.js';

const { length, amount, outfile } = generator;

export const gen = (async (N = amount, o = outfile) => {
const l = [];
o && existsSync(o) && unlinkSync(o);
const E = performance.now();
wait(2000).then(() => {
console.log(
`${bgBlue('[Developing]')} ${green(compactMode({ date: N, formatType: 'Number' }))} codes of length ${red(
length,
)}.\n`,
);
});
for (let i = 0; i < N; i++) {
const codesToPush = getRan(getRandomInt());
l.push(codesToPush);
}

const R = performance.now();
if (o) {
await mkdir(o.match(/.*(\/|\\)/g)[0]);
const e = createWriteStream(o, { encoding: 'utf-8' });
e.write(Array.from(new Set(l)).join('\n').toString());
e.close();
}
return { start: E, end: R, codes: l };
})().then(e => {
wait(6000).then(() => {
console.info(
`${bgBlue('[END]')} Coffee Break ${cyan(
e.end - e.start <= 1000 ? (e.end - e.start).toString().split('.')[0] + 'ms' : ms(e.end - e.start),
)} 🍵 - Developed ${green(compactMode({ date: e.codes.length, formatType: 'Number' }))} codes`,
);
});
});
console.clear();
console.log(`${bgBlue('[Establishing]')} Generation. . .\n`);
74 changes: 0 additions & 74 deletions src/gen.js

This file was deleted.

0 comments on commit 3776ff1

Please sign in to comment.