mirror of https://github.com/tycrek/ass
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
24 lines
903 B
24 lines
903 B
3 years ago
|
const fs = require('fs-extra');
|
||
3 years ago
|
|
||
|
// Don't trigger circular dependency during setup
|
||
|
if (!require.main.filename.includes('setup.js'))
|
||
3 years ago
|
var MIN_LENGTH = require('../setup').gfyIdSize; // skipcq: JS-0239, JS-0102
|
||
3 years ago
|
|
||
3 years ago
|
function getWord(list, delim = '') {
|
||
|
return list[Math.floor(Math.random() * list.length)].concat(delim);
|
||
|
}
|
||
|
|
||
3 years ago
|
function genString(count = MIN_LENGTH) {
|
||
3 years ago
|
// For some reason these 3 lines MUST be inside the function
|
||
|
const { path } = require('../utils');
|
||
|
const adjectives = fs.readFileSync(path('./gfycat/adjectives.txt')).toString().split('\n');
|
||
|
const animals = fs.readFileSync(path('./gfycat/animals.txt')).toString().split('\n');
|
||
|
|
||
3 years ago
|
let gfycat = '';
|
||
3 years ago
|
for (let i = 0; i < (count < MIN_LENGTH ? MIN_LENGTH : count); i++)
|
||
3 years ago
|
gfycat += getWord(adjectives, '-');
|
||
|
return gfycat.concat(getWord(animals));
|
||
3 years ago
|
};
|
||
|
|
||
3 years ago
|
module.exports = ({ gfyLength }) => genString(gfyLength);
|