@elara-services/packages 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.d.ts ADDED
@@ -0,0 +1,94 @@
1
+ declare module "@elara-services/packages" {
2
+ type array = string[];
3
+
4
+ export class AES {
5
+ public constructor(key: string);
6
+ private key: string;
7
+ private header: string;
8
+ public encrypt(input: string): string
9
+ public decrypt(encrypted: string): string;
10
+ }
11
+
12
+ export const Languages: object = "" | {};
13
+ export class Minesweeper {
14
+ public constructor(options?: {
15
+ rows?: number;
16
+ columns?: number;
17
+ mines?: number;
18
+ emote?: string
19
+ });
20
+
21
+ public rows: number;
22
+ public columns: number;
23
+ public mines: number;
24
+ public matrix: array;
25
+ public types: {
26
+ mine: string;
27
+ numbers: array
28
+ };
29
+
30
+ public generateEmptyMatrix(): void;
31
+ public plantMines(): void;
32
+ public getNumberOfMines(x: number, y: number): string;
33
+ public start(): string | array[] | null;
34
+ }
35
+
36
+ export type ChannelTypes = 'GUILD_TEXT' | 'DM' | 'GUILD_VOICE' | 'GROUP_DM' | 'GUILD_CATEGORY' | 'GUILD_NEWS' | 'GUILD_STORE' | 'GUILD_NEWS_THREAD' | 'GUILD_PUBLIC_THREAD' | 'GUILD_PRIVATE_THREAD' | 'GUILD_STAGE_VOICE';
37
+
38
+ export type SlashOptions = {
39
+ type: number;
40
+ name: string;
41
+ description: string;
42
+ required?: boolean;
43
+ channel_types?: ChannelTypes[];
44
+ autocomplete?: boolean;
45
+ min_value?: number;
46
+ max_value?: number;
47
+ choices?: { name: string, value: string }[];
48
+ options?: SlashOptions[];
49
+ };
50
+
51
+ export type Slash = {
52
+ type?: number;
53
+ defaultPermission?: boolean;
54
+ default_permission?: boolean;
55
+ options?: SlashOptions[];
56
+ };
57
+
58
+ export class SlashBuilder {
59
+ public constructor();
60
+ public types: {
61
+ sub_command: number,
62
+ sub_group: number,
63
+ string: number,
64
+ integer: number,
65
+ boolean: number,
66
+ user: number,
67
+ channel: number,
68
+ role: number,
69
+ mentionable: number,
70
+ number: number
71
+ };
72
+
73
+ public context: {
74
+ user(name: string): Slash;
75
+ message(name: string): Slash;
76
+ };
77
+
78
+ public choice(name: string, value: string|number): { name: string, value: string|number };
79
+ public option(data: SlashOptions): Slash;
80
+ public create(name: string, description: string, options: Slash): Slash;
81
+ }
82
+
83
+ export function randomWeight(objects: object[]): object;
84
+ export function randomWords(options?: {
85
+ exactly?: boolean;
86
+ maxLength?: number;
87
+ min?: number;
88
+ max?: number;
89
+ wordsPerString?: number;
90
+ formatter(word: string): void;
91
+ separator: string;
92
+ join: string;
93
+ }): string | string[];
94
+ }
package/index.js ADDED
@@ -0,0 +1,6 @@
1
+ exports.AES = require("./packages/aes256");
2
+ exports.Minesweeper = require("./packages/minesweeper");
3
+ exports.randomWords = require("./packages/random/words");
4
+ exports.randomWeight = require("./packages/random/weight");
5
+ exports.Languages = require("./packages/languages");
6
+ exports.SlashBuilder = require("./packages/SlashBuilder");
package/package.json ADDED
@@ -0,0 +1,10 @@
1
+ {
2
+ "name": "@elara-services/packages",
3
+ "version": "1.0.0",
4
+ "description": "",
5
+ "main": "index.js",
6
+ "types": "./index.d.ts",
7
+ "typings": "./index.d.ts",
8
+ "author": "SUPERCHIEFYT (Elara-Discord-Bots, Elara-Services)",
9
+ "license": "MIT"
10
+ }
@@ -0,0 +1,44 @@
1
+ module.exports = class SlashBuilder {
2
+ constructor() {
3
+ this.TEXT_BASED_CHANNELS = [ 0, 5, 11, 12 ];
4
+ };
5
+
6
+ get types() {
7
+ return {
8
+ sub_command: 1,
9
+ sub_group: 2,
10
+ string: 3,
11
+ integer: 4,
12
+ boolean: 5,
13
+ user: 6,
14
+ channel: 7,
15
+ role: 8,
16
+ mentionable: 9,
17
+ number: 10,
18
+ };
19
+ }
20
+
21
+ get context() {
22
+ return {
23
+ user: (name) => this.create(name, "", { type: 2 }),
24
+ message: (name) => this.create(name, "", { type: 3 })
25
+ }
26
+ };
27
+
28
+ choice(name, value) {
29
+ return { name, value };
30
+ };
31
+
32
+ option(data) {
33
+ return data;
34
+ };
35
+
36
+ create(name, description, options = { }) {
37
+ let obj = { name, description };
38
+ if (options?.options?.length) obj.options = options.options;
39
+ if (options.type) obj.type = options.type;
40
+ if (typeof options.defaultPermission === "boolean") obj.default_permission = options.defaultPermission;
41
+ else if (typeof options.default_permission === "boolean") obj.default_permission = options.default_permission;
42
+ return obj;
43
+ };
44
+ };
@@ -0,0 +1,62 @@
1
+ const crypto = require("node:crypto"),
2
+ CIPHER_ALGORITHM = 'aes-256-ctr';
3
+
4
+ module.exports = class AES256 {
5
+ constructor(key) {
6
+ if (!key || typeof key !== "string") throw new Error(`${this.header} 'key' is invalid or not a string.`);
7
+ /** @private */
8
+ this.key = key;
9
+ };
10
+ /** @private */
11
+ get header() {
12
+ return `[SECURITY]:`;
13
+ };
14
+
15
+ encrypt(input) {
16
+ let isString = typeof input === 'string',
17
+ isBuffer = Buffer.isBuffer(input);
18
+ if (!(isString || isBuffer) || (isString && !input) || (isBuffer && !Buffer.byteLength(input))) {
19
+ throw new Error(`${this.header} Provided invalid 'input', must be a non-empty string or buffer.`);
20
+ };
21
+
22
+ let sha = crypto.createHash("sha256");
23
+ sha.update(this.key);
24
+
25
+ let iv = crypto.randomBytes(16),
26
+ cipher = crypto.createCipheriv(CIPHER_ALGORITHM, sha.digest(), iv),
27
+ buffer = input;
28
+
29
+ if (isString) buffer = Buffer.from(input);
30
+ let text = cipher.update(buffer),
31
+ encrypted = Buffer.concat([ iv, text, cipher.final() ]);
32
+
33
+ if (isString) encrypted = encrypted.toString('base64');
34
+ return encrypted;
35
+ };
36
+
37
+ decrypt(encrypted) {
38
+ let [ isString, isBuffer ] = [
39
+ typeof encrypted === 'string',
40
+ Buffer.isBuffer(encrypted)
41
+ ];
42
+ if (!(isString || isBuffer) || (isString && !encrypted) || (isBuffer && !Buffer.byteLength(encrypted))) throw new Error(`${this.header} Provided "encrypted" must be a non-empty string or buffer`);
43
+ let sha256 = crypto.createHash('sha256');
44
+ sha256.update(this.key);
45
+
46
+ let input = encrypted;
47
+ if (isString) {
48
+ input = Buffer.from(encrypted, 'base64');
49
+ if (input.length < 17) throw new Error(`${this.header} Provided "encrypted" must decrypt to a non-empty string or buffer`);
50
+ } else {
51
+ if (Buffer.byteLength(encrypted) < 17) throw new Error(`${this.header} Provided "encrypted" must decrypt to a non-empty string or buffer`);
52
+ }
53
+
54
+ let iv = input.slice(0, 16),
55
+ decipher = crypto.createDecipheriv(CIPHER_ALGORITHM, sha256.digest(), iv),
56
+ ciphertext = input.slice(16),
57
+ output;
58
+ if (isString) output = decipher.update(ciphertext) + decipher.final();
59
+ else output = Buffer.concat([decipher.update(ciphertext), decipher.final()]);
60
+ return output;
61
+ };
62
+ };
@@ -0,0 +1,108 @@
1
+ module.exports = {
2
+ 'en': 'English',
3
+ 'fr': 'French',
4
+ 'es': 'Spanish',
5
+ 'pt': 'Portuguese',
6
+ 'tr': 'Turkish',
7
+ 'ru': 'Russian',
8
+ 'ar': 'Arabic',
9
+
10
+ 'af': 'Afrikaans',
11
+ 'sq': 'Albanian',
12
+ 'am': 'Amharic',
13
+ 'hy': 'Armenian',
14
+ 'az': 'Azerbaijani',
15
+ 'eu': 'Basque',
16
+ 'be': 'Belarusian',
17
+ 'bn': 'Bengali',
18
+ 'bs': 'Bosnian',
19
+ 'bg': 'Bulgarian',
20
+ 'ca': 'Catalan',
21
+ 'ceb': 'Cebuano',
22
+ 'ny': 'Chichewa',
23
+ 'zh': 'Chinese (Simplified)',
24
+ 'zh-tw': 'Chinese (Traditional)',
25
+ 'co': 'Corsican',
26
+ 'hr': 'Croatian',
27
+ 'cs': 'Czech',
28
+ 'da': 'Danish',
29
+ 'nl': 'Dutch',
30
+ 'eo': 'Esperanto',
31
+ 'et': 'Estonian',
32
+ 'tl': 'Filipino',
33
+ 'fi': 'Finnish',
34
+ 'fy': 'Frisian',
35
+ 'gl': 'Galician',
36
+ 'ka': 'Georgian',
37
+ 'de': 'German',
38
+ 'el': 'Greek',
39
+ 'gu': 'Gujarati',
40
+ 'ht': 'Haitian Creole',
41
+ 'ha': 'Hausa',
42
+ 'haw': 'Hawaiian',
43
+ 'he': 'Hebrew',
44
+ 'iw': 'Hebrew',
45
+ 'hi': 'Hindi',
46
+ 'hmn': 'Hmong',
47
+ 'hu': 'Hungarian',
48
+ 'is': 'Icelandic',
49
+ 'ig': 'Igbo',
50
+ 'id': 'Indonesian',
51
+ 'ga': 'Irish',
52
+ 'it': 'Italian',
53
+ 'ja': 'Japanese',
54
+ 'jw': 'Javanese',
55
+ 'kn': 'Kannada',
56
+ 'kk': 'Kazakh',
57
+ 'km': 'Khmer',
58
+ 'ko': 'Korean',
59
+ 'ku': 'Kurdish (Kurmanji)',
60
+ 'ky': 'Kyrgyz',
61
+ 'lo': 'Lao',
62
+ 'la': 'Latin',
63
+ 'lv': 'Latvian',
64
+ 'lt': 'Lithuanian',
65
+ 'lb': 'Luxembourgish',
66
+ 'mk': 'Macedonian',
67
+ 'mg': 'Malagasy',
68
+ 'ms': 'Malay',
69
+ 'ml': 'Malayalam',
70
+ 'mt': 'Maltese',
71
+ 'mi': 'Maori',
72
+ 'mr': 'Marathi',
73
+ 'mn': 'Mongolian',
74
+ 'my': 'Myanmar (Burmese)',
75
+ 'ne': 'Nepali',
76
+ 'no': 'Norwegian',
77
+ 'ps': 'Pashto',
78
+ 'fa': 'Persian',
79
+ 'pl': 'Polish',
80
+ 'pa': 'Punjabi',
81
+ 'ro': 'Romanian',
82
+ 'sm': 'Samoan',
83
+ 'gd': 'Scots Gaelic',
84
+ 'sr': 'Serbian',
85
+ 'st': 'Sesotho',
86
+ 'sn': 'Shona',
87
+ 'sd': 'Sindhi',
88
+ 'si': 'Sinhala',
89
+ 'sk': 'Slovak',
90
+ 'sl': 'Slovenian',
91
+ 'so': 'Somali',
92
+ 'su': 'Sundanese',
93
+ 'sw': 'Swahili',
94
+ 'sv': 'Swedish',
95
+ 'tg': 'Tajik',
96
+ 'ta': 'Tamil',
97
+ 'te': 'Telugu',
98
+ 'th': 'Thai',
99
+ 'uk': 'Ukrainian',
100
+ 'ur': 'Urdu',
101
+ 'uz': 'Uzbek',
102
+ 'vi': 'Vietnamese',
103
+ 'cy': 'Welsh',
104
+ 'xh': 'Xhosa',
105
+ 'yi': 'Yiddish',
106
+ 'yo': 'Yoruba',
107
+ 'zu': 'Zulu'
108
+ };
@@ -0,0 +1,77 @@
1
+ module.exports = class Minesweeper {
2
+ /**
3
+ * The constructor of the Minesweeper class.
4
+ * @constructor
5
+ * @param {MinesweeperOpts} opts - The options of the Minesweeper class.
6
+ */
7
+ constructor(opts) {
8
+ this.rows = opts?.rows ?? 5;
9
+ this.columns = opts?.columns ?? 5;
10
+ this.mines = opts?.mines ?? 5;
11
+ this.matrix = [];
12
+ this.types = {
13
+ mine: opts?.emote ?? "bomb",
14
+ numbers: [
15
+ 'zero', 'one', 'two',
16
+ 'three', 'four', 'five',
17
+ 'six', 'seven', 'eight'
18
+ ]
19
+ };
20
+ }
21
+
22
+ /**
23
+ * Fills the matrix with "zero" emojis.
24
+ */
25
+ generateEmptyMatrix() {
26
+ for (let i = 0; i < this.rows; i++) {
27
+ const arr = new Array(this.columns).fill(this.types.numbers[0]);
28
+ this.matrix.push(arr);
29
+ }
30
+ }
31
+ /**
32
+ * Plants mines in the matrix randomly.
33
+ */
34
+ plantMines() {
35
+ for (let i = 0; i < this.mines; i++) {
36
+ const x = Math.floor(Math.random() * this.rows);
37
+ const y = Math.floor(Math.random() * this.columns);
38
+ if (this.matrix[x][y] === this.types.mine) i--;
39
+ else this.matrix[x][y] = this.types.mine;
40
+ }
41
+ }
42
+ /**
43
+ * Gets the number of mines in a particular (x, y) coordinate
44
+ * of the matrix.
45
+ * @param {number} x - The x coordinate (row).
46
+ * @param {number} y - The y coordinate (column).
47
+ * @returns {string}
48
+ */
49
+ getNumberOfMines(x, y) {
50
+ if (this.matrix[x][y] === this.types.mine) return this.types.mine;
51
+ let counter = 0;
52
+ const hasLeft = y > 0;
53
+ const hasRight = y < (this.columns - 1);
54
+ const hasTop = x > 0;
55
+ const hasBottom = x < (this.rows - 1);
56
+ counter += +(hasTop && hasLeft && this.matrix[x - 1][y - 1] === this.types.mine);
57
+ counter += +(hasTop && this.matrix[x - 1][y] === this.types.mine);
58
+ counter += +(hasTop && hasRight && this.matrix[x - 1][y + 1] === this.types.mine);
59
+ counter += +(hasLeft && this.matrix[x][y - 1] === this.types.mine);
60
+ counter += +(hasRight && this.matrix[x][y + 1] === this.types.mine);
61
+ counter += +(hasBottom && hasLeft && this.matrix[x + 1][y - 1] === this.types.mine);
62
+ counter += +(hasBottom && this.matrix[x + 1][y] === this.types.mine);
63
+ counter += +(hasBottom && hasRight && this.matrix[x + 1][y + 1] === this.types.mine);
64
+ return this.types.numbers[counter];
65
+ }
66
+
67
+ /**
68
+ * Generates a minesweeper mine field and returns it.
69
+ * @returns {(string | string[][] | null)}
70
+ */
71
+ start() {
72
+ if (this.rows * this.columns <= this.mines * 2) return null;
73
+ for (const n of [ "generateEmptyMatrix", "plantMines" ]) this[n]();
74
+ this.matrix = this.matrix.map((row, x) => row.map((col, y) => this.getNumberOfMines(x, y)));
75
+ return this.matrix;
76
+ }
77
+ };
@@ -0,0 +1,8 @@
1
+ module.exports = (objects) => {
2
+ let randomNumber = Math.random() * objects.reduce((agg, object) => agg + object.weight, 0),
3
+ weightSum = 0;
4
+ return objects.find(o => {
5
+ weightSum += o.weight;
6
+ return randomNumber <= weightSum;
7
+ });
8
+ }
@@ -0,0 +1,300 @@
1
+ let wordList = [
2
+ "ability","able","aboard","about","above","accept","accident","according",
3
+ "account","accurate","acres","across","act","action","active","activity",
4
+ "actual","actually","add","addition","additional","adjective","adult","adventure",
5
+ "advice","affect","afraid","after","afternoon","again","against","age",
6
+ "ago","agree","ahead","aid","air","airplane","alike","alive",
7
+ "all","allow","almost","alone","along","aloud","alphabet","already",
8
+ "also","although","am","among","amount","ancient","angle","angry",
9
+ "animal","announced","another","answer","ants","any","anybody","anyone",
10
+ "anything","anyway","anywhere","apart","apartment","appearance","apple","applied",
11
+ "appropriate","are","area","arm","army","around","arrange","arrangement",
12
+ "arrive","arrow","art","article","as","aside","ask","asleep",
13
+ "at","ate","atmosphere","atom","atomic","attached","attack","attempt",
14
+ "attention","audience","author","automobile","available","average","avoid","aware",
15
+ "away","baby","back","bad","badly","bag","balance","ball",
16
+ "balloon","band","bank","bar","bare","bark","barn","base",
17
+ "baseball","basic","basis","basket","bat","battle","be","bean",
18
+ "bear","beat","beautiful","beauty","became","because","become","becoming",
19
+ "bee","been","before","began","beginning","begun","behavior","behind",
20
+ "being","believed","bell","belong","below","belt","bend","beneath",
21
+ "bent","beside","best","bet","better","between","beyond","bicycle",
22
+ "bigger","biggest","bill","birds","birth","birthday","bit","bite",
23
+ "black","blank","blanket","blew","blind","block","blood","blow",
24
+ "blue","board","boat","body","bone","book","border","born",
25
+ "both","bottle","bottom","bound","bow","bowl","box","boy",
26
+ "brain","branch","brass","brave","bread","break","breakfast","breath",
27
+ "breathe","breathing","breeze","brick","bridge","brief","bright","bring",
28
+ "broad","broke","broken","brother","brought","brown","brush","buffalo",
29
+ "build","building","built","buried","burn","burst","bus","bush",
30
+ "business","busy","but","butter","buy","by","cabin","cage",
31
+ "cake","call","calm","came","camera","camp","can","canal",
32
+ "cannot","cap","capital","captain","captured","car","carbon","card",
33
+ "care","careful","carefully","carried","carry","case","cast","castle",
34
+ "cat","catch","cattle","caught","cause","cave","cell","cent",
35
+ "center","central","century","certain","certainly","chain","chair","chamber",
36
+ "chance","change","changing","chapter","character","characteristic","charge","chart",
37
+ "check","cheese","chemical","chest","chicken","chief","child","children",
38
+ "choice","choose","chose","chosen","church","circle","circus","citizen",
39
+ "city","class","classroom","claws","clay","clean","clear","clearly",
40
+ "climate","climb","clock","close","closely","closer","cloth","clothes",
41
+ "clothing","cloud","club","coach","coal","coast","coat","coffee",
42
+ "cold","collect","college","colony","color","column","combination","combine",
43
+ "come","comfortable","coming","command","common","community","company","compare",
44
+ "compass","complete","completely","complex","composed","composition","compound","concerned",
45
+ "condition","congress","connected","consider","consist","consonant","constantly","construction",
46
+ "contain","continent","continued","contrast","control","conversation","cook","cookies",
47
+ "cool","copper","copy","corn","corner","correct","correctly","cost",
48
+ "cotton","could","count","country","couple","courage","course","court",
49
+ "cover","cow","cowboy","crack","cream","create","creature","crew",
50
+ "crop","cross","crowd","cry","cup","curious","current","curve",
51
+ "customs","cut","cutting","daily","damage","dance","danger","dangerous",
52
+ "dark","darkness","date","daughter","dawn","day","dead","deal",
53
+ "dear","death","decide","declared","deep","deeply","deer","definition",
54
+ "degree","depend","depth","describe","desert","design","desk","detail",
55
+ "determine","develop","development","diagram","diameter","did","die","differ",
56
+ "difference","different","difficult","difficulty","dig","dinner","direct","direction",
57
+ "directly","dirt","dirty","disappear","discover","discovery","discuss","discussion",
58
+ "disease","dish","distance","distant","divide","division","do","doctor",
59
+ "does","dog","doing","doll","dollar","done","donkey","door",
60
+ "dot","double","doubt","down","dozen","draw","drawn","dream",
61
+ "dress","drew","dried","drink","drive","driven","driver","driving",
62
+ "drop","dropped","drove","dry","duck","due","dug","dull",
63
+ "during","dust","duty","each","eager","ear","earlier","early",
64
+ "earn","earth","easier","easily","east","easy","eat","eaten",
65
+ "edge","education","effect","effort","egg","eight","either","electric",
66
+ "electricity","element","elephant","eleven","else","empty","end","enemy",
67
+ "energy","engine","engineer","enjoy","enough","enter","entire","entirely",
68
+ "environment","equal","equally","equator","equipment","escape","especially","essential",
69
+ "establish","even","evening","event","eventually","ever","every","everybody",
70
+ "everyone","everything","everywhere","evidence","exact","exactly","examine","example",
71
+ "excellent","except","exchange","excited","excitement","exciting","exclaimed","exercise",
72
+ "exist","expect","experience","experiment","explain","explanation","explore","express",
73
+ "expression","extra","eye","face","facing","fact","factor","factory",
74
+ "failed","fair","fairly","fall","fallen","familiar","family","famous",
75
+ "far","farm","farmer","farther","fast","fastened","faster","fat",
76
+ "father","favorite","fear","feathers","feature","fed","feed","feel",
77
+ "feet","fell","fellow","felt","fence","few","fewer","field",
78
+ "fierce","fifteen","fifth","fifty","fight","fighting","figure","fill",
79
+ "film","final","finally","find","fine","finest","finger","finish",
80
+ "fire","fireplace","firm","first","fish","five","fix","flag",
81
+ "flame","flat","flew","flies","flight","floating","floor","flow",
82
+ "flower","fly","fog","folks","follow","food","foot","football",
83
+ "for","force","foreign","forest","forget","forgot","forgotten","form",
84
+ "former","fort","forth","forty","forward","fought","found","four",
85
+ "fourth","fox","frame","free","freedom","frequently","fresh","friend",
86
+ "friendly","frighten","frog","from","front","frozen","fruit","fuel",
87
+ "full","fully","fun","function","funny","fur","furniture","further",
88
+ "future","gain","game","garage","garden","gas","gasoline","gate",
89
+ "gather","gave","general","generally","gentle","gently","get","getting",
90
+ "giant","gift","girl","give","given","giving","glad","glass",
91
+ "globe","go","goes","gold","golden","gone","good","goose",
92
+ "got","government","grabbed","grade","gradually","grain","grandfather","grandmother",
93
+ "graph","grass","gravity","gray","great","greater","greatest","greatly",
94
+ "green","grew","ground","group","grow","grown","growth","guard",
95
+ "guess","guide","gulf","gun","habit","had","hair","half",
96
+ "halfway","hall","hand","handle","handsome","hang","happen","happened",
97
+ "happily","happy","harbor","hard","harder","hardly","has","hat",
98
+ "have","having","hay","he","headed","heading","health","heard",
99
+ "hearing","heart","heat","heavy","height","held","hello","help",
100
+ "helpful","her","herd","here","herself","hidden","hide","high",
101
+ "higher","highest","highway","hill","him","himself","his","history",
102
+ "hit","hold","hole","hollow","home","honor","hope","horn",
103
+ "horse","hospital","hot","hour","house","how","however","huge",
104
+ "human","hundred","hung","hungry","hunt","hunter","hurried","hurry",
105
+ "hurt","husband","ice","idea","identity","if","ill","image",
106
+ "imagine","immediately","importance","important","impossible","improve","in","inch",
107
+ "include","including","income","increase","indeed","independent","indicate","individual",
108
+ "industrial","industry","influence","information","inside","instance","instant","instead",
109
+ "instrument","interest","interior","into","introduced","invented","involved","iron",
110
+ "is","island","it","its","itself","jack","jar","jet",
111
+ "job","join","joined","journey","joy","judge","jump","jungle",
112
+ "just","keep","kept","key","kids","kill","kind","kitchen",
113
+ "knew","knife","know","knowledge","known","label","labor","lack",
114
+ "lady","laid","lake","lamp","land","language","large","larger",
115
+ "largest","last","late","later","laugh","law","lay","layers",
116
+ "lead","leader","leaf","learn","least","leather","leave","leaving",
117
+ "led","left","leg","length","lesson","let","letter","level",
118
+ "library","lie","life","lift","light","like","likely","limited",
119
+ "line","lion","lips","liquid","list","listen","little","live",
120
+ "living","load","local","locate","location","log","lonely","long",
121
+ "longer","look","loose","lose","loss","lost","lot","loud",
122
+ "love","lovely","low","lower","luck","lucky","lunch","lungs",
123
+ "lying","machine","machinery","mad","made","magic","magnet","mail",
124
+ "main","mainly","major","make","making","man","managed","manner",
125
+ "manufacturing","many","map","mark","market","married","mass","massage",
126
+ "master","material","mathematics","matter","may","maybe","me","meal",
127
+ "mean","means","meant","measure","meat","medicine","meet","melted",
128
+ "member","memory","men","mental","merely","met","metal","method",
129
+ "mice","middle","might","mighty","mile","military","milk","mill",
130
+ "mind","mine","minerals","minute","mirror","missing","mission","mistake",
131
+ "mix","mixture","model","modern","molecular","moment","money","monkey",
132
+ "month","mood","moon","more","morning","most","mostly","mother",
133
+ "motion","motor","mountain","mouse","mouth","move","movement","movie",
134
+ "moving","mud","muscle","music","musical","must","my","myself",
135
+ "mysterious","nails","name","nation","national","native","natural","naturally",
136
+ "nature","near","nearby","nearer","nearest","nearly","necessary","neck",
137
+ "needed","needle","needs","negative","neighbor","neighborhood","nervous","nest",
138
+ "never","new","news","newspaper","next","nice","night","nine",
139
+ "no","nobody","nodded","noise","none","noon","nor","north",
140
+ "nose","not","note","noted","nothing","notice","noun","now",
141
+ "number","numeral","nuts","object","observe","obtain","occasionally","occur",
142
+ "ocean","of","off","offer","office","officer","official","oil",
143
+ "old","older","oldest","on","once","one","only","onto",
144
+ "open","operation","opinion","opportunity","opposite","or","orange","orbit",
145
+ "order","ordinary","organization","organized","origin","original","other","ought",
146
+ "our","ourselves","out","outer","outline","outside","over","own",
147
+ "owner","oxygen","pack","package","page","paid","pain","paint",
148
+ "pair","palace","pale","pan","paper","paragraph","parallel","parent",
149
+ "park","part","particles","particular","particularly","partly","parts","party",
150
+ "pass","passage","past","path","pattern","pay","peace","pen",
151
+ "pencil","people","per","percent","perfect","perfectly","perhaps","period",
152
+ "person","personal","pet","phrase","physical","piano","pick","picture",
153
+ "pictured","pie","piece","pig","pile","pilot","pine","pink",
154
+ "pipe","pitch","place","plain","plan","plane","planet","planned",
155
+ "planning","plant","plastic","plate","plates","play","pleasant","please",
156
+ "pleasure","plenty","plural","plus","pocket","poem","poet","poetry",
157
+ "point","pole","police","policeman","political","pond","pony","pool",
158
+ "poor","popular","population","porch","port","position","positive","possible",
159
+ "possibly","post","pot","potatoes","pound","pour","powder","power",
160
+ "powerful","practical","practice","prepare","present","president","press","pressure",
161
+ "pretty","prevent","previous","price","pride","primitive","principal","principle",
162
+ "printed","private","prize","probably","problem","process","produce","product",
163
+ "production","program","progress","promised","proper","properly","property","protection",
164
+ "proud","prove","provide","public","pull","pupil","pure","purple",
165
+ "purpose","push","put","putting","quarter","queen","question","quick",
166
+ "quickly","quiet","quietly","quite","rabbit","race","radio","railroad",
167
+ "rain","raise","ran","ranch","range","rapidly","rate","rather",
168
+ "raw","rays","reach","read","reader","ready","real","realize",
169
+ "rear","reason","recall","receive","recent","recently","recognize","record",
170
+ "red","refer","refused","region","regular","related","relationship","religious",
171
+ "remain","remarkable","remember","remove","repeat","replace","replied","report",
172
+ "represent","require","research","respect","rest","result","return","review",
173
+ "rhyme","rhythm","rice","rich","ride","riding","right","ring",
174
+ "rise","rising","river","road","roar","rock","rocket","rocky",
175
+ "rod","roll","roof","room","root","rope","rose","rough",
176
+ "round","route","row","rubbed","rubber","rule","ruler","run",
177
+ "running","rush","sad","saddle","safe","safety","said","sail",
178
+ "sale","salmon","salt","same","sand","sang","sat","satellites",
179
+ "satisfied","save","saved","saw","say","scale","scared","scene",
180
+ "school","science","scientific","scientist","score","screen","sea","search",
181
+ "season","seat","second","secret","section","see","seed","seeing",
182
+ "seems","seen","seldom","select","selection","sell","send","sense",
183
+ "sent","sentence","separate","series","serious","serve","service","sets",
184
+ "setting","settle","settlers","seven","several","shade","shadow","shake",
185
+ "shaking","shall","shallow","shape","share","sharp","she","sheep",
186
+ "sheet","shelf","shells","shelter","shine","shinning","ship","shirt",
187
+ "shoe","shoot","shop","shore","short","shorter","shot","should",
188
+ "shoulder","shout","show","shown","shut","sick","sides","sight",
189
+ "sign","signal","silence","silent","silk","silly","silver","similar",
190
+ "simple","simplest","simply","since","sing","single","sink","sister",
191
+ "sit","sitting","situation","six","size","skill","skin","sky",
192
+ "slabs","slave","sleep","slept","slide","slight","slightly","slip",
193
+ "slipped","slope","slow","slowly","small","smaller","smallest","smell",
194
+ "smile","smoke","smooth","snake","snow","so","soap","social",
195
+ "society","soft","softly","soil","solar","sold","soldier","solid",
196
+ "solution","solve","some","somebody","somehow","someone","something","sometime",
197
+ "somewhere","son","song","soon","sort","sound","source","south",
198
+ "southern","space","speak","special","species","specific","speech","speed",
199
+ "spell","spend","spent","spider","spin","spirit","spite","split",
200
+ "spoken","sport","spread","spring","square","stage","stairs","stand",
201
+ "standard","star","stared","start","state","statement","station","stay",
202
+ "steady","steam","steel","steep","stems","step","stepped","stick",
203
+ "stiff","still","stock","stomach","stone","stood","stop","stopped",
204
+ "store","storm","story","stove","straight","strange","stranger","straw",
205
+ "stream","street","strength","stretch","strike","string","strip","strong",
206
+ "stronger","struck","structure","struggle","stuck","student","studied","studying",
207
+ "subject","substance","success","successful","such","sudden","suddenly","sugar",
208
+ "suggest","suit","sum","summer","sun","sunlight","supper","supply",
209
+ "support","suppose","sure","surface","surprise","surrounded","swam","sweet",
210
+ "swept","swim","swimming","swing","swung","syllable","symbol","system",
211
+ "table","tail","take","taken","tales","talk","tall","tank",
212
+ "tape","task","taste","taught","tax","tea","teach","teacher",
213
+ "team","tears","teeth","telephone","television","tell","temperature","ten",
214
+ "tent","term","terrible","test","than","thank","that","thee",
215
+ "them","themselves","then","theory","there","therefore","these","they",
216
+ "thick","thin","thing","think","third","thirty","this","those",
217
+ "thou","though","thought","thousand","thread","three","threw","throat",
218
+ "through","throughout","throw","thrown","thumb","thus","thy","tide",
219
+ "tie","tight","tightly","till","time","tin","tiny","tip",
220
+ "tired","title","to","tobacco","today","together","told","tomorrow",
221
+ "tone","tongue","tonight","too","took","tool","top","topic",
222
+ "torn","total","touch","toward","tower","town","toy","trace",
223
+ "track","trade","traffic","trail","train","transportation","trap","travel",
224
+ "treated","tree","triangle","tribe","trick","tried","trip","troops",
225
+ "tropical","trouble","truck","trunk","truth","try","tube","tune",
226
+ "turn","twelve","twenty","twice","two","type","typical","uncle",
227
+ "under","underline","understanding","unhappy","union","unit","universe","unknown",
228
+ "unless","until","unusual","up","upon","upper","upward","us",
229
+ "use","useful","using","usual","usually","valley","valuable","value",
230
+ "vapor","variety","various","vast","vegetable","verb","vertical","very",
231
+ "vessels","victory","view","village","visit","visitor","voice","volume",
232
+ "vote","vowel","voyage","wagon","wait","walk","wall","want",
233
+ "war","warm","warn","was","wash","waste","watch","water",
234
+ "wave","way","we","weak","wealth","wear","weather","week",
235
+ "weigh","weight","welcome","well","went","were","west","western",
236
+ "wet","whale","what","whatever","wheat","wheel","when","whenever",
237
+ "where","wherever","whether","which","while","whispered","whistle","white",
238
+ "who","whole","whom","whose","why","wide","widely","wife",
239
+ "wild","will","willing","win","wind","window","wing","winter",
240
+ "wire","wise","wish","with","within","without","wolf","women",
241
+ "won","wonder","wonderful","wood","wooden","wool","word","wore",
242
+ "work","worker","world","worried","worry","worse","worth","would",
243
+ "wrapped","write","writer","writing","written","wrong","wrote","yard",
244
+ "year","yellow","yes","yesterday","yet","you","young","younger",
245
+ "your","yourself","youth","zero","zebra","zipper","zoo","zulu"
246
+ ];
247
+
248
+ module.exports = (options) => {
249
+
250
+ const [
251
+ randInt, generateRandomWord, generateWordWithMaxLength,
252
+ ] = [
253
+ (less) => Math.floor(Math.random() * less),
254
+ () => wordList[randInt(wordList.length)],
255
+ () => {
256
+ let [ rightSize, wordUsed ] = [ false, undefined ];
257
+ while (!rightSize) {
258
+ wordUsed = generateRandomWord();
259
+ if(wordUsed.length <= options.maxLength) rightSize = true;
260
+ }
261
+ return wordUsed;
262
+ }
263
+ ],
264
+ word = () => {
265
+ if (options && options.maxLength > 1) return generateWordWithMaxLength();
266
+ else return generateRandomWord();
267
+ }
268
+ if (!options) return word();
269
+ if (typeof options === "number") options = { exactly: options };
270
+
271
+ if (options.exactly) {
272
+ options.min = options.exactly;
273
+ options.max = options.exactly;
274
+ }
275
+
276
+ if (typeof options.wordsPerString !== 'number') options.wordsPerString = 1;
277
+ if (typeof options.formatter !== 'function') options.formatter = (word) => word;
278
+ if (typeof options.separator !== 'string') options.separator = ' ';
279
+ let [ total, results, token, relativeIndex ] = [
280
+ options.min + randInt((options.max + 1) - options.min),
281
+ [],
282
+ "",
283
+ 0
284
+ ]
285
+
286
+ for (let i = 0; (i < total * options.wordsPerString); i++) {
287
+ if (relativeIndex === options.wordsPerString - 1) token += options.formatter(word(), relativeIndex);
288
+ else token += options.formatter(word(), relativeIndex) + options.separator;
289
+ relativeIndex++;
290
+ if ((i + 1) % options.wordsPerString === 0) {
291
+ results.push(token);
292
+ token = '';
293
+ relativeIndex = 0;
294
+ }
295
+
296
+ }
297
+ if (typeof options.join === 'string') results = results.join(options.join);
298
+
299
+ return results;
300
+ };