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