mirror of https://github.com/tycrek/ass
parent
efe3440903
commit
ecdebf73ad
@ -1,19 +1,17 @@
|
||||
const fs = require('fs-extra');
|
||||
const adjectiveList = fs.readFileSync("./generators/gfycat/adjectives.txt", "utf-8").split('\n');
|
||||
const animalsList = fs.readFileSync("./generators/gfycat/animals.txt", "utf-8").split('\n');
|
||||
const adjectives = fs.readFileSync('./generators/gfycat/adjectives.txt').toString().split('\n');
|
||||
const animals = fs.readFileSync('./generators/gfycat/animals.txt').toString().split('\n');
|
||||
const MIN_LENGTH = require('../setup').gfyIdSize;
|
||||
|
||||
function genString(adjCount) {
|
||||
let adjectivesString = "";
|
||||
for (i = 0; i < adjCount; i++) adjectivesString += genAdjective();
|
||||
return adjectivesString + genAnimal();
|
||||
function genString(count = MIN_LENGTH) {
|
||||
let gfycat = '';
|
||||
for (i = 0; i < (count < MIN_LENGTH ? MIN_LENGTH : count); i++)
|
||||
gfycat += getWord(adjectives, '-');
|
||||
return gfycat.concat(getWord(animals));
|
||||
};
|
||||
|
||||
function genAnimal() {
|
||||
return animalsList[Math.floor(Math.random()*animalsList.length)];
|
||||
function getWord(list, delim = '') {
|
||||
return list[Math.floor(Math.random() * list.length)].concat(delim);
|
||||
}
|
||||
|
||||
function genAdjective() {
|
||||
return adjectiveList[Math.floor(Math.random()*adjectiveList.length)] + "-";
|
||||
}
|
||||
|
||||
module.exports = (adjectives) => genString(adjectives);
|
||||
module.exports = ({ gfyLength }) => genString(gfyLength);
|
||||
|
@ -1,2 +1,2 @@
|
||||
const cryptoRandomString = require('crypto-random-string');
|
||||
module.exports = (length) => cryptoRandomString({ length, type: 'alphanumeric' });
|
||||
module.exports = ({ length }) => cryptoRandomString({ length, type: 'alphanumeric' });
|
||||
|
@ -1,3 +1,3 @@
|
||||
const { randomBytes } = require('crypto');
|
||||
const zeroWidthChars = ['\u200B', '\u200C', '\u200D', '\u2060'];
|
||||
module.exports = (size) => [...randomBytes(size)].map(byte => zeroWidthChars[+byte % zeroWidthChars.length]).join('').slice(1) + zeroWidthChars[0];
|
||||
module.exports = ({ length }) => [...randomBytes(length)].map(byte => zeroWidthChars[+byte % zeroWidthChars.length]).join('').slice(1) + zeroWidthChars[0];
|
||||
|
Loading…
Reference in new issue