]> git.ardis.lu - random-word-generator/commitdiff
Run autoformatter
authorArdis Lu <ardisglu@gmail.com>
Wed, 6 Jul 2022 02:16:25 +0000 (19:16 -0700)
committerArdis Lu <ardisglu@gmail.com>
Wed, 6 Jul 2022 02:20:18 +0000 (19:20 -0700)
README.md
main.ts

index 1591739de6a0eec410094d3503b2b0717443f07a..4960ffe2ddd119ee44bead41a0d8ac84269ad27f 100644 (file)
--- a/README.md
+++ b/README.md
@@ -1,30 +1,51 @@
 # random-word-generator
 
-A [Deno](https://deno.land/) CLI which returns a string of random words from a given word list.
+A [Deno](https://deno.land/) CLI which returns a string of random words from a
+given word list.
 
 ```
 > deno run --allow-read ./main.ts
 > cheeking-signs-riches
 ```
 
-Similar to [unique-names-generator](https://github.com/andreasonny83/unique-names-generator).
+Similar to
+[unique-names-generator](https://github.com/andreasonny83/unique-names-generator).
 
 ## Flags
-- `--words`: path to a word list file where each word is delimited by a newline. Default value is `./words/xkcd.txt`.
-- `--separator`: a character to insert in between each word in the output. If multiple characters are provided, a random character is picked for each separator. Default value is `-`.
+
+- `--words`: path to a word list file where each word is delimited by a newline.
+  Default value is `./words/xkcd.txt`.
+- `--separator`: a character to insert in between each word in the output. If
+  multiple characters are provided, a random character is picked for each
+  separator. Default value is `-`.
 - `--length`: the number of words to output. Default value is `3`.
 
 ## Included word lists
-- `xkcd.txt`: the dictionary for [XKCD](https://xkcd.com/)'s [Simple Writer](https://xkcd.com/simplewriter/), [Up Goer Five](https://xkcd.com/1133/), and [Thing Explainer](https://blog.xkcd.com/2015/05/13/new-book-thing-explainer/), minus contractions.
-- `google-10000.txt`: the top 10,000 most common English words from [Google's Trillion Word Corpus](https://books.google.com/ngrams/info), minus swear words.
-- `left-hand-only.txt`: the subset of `google-10000.txt` which only contains the words which can be typed using only the left hand on a QWERTY keyboard.
-- `gfycat.txt`: the adjectives and animal names that [gfycat](https://gfycat.com/) uses to generate URLs.
-- `bip39.txt`: the word list used to make [BIP39 mnemonic phrases](https://github.com/bitcoin/bips/blob/master/bip-0039.mediawiki) for generating Bitcoin wallets.
-- `echohash.txt`: the word list used for Gemini's [Echo Hash](https://echohash.net/) utility, which transforms a hash into an English phrase.
+
+- `xkcd.txt`: the dictionary for [XKCD](https://xkcd.com/)'s
+  [Simple Writer](https://xkcd.com/simplewriter/),
+  [Up Goer Five](https://xkcd.com/1133/), and
+  [Thing Explainer](https://blog.xkcd.com/2015/05/13/new-book-thing-explainer/),
+  minus contractions.
+- `google-10000.txt`: the top 10,000 most common English words from
+  [Google's Trillion Word Corpus](https://books.google.com/ngrams/info), minus
+  swear words.
+- `left-hand-only.txt`: the subset of `google-10000.txt` which only contains the
+  words which can be typed using only the left hand on a QWERTY keyboard.
+- `gfycat.txt`: the adjectives and animal names that
+  [gfycat](https://gfycat.com/) uses to generate URLs.
+- `bip39.txt`: the word list used to make
+  [BIP39 mnemonic phrases](https://github.com/bitcoin/bips/blob/master/bip-0039.mediawiki)
+  for generating Bitcoin wallets.
+- `echohash.txt`: the word list used for Gemini's
+  [Echo Hash](https://echohash.net/) utility, which transforms a hash into an
+  English phrase.
 
 ## Word list sources
+
 - [XKCD Simple Writer Word List](https://xkcd.com/simplewriter/words.js)
 - [first20hours/google-10000-english](https://github.com/first20hours/google-10000-english)
-- [gfycat adjectives](http://assets.gfycat.com/adjectives) and [gfycat animals](http://assets.gfycat.com/animals)
+- [gfycat adjectives](http://assets.gfycat.com/adjectives) and
+  [gfycat animals](http://assets.gfycat.com/animals)
 - [BIP39 English word list](https://github.com/bitcoin/bips/blob/master/bip-0039/english.txt)
 - [echohash](https://github.com/gemini/echohash/blob/master/src/wordlists/en_eff_long.js)
diff --git a/main.ts b/main.ts
index 65320f0a2be9c8c15616de59652bde5f40223b0d..a52243e46cfbd6c0b33b5356d2567b8c8fced4bf 100644 (file)
--- a/main.ts
+++ b/main.ts
@@ -2,10 +2,10 @@ import { parse } from "https://deno.land/std@0.146.0/flags/mod.ts";
 
 const { words, separator, length } = parse(Deno.args, {
   default: {
-    'words': './words/xkcd.txt',
-    'separator': '-',
-    'length': 3
-  }
+    "words": "./words/xkcd.txt",
+    "separator": "-",
+    "length": 3,
+  },
 });
 
 function abort(error: Error) {
@@ -16,11 +16,11 @@ function abort(error: Error) {
 // Validate and process words argument
 const dictionary: string[] = [];
 await Deno.readTextFile(words)
-  .then(f => dictionary.push(...f.split(/\r?\n/)))
+  .then((f) => dictionary.push(...f.split(/\r?\n/)))
   .catch(abort); // Will throw if an invalid file path is given
 
 // Validate and process separator argument
-const separators: string[] = separator.toString().split('');
+const separators: string[] = separator.toString().split("");
 
 // Validate and process length argument
 const len = parseInt(length);
@@ -31,10 +31,10 @@ const rand = new Uint16Array(len);
 crypto.getRandomValues(rand);
 
 const output: string[] = [];
-rand.forEach(v => {
+rand.forEach((v) => {
   output.push(dictionary[v % dictionary.length]);
   output.push(separators[v % separators.length]);
 });
 output.pop();
 
-console.log(output.join(''));
+console.log(output.join(""));
This page took 0.046784 seconds and 4 git commands to generate.