diff --git a/.babelrc b/.babelrc new file mode 100644 index 0000000..dc4e6e2 --- /dev/null +++ b/.babelrc @@ -0,0 +1,5 @@ +{ + "presets": [ + "babel-preset-env" + ] +} \ No newline at end of file diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..c192f23 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,9 @@ +root = true + +[*] +indent_style = space +indent_size = 2 +charset = utf-8 +end_of_line = lf +trim_trailing_whitespace = true +insert_final_newline = true \ No newline at end of file diff --git a/.eslintignore b/.eslintignore new file mode 100644 index 0000000..b0b28f7 --- /dev/null +++ b/.eslintignore @@ -0,0 +1,2 @@ +/dist/** +/bin/** \ No newline at end of file diff --git a/.eslintrc.json b/.eslintrc.json new file mode 100644 index 0000000..4b16401 --- /dev/null +++ b/.eslintrc.json @@ -0,0 +1,13 @@ +{ + "parser": "babel-eslint", + "extends": "eslint:recommended", + "env": { + "es6": true, + "browser": true, + "node": true, + "mocha": true + }, + "rules": { + "no-console": 0 + } +} \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..6d8e54c --- /dev/null +++ b/.gitignore @@ -0,0 +1,68 @@ +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* + +# Runtime data +pids +*.pid +*.seed +*.pid.lock + +# Directory for instrumented libs generated by jscoverage/JSCover +lib-cov + +# Coverage directory used by tools like istanbul +coverage + +# nyc test coverage +.nyc_output + +# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) +.grunt + +# Bower dependency directory (https://bower.io/) +bower_components + +# node-waf configuration +.lock-wscript + +# Compiled binary addons (https://nodejs.org/api/addons.html) +build/Release + +# Dependency directories +node_modules/ +jspm_packages/ + +# TypeScript v1 declaration files +typings/ + +# Optional npm cache directory +.npm + +# Optional eslint cache +.eslintcache + +# Optional REPL history +.node_repl_history + +# Output of 'npm pack' +*.tgz + +# Yarn Integrity file +.yarn-integrity + +# dotenv environment variables file +.env + +# next.js build output +.next + +# build output does not go to the repository +dist/ + +# lockfiles +package-lock.json +yarn.lock \ No newline at end of file diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..449a41b --- /dev/null +++ b/.travis.yml @@ -0,0 +1,7 @@ +language: node_js +script: + - "npm test" +node_js: + - "stable" + - "8" + - "6" \ No newline at end of file diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..e1165c2 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2018 @Burkes + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..3e84a71 --- /dev/null +++ b/README.md @@ -0,0 +1,48 @@ +# [gfynonce](https://burkes.github.io/gfynonce) - [![license](https://img.shields.io/github/license/Burkes/gfynonce.svg)](https://github.com/Burkes/gfynonce/blob/master/LICENSE) [![npm](https://img.shields.io/npm/v/gfynonce.svg)](https://npm.im/gfynonce) [![npm bundle size (minified + gzip)](https://img.shields.io/bundlephobia/minzip/gfynonce.svg)](https://unpkg.com/gfynonce) [![Travis](https://img.shields.io/travis/Burkes/gfynonce.svg)](https://travis-ci.org/Burkes/gfynonce) ![node](https://img.shields.io/node/v/gfynonce.svg) + +gfynonce is a "small" library that generates unique word compositions in the "adjective, adjective, animal" format that both Gfycat and Twitch uses. It tries it's best to generate nonces without repeating the same adjective and allows _some_ customization, such as providing the number of adjectives desired or the separator character. + +## Installation and Usage + +For your convenience, it is available in 3 forms, so choose whatever will work best for you: + +### Command Line +Installing gfynonce for the command line is as simple as running the following command: +``` +npm i -g gfynonce +``` + +Then, simply run `gfynonce` and it will generate a nonce with the default settings. +``` +$ gfynonce +FatSmallAmericanBulldog +``` +Additionally, you can provide some arguments to customize it, such as `--adjectives ` and `--separator `. +``` +$ gfynonce --adjectives 5 --separator . +Big.Small.Fancy.Elegant.Shy.Dipper +``` + +### Node +The installation procedure is almost the same, simply add it to your current project: +``` +npm i --save gfynonce +``` + +And you should be good to import it! +```js +const gfynonce = require('gfynonce'); + +console.log(gfynonce({ adjectives: 1, separator: '_' })); +// Tiny_Hog +``` + +### Browser +Unpkg kindly provides a fast CDN for NPM packages which you can use to access the UMD script. +```html + + +``` \ No newline at end of file diff --git a/bin/index.js b/bin/index.js new file mode 100644 index 0000000..eb0add3 --- /dev/null +++ b/bin/index.js @@ -0,0 +1,12 @@ +#!/usr/bin/env node + +// aiming for older node version compatibility + +var gfynonce = require('../'); +var minimist = require('minimist'); + +var argv = minimist(process.argv.slice(2)); + +var options = Object.assign({}, { separator: '', adjectives: 2 }, argv); + +process.stdout.write(gfynonce(options)); \ No newline at end of file diff --git a/data/adjectives.json b/data/adjectives.json new file mode 100644 index 0000000..415a9cd --- /dev/null +++ b/data/adjectives.json @@ -0,0 +1,1072 @@ +[ + "Wellmade", + "Blushing", + "Small", + "Playful", + "Pertinent", + "Closed", + "Zany", + "Hardtofind", + "Nifty", + "Considerate", + "Elderly", + "Affectionate", + "Whirlwind", + "Frayed", + "Gray", + "Insubstantial", + "Scratchy", + "Flippant", + "Secret", + "Shady", + "Tender", + "Interesting", + "Stormy", + "Cogent", + "Placid", + "Lucky", + "Disastrous", + "Every", + "Lined", + "Unripe", + "Somber", + "Faraway", + "These", + "Harmonious", + "Sharp", + "Anguished", + "Unpleasant", + "Jaunty", + "Vicious", + "Abnegate", + "Cracky", + "Hyper", + "Genius", + "Abstemious", + "Freezing", + "Jazzy", + "Cultured", + "Flirty", + "Busy", + "Deaf", + "Benevolent", + "Abstruse", + "Sweet", + "Affluent", + "Wild", + "Hairy", + "Alienated", + "Imaginative", + "Polished", + "Tempting", + "Watchful", + "Wavy", + "Broken", + "Responsible", + "Illiterate", + "Disfigured", + "Scientific", + "Oblong", + "Back", + "Rectangular", + "Inspiring", + "Blazing", + "Sincere", + "Enjoyable", + "Entertaining", + "Onerous", + "Rough", + "Round", + "Frozen", + "Manly", + "Smoky", + "Ephemeral", + "Trustworthy", + "Bashful", + "Litigious", + "Proud", + "Whispered", + "Hedonistic", + "Whopping", + "Rocky", + "Spoopy", + "Boxy", + "Moldy", + "Spunky", + "Observant", + "Renowned", + "Resolute", + "Spooky", + "Lovely", + "Astute", + "Expensive", + "Endearing", + "Callous", + "Flaccid", + "Kawaii", + "Abrasive", + "Ironic", + "Tacit", + "Seductive", + "Modern", + "Kathish", + "Resourceful", + "Apathetic", + "Fit", + "Unhealthy", + "Amazonian", + "Humble", + "Artsy", + "Suspicious", + "Bumbling", + "Periodic", + "Rude", + "Productive", + "Encouraging", + "Attractive", + "Bloody", + "Slushy", + "Hungry", + "Steamy", + "Gargantuan", + "Bossy", + "Energetic", + "Vengeful", + "Fancy", + "Teeming", + "Fatal", + "Smoggy", + "Sore", + "Tart", + "Taut", + "Polite", + "Bighearted", + "Late", + "Haunting", + "Sleepy", + "Wellworn", + "Famous", + "Salty", + "Young", + "Definite", + "Diligent", + "Frequent", + "Quick", + "Free", + "Grouchy", + "Offensive", + "Silky", + "Unique", + "Regular", + "Secondhand", + "Victorious", + "Zesty", + "Some", + "Verifiable", + "Wellinformed", + "Welllit", + "Vibrant", + "Warm", + "Infantile", + "Welcome", + "Minty", + "Wilted", + "Improbable", + "Windy", + "Wet", + "General", + "Remarkable", + "Melodic", + "Hearty", + "Short", + "Rewarding", + "Big", + "Ancient", + "Content", + "Excellent", + "Flickering", + "Constant", + "Gifted", + "Hospitable", + "Passionate", + "Healthy", + "Hopeful", + "Memorable", + "Scared", + "Joyful", + "Sentimental", + "Wellgroomed", + "Weak", + "Clever", + "Peppery", + "Yellow", + "Tight", + "Selfreliant", + "Serene", + "Speedy", + "Thin", + "Goodnatured", + "Thoughtful", + "Plush", + "Satisfied", + "Scary", + "Weepy", + "Yearly", + "Specific", + "Adventurous", + "Courageous", + "Selfassured", + "Vapid", + "Exemplary", + "Coarse", + "Wealthy", + "Giant", + "Firm", + "Bountiful", + "Flawless", + "Grim", + "Clean", + "Any", + "Boring", + "Smooth", + "Massive", + "Discrete", + "Feline", + "Hard", + "Terrible", + "Identical", + "Ill", + "Immediate", + "Jaded", + "Impressive", + "Antique", + "Apprehensive", + "Evergreen", + "Filthy", + "Aged", + "Welloff", + "Baggy", + "Bare", + "Candid", + "Celebrated", + "Comfortable", + "Crafty", + "Farflung", + "Glamorous", + "Jampacked", + "Magnificent", + "Meager", + "Precious", + "Prestigious", + "Spectacular", + "Spry", + "Thrifty", + "Severe", + "Shameless", + "Circular", + "Faroff", + "United", + "Lively", + "Gigantic", + "Large", + "Wasteful", + "Actual", + "Shiny", + "Complete", + "Tan", + "Testy", + "Appropriate", + "Thorough", + "Shallow", + "Silver", + "Total", + "Unacceptable", + "Uneven", + "Enchanting", + "Unnatural", + "Delightful", + "Untried", + "Costly", + "Unfinished", + "Beautiful", + "Thunderous", + "All", + "Another", + "Bowed", + "Clear", + "Calculating", + "Flustered", + "Oddball", + "Possible", + "Unconscious", + "Safe", + "Crazy", + "Important", + "Legal", + "Sizzling", + "Sorrowful", + "Tired", + "White", + "Zigzag", + "Organic", + "Careless", + "Cool", + "Creepy", + "Enraged", + "Equal", + "Favorable", + "Pointless", + "Fluid", + "Glistening", + "Kindhearted", + "Limping", + "Masculine", + "Orange", + "Palatable", + "Villainous", + "Welltodo", + "Which", + "Whimsical", + "Wideeyed", + "Decent", + "Defiant", + "Shameful", + "Yellowish", + "Wiggly", + "Willing", + "Slim", + "Tattered", + "Digital", + "Fitting", + "Vain", + "Last", + "Bleak", + "Tidy", + "Bruised", + "Cooperative", + "Dreary", + "Forsaken", + "Heavenly", + "Pleased", + "Ragged", + "Untimely", + "Unequaled", + "Acrobatic", + "Advanced", + "Agile", + "Ambitious", + "Enlightened", + "Brave", + "Difficult", + "Fatherly", + "Fine", + "Frigid", + "Jovial", + "Lighthearted", + "Long", + "Merry", + "Necessary", + "Rash", + "Remote", + "Several", + "Obedient", + "Shortterm", + "Sparse", + "Respectful", + "Tame", + "Tasty", + "Thick", + "Tinted", + "Unhappy", + "Yawning", + "Wee", + "Weighty", + "Lame", + "Odd", + "Fluffy", + "Angry", + "Recent", + "Cavernous", + "Hateful", + "Inconsequential", + "Nimble", + "Flimsy", + "Babyish", + "Finished", + "Better", + "Hollow", + "Disgusting", + "Misguided", + "Near", + "Ready", + "Elliptical", + "Immaculate", + "Gripping", + "Cooked", + "Happygolucky", + "Inexperienced", + "Fake", + "Colorful", + "Apt", + "Assured", + "Annual", + "Bad", + "Bogus", + "Classic", + "Blank", + "Fat", + "High", + "Insistent", + "Crisp", + "Decimal", + "Distant", + "Faint", + "Blissful", + "Fantastic", + "Good", + "Grounded", + "Honest", + "Horrible", + "Impractical", + "Insignificant", + "Keen", + "Klutzy", + "Likable", + "Aching", + "Graceful", + "Mediocre", + "Mild", + "Next", + "Past", + "Rich", + "Shocking", + "Splendid", + "Tepid", + "Unlawful", + "Infatuated", + "Elastic", + "Perfect", + "Essential", + "Snoopy", + "Barren", + "Gross", + "Sophisticated", + "Serpentine", + "Faithful", + "Defensive", + "Joint", + "Deficient", + "Flaky", + "Livid", + "Detailed", + "Brown", + "Cheap", + "Afraid", + "Angelic", + "Both", + "Bright", + "Calm", + "Dark", + "Great", + "Heavy", + "Madeup", + "Close", + "Elementary", + "Meek", + "Exalted", + "Flat", + "Gleeful", + "Terrific", + "Idealistic", + "Kind", + "Lasting", + "Lean", + "Orderly", + "Jealous", + "Positive", + "Tall", + "Colorless", + "Misty", + "Real", + "Required", + "Secondary", + "Sick", + "Smug", + "Sniveling", + "Spirited", + "Tedious", + "Bitesized", + "Pesky", + "Few", + "Indolent", + "Downright", + "Ashamed", + "Dense", + "Radiant", + "Mature", + "Male", + "Deafening", + "Scaly", + "Second", + "Phony", + "Aggravating", + "Animated", + "Beloved", + "Active", + "Cautious", + "Cheerful", + "Damaged", + "Familiar", + "Far", + "Gaseous", + "Focused", + "Immaterial", + "Grandiose", + "Major", + "Mealy", + "Only", + "Idolized", + "Accomplished", + "Mad", + "Biodegradable", + "Clumsy", + "Posh", + "Common", + "Dependable", + "Dimwitted", + "Disloyal", + "Flawed", + "Homely", + "Hot", + "Majestic", + "Offbeat", + "Sarcastic", + "Shrill", + "Disguised", + "Mean", + "Nervous", + "Cloudy", + "Gregarious", + "Hilarious", + "Favorite", + "Charming", + "Leading", + "Medium", + "Imaginary", + "Red", + "Acclaimed", + "Personal", + "Anxious", + "Arid", + "Emotional", + "Foolhardy", + "Shocked", + "Shoddy", + "Oily", + "Exhausted", + "Smart", + "Measly", + "Criminal", + "Elaborate", + "Alarmed", + "Ample", + "Bewitched", + "Blackandwhite", + "Clueless", + "Dependent", + "Deserted", + "Idiotic", + "Impeccable", + "Imperfect", + "Negative", + "Potable", + "Relieved", + "Spicy", + "Violet", + "Weary", + "Wide", + "Insidious", + "Daring", + "Perky", + "Ignorant", + "Lone", + "Illegal", + "Blaring", + "Brilliant", + "Devoted", + "Innocent", + "Female", + "French", + "Gentle", + "Imperturbable", + "That", + "Slimy", + "Impolite", + "Formal", + "Alive", + "Illustrious", + "Glossy", + "Golden", + "Dopey", + "Talkative", + "Menacing", + "Raw", + "Soupy", + "Adorable", + "Astonishing", + "Winding", + "Bland", + "Colossal", + "Fearful", + "Handsome", + "Highlevel", + "Incredible", + "Inferior", + "Neat", + "Neighboring", + "Paltry", + "Poised", + "Right", + "Sad", + "Snarling", + "Similar", + "Complicated", + "Frightening", + "Clearcut", + "Ordinary", + "Delectable", + "Chilly", + "Darling", + "Distorted", + "Euphoric", + "Greedy", + "Neglected", + "Dismal", + "Black", + "Remorseful", + "Unselfish", + "Wicked", + "Corny", + "Heartfelt", + "Unlucky", + "Minor", + "Velvety", + "Handy", + "Delayed", + "Mammoth", + "Able", + "Adept", + "Envious", + "Altruistic", + "Dirty", + "Pleasant", + "Equatorial", + "Forceful", + "Hefty", + "Repentant", + "Lanky", + "Linear", + "Miniature", + "Nippy", + "Opulent", + "Sandy", + "Scented", + "Soft", + "Bouncy", + "Reflecting", + "Silent", + "Solid", + "Pale", + "Eager", + "Political", + "Harsh", + "Conscious", + "Earnest", + "Icy", + "Ringed", + "Messy", + "Cold", + "Spiteful", + "Plaintive", + "Honorable", + "Plump", + "Confused", + "Enormous", + "Impartial", + "Excitable", + "Easy", + "Key", + "Dimpled", + "Glass", + "Valid", + "Impossible", + "Grotesque", + "Negligible", + "Each", + "Brisk", + "Glum", + "Grizzled", + "Helpless", + "Ajar", + "Anchored", + "Cheery", + "Forthright", + "Bony", + "Different", + "Dim", + "Glittering", + "Direct", + "Giving", + "Dizzy", + "Easygoing", + "Embarrassed", + "Blue", + "Carefree", + "Icky", + "Piercing", + "Feisty", + "Feminine", + "Quarterly", + "Grand", + "Grateful", + "Jubilant", + "Repulsive", + "Ripe", + "Shimmering", + "Handmade", + "Parched", + "Quarrelsome", + "Revolving", + "Slight", + "Immense", + "Dazzling", + "Incompatible", + "Legitimate", + "Petty", + "Loathsome", + "Amusing", + "Firsthand", + "Pointed", + "Old", + "Portly", + "Accurate", + "First", + "Corrupt", + "Scholarly", + "Realistic", + "Naive", + "Delirious", + "Fast", + "Inborn", + "Needy", + "Reliable", + "Valuable", + "Unlined", + "Best", + "Scarce", + "Same", + "Venerated", + "Vigorous", + "Webbed", + "Shy", + "Brief", + "Failing", + "Fragrant", + "Incomparable", + "Open", + "Ultimate", + "Spotless", + "Wan", + "Jittery", + "Informal", + "Whole", + "Agonizing", + "Flowery", + "Amused", + "Blind", + "Dental", + "Mindless", + "Harmless", + "Determined", + "Ornate", + "Ecstatic", + "Impassioned", + "Regal", + "Light", + "Metallic", + "Physical", + "Plain", + "Powerful", + "Sane", + "Fortunate", + "Granular", + "Slippery", + "Hidden", + "Honored", + "Infinite", + "Miserable", + "Thankful", + "Narrow", + "Nasty", + "Naughty", + "Nautical", + "Vague", + "Variable", + "Warlike", + "Perfumed", + "Breakable", + "Reckless", + "Simplistic", + "Sparkling", + "Those", + "Unimportant", + "Unknown", + "Weekly", + "Reasonable", + "Zealous", + "Demanding", + "Ideal", + "Official", + "Compassionate", + "Scrawny", + "Rare", + "Half", + "Spherical", + "Fond", + "Descriptive", + "Early", + "Knobby", + "Simple", + "Composed", + "Canine", + "Generous", + "Creamy", + "Absolute", + "Foolish", + "Gleaming", + "Impish", + "Incomplete", + "Medical", + "Peaceful", + "Agreeable", + "Aromatic", + "Pink", + "Pleasing", + "Powerless", + "Grimy", + "Sinful", + "Married", + "Qualified", + "Silly", + "Snappy", + "Soulful", + "Obvious", + "Third", + "Spotted", + "Understated", + "Popular", + "Abandoned", + "Rapid", + "Unfolded", + "Single", + "Spiffy", + "Unruly", + "Illinformed", + "Unsightly", + "Chief", + "Jolly", + "Skeletal", + "Belated", + "Cluttered", + "Parallel", + "Bitter", + "Unkempt", + "Huge", + "Deadly", + "Instructive", + "New", + "Warped", + "Complex", + "Occasional", + "Mellow", + "Acceptable", + "Queasy", + "Flamboyant", + "Thorny", + "Artistic", + "Blond", + "Gloomy", + "Entire", + "Everlasting", + "Indelible", + "Enchanted", + "Boiling", + "Arctic", + "Present", + "Damp", + "Liquid", + "Coordinated", + "Conventional", + "Courteous", + "Elegant", + "Admired", + "Joyous", + "Embellished", + "Alert", + "Frail", + "Pessimistic", + "Friendly", + "False", + "Harmful", + "Frank", + "Sardonic", + "Meaty", + "Shabby", + "Querulous", + "Weird", + "Basic", + "Partial", + "Bronze", + "Careful", + "Dead", + "Deep", + "Impressionable", + "Eminent", + "Torn", + "Leafy", + "Mixed", + "Vast", + "Selfish", + "Insecure", + "Unaware", + "Esteemed", + "Electric", + "Watery", + "Concerned", + "Creative", + "Edible", + "Even", + "Dangerous", + "Hasty", + "Fixed", + "Bold", + "Optimal", + "Defenseless", + "Nice", + "Educated", + "Elated", + "Glaring", + "Impure", + "Jagged", + "Obese", + "Left", + "Tense", + "Admirable", + "Dishonest", + "Scornful", + "Shadowy", + "Distinct", + "Green", + "Spanish", + "Flashy", + "Unfit", + "Genuine", + "Unsteady", + "Untidy", + "Helpful", + "Lonely", + "Athletic", + "Aggressive", + "Questionable", + "Skinny", + "Agitated", + "Adolescent", + "Glorious", + "Threadbare", + "Pastel", + "Dearest", + "Kindly", + "Idle", + "Lawful", + "Oldfashioned", + "Miserly", + "Separate", + "Tangible", + "Thirsty", + "Serious", + "Timely", + "Fair", + "Delicious", + "Caring", + "Pitiful", + "Tiny", + "Ugly", + "Uniform", + "Competent", + "Wary", + "Kaleidoscopic", + "Sour", + "Infamous", + "Happy", + "Adored", + "Alarming", + "Capital", + "Amazing", + "Academic", + "Live", + "Soggy", + "Ethical", + "Dear", + "Empty", + "Optimistic", + "Fearless", + "Evil", + "Fickle", + "Uncomfortable", + "Likely", + "Vigilant", + "Marvelous", + "Unrealistic", + "Little", + "Quaint", + "Frightened", + "Lazy", + "Definitive", + "Welldocumented", + "Hoarse", + "Decisive", + "Limp", + "Natural", + "Acidic", + "Fresh", + "Vacant", + "Beneficial", + "Chubby", + "Limited", + "Rigid", + "Giddy", + "Milky", + "Poor", + "Unfortunate", + "Lavish", + "Forked", + "Concrete", + "Fabulous", + "Gorgeous", + "Ornery", + "Dapper", + "Gracious", + "Grave", + "Plastic", + "Hideous", + "Slow", + "Illfated", + "Practical", + "Showy", + "Sneaky", + "Warmhearted", + "Sociable", + "Uncommon", + "Unsung", + "Waterlogged" +] \ No newline at end of file diff --git a/data/animals.json b/data/animals.json new file mode 100644 index 0000000..31cdd7d --- /dev/null +++ b/data/animals.json @@ -0,0 +1,1005 @@ +[ + "BantamRooster", + "Amphiuma", + "IbizanHound", + "AfricanPorcupine", + "AdmiralButterfly", + "Civet", + "AldabraTortoise", + "Fluke", + "Beetle", + "AbyssinianGroundHornbill", + "Akitainu", + "Caecilian", + "Goose", + "BeardedDragon", + "Antlion", + "BlackWidowSpider", + "AmericanBobtail", + "Cuttlefish", + "CornSnake", + "Iguanodon", + "ArrowWorm", + "BlueAndGoldMackaw", + "DartFrog", + "IzuThrush", + "Amoeba", + "Ichthyosaurs", + "Crustacean", + "AcornWoodpecker", + "Leafhopper", + "Deinonychus", + "IberianBarbel", + "Bettong", + "Giraffe", + "Elephant", + "AfricanFishEagle", + "Bonobo", + "DiamondbackRattlesnake", + "FlickertailSquirrel", + "FlyingSquirrel", + "Godwit", + "GuineaPig", + "Caterpillar", + "Chihuahua", + "DuckbillPlatypus", + "Genet", + "Cygnet", + "FennecFox", + "Bull", + "Armyant", + "EuropeanFireSalamander", + "Elk", + "ChimneySwift", + "Lice", + "HectorsDolphin", + "FairyBluebird", + "IslandWhistler", + "ItalianGreyhound", + "Kangaroo", + "Killifish", + "Lark", + "Emu", + "BlueWhale", + "Deer", + "HanumanMonkey", + "AfricanMoleSnake", + "ImperatorAngel", + "Gharial", + "Dunlin", + "Isopod", + "Javalina", + "Ichthyostega", + "Jellyfish", + "LhasaApso", + "KillerWhale", + "Crane", + "Aardvark", + "Kinkajou", + "Kitten", + "Kronosaurus", + "Hadrosaurus", + "Gaur", + "Baiji", + "AntelopeGroundSquirrel", + "Bandicoot", + "Foal", + "Earwig", + "Bluebird", + "Coelacanth", + "Copperhead", + "Goldfinch", + "Cottonmouth", + "Gyrfalcon", + "GraySquirrel", + "IcelandicSheepdog", + "Grosbeak", + "AtlanticBlueTang", + "Blobfish", + "AlligatorGar", + "Goat", + "Human", + "Goral", + "Ape", + "Grunion", + "Chimpanzee", + "KarakulSheep", + "GalapagosDove", + "Coot", + "Balloonfish", + "Appaloosa", + "Guppy", + "ArabianHorse", + "AltiplanoChinchillaMouse", + "Hagfish", + "CommonGonolek", + "AfricanElephant", + "Goldfish", + "Hedgehog", + "Barbet", + "ArcticSeal", + "Hornet", + "Cockatoo", + "CraneFly", + "FoxTerrier", + "Grasshopper", + "Guineafowl", + "HarbourPorpoise", + "Bear", + "AustralianKestrel", + "AnophelesMosquito", + "FieldSpaniel", + "Devilfish", + "Butterfly", + "Egg", + "AtlanticBlackgoby", + "Eider", + "Albertosaurus", + "Leveret", + "AfricanGroundHornbill", + "Bactrian", + "Argali", + "Goa", + "Albino", + "CommaButterfly", + "Cony", + "CopperButterfly", + "IbadanMalimbe", + "EidolonHelvum", + "Crocodile", + "EmperorShrimp", + "Ewe", + "EyelashPitViper", + "Cottontail", + "Bluet", + "Ferret", + "Crossbill", + "FinnishSpitz", + "AlaskanMalamute", + "Flee", + "Finch", + "Cub", + "IberianMole", + "Dassie", + "HermitCrab", + "FlatCoatRetriever", + "IndigoWingedParrot", + "DungBeetle", + "DraftHorse", + "Drake", + "EasternNewt", + "Bird", + "IvoryBackedWoodswallow", + "AmethystinePython", + "BlackRussianTerrier", + "Firecrest", + "Kite", + "Fish", + "ArcticWolf", + "BighornedSheep", + "AustralianFreshwaterCrocodile", + "DanishSwedishFarmdog", + "Flicker", + "HorseChestnutLeafMiner", + "Huemul", + "Budgie", + "LeopardSeal", + "Kiskadee", + "LeafcutterAnt", + "Leafbird", + "Discus", + "Cod", + "Coqui", + "Coral", + "Cow", + "CrownOfThornsStarfish", + "Hartebeest", + "ElectricEel", + "Insect", + "EskimoDog", + "Ibex", + "EthiopianWolf", + "EuropeanPoleCat", + "Kingbird", + "IrishDraughtHorse", + "Lamb", + "Impala", + "IndianPalmSquirrel", + "Hummingbird", + "HawaiianMonkSeal", + "Ichidna", + "Jaeger", + "Jabiru", + "Flycatcher", + "Antbear", + "Antelope", + "Arachnid", + "Arawana", + "ArgusFish", + "AsianDamselfly", + "Hawk", + "GalapagosTortoise", + "AustralianCurlew", + "AustralianKelpie", + "BlackLab", + "Incatern", + "BlackNorwegianElkhound", + "Boa", + "IceBlueRedTopZebra", + "CaimanLizard", + "Calf", + "Chameleon", + "ClownAnemonefish", + "IberianMidwifeToad", + "IndianCow", + "ItalianBrownBear", + "KoalaBear", + "Larva", + "EstuarineCrocodile", + "FanWorms", + "BoaConstrictor", + "Koala", + "Gelada", + "Jaguar", + "AntarcticGiantPetrel", + "ArizonaAlligatorLizard", + "HarvestMouse", + "IndianaBat", + "AndeanCat", + "Anura", + "FrilledLizard", + "Archaeopteryx", + "ArielToucan", + "AsianElephant", + "AsiaticGreaterFreshwaterClam", + "IndigoBunting", + "Haddock", + "AsiaticLesserFreshwaterClam", + "Halcyon", + "Asp", + "Avians", + "AxisDeer", + "Hoverfly", + "Axolotl", + "GreatHornedOwl", + "Horse", + "Barracuda", + "GoldenEye", + "Basil", + "InchWorm", + "IcelandGull", + "GypsyMoth", + "Herring", + "Hind", + "ArabianWildcat", + "KissingBug", + "Killdeer", + "Hart", + "BlackPanther", + "IrishRedAndWhiteSetter", + "AsianSmallClawedOtter", + "Borer", + "Goshawk", + "Camel", + "AchillesTang", + "Aidi", + "AiredaleTerrier", + "AlpineGoat", + "AmericanCicada", + "AmericanRiverOtter", + "AmericanWarmblood", + "AmericanWigeon", + "Capybara", + "Cardinal", + "Cassowary", + "Cero", + "CleanerWrasse", + "Cormorant", + "CorydorasCatfish", + "Creature", + "Langur", + "Airedale", + "AmericanWirehair", + "Amphibian", + "Gerbil", + "Heterodontosaurus", + "AmethystSunbird", + "ImperialEagle", + "AmurStarfish", + "Angora", + "Eel", + "ArabianOryx", + "BluetickCoonhound", + "Cat", + "Kakarikis", + "AsianTrumpetfish", + "AfricanJacana", + "AfricanRockPython", + "Agouti", + "AlaskanHusky", + "AmericanAlligator", + "AplomadoFalcon", + "AmericanCrayfish", + "Fawn", + "Cusimanse", + "Bullfrog", + "Ladybird", + "Gemsbuck", + "AmericanCurl", + "Heifer", + "AmericanGoldfinch", + "HorseshoeCrab", + "AsianWaterBuffalo", + "Globefish", + "Hogget", + "Hypsilophodon", + "IchneumonFly", + "IndianSpinyLoach", + "AmericanQuarterHorse", + "AmericanRedSquirrel", + "Lemming", + "AsiaticMouflon", + "Kob", + "AtlanticSharpnosePuffer", + "Auklet", + "Avocet", + "Aztecant", + "BaldEagle", + "BlackCrappie", + "Caracal", + "Indri", + "Clingfish", + "FatTailedDunnart", + "Bunny", + "AmericanBittern", + "Janenschia", + "Leafwing", + "GalapagosMockingbird", + "GermanShepherd", + "IcterineWarbler", + "Inganue", + "Kakapo", + "IvoryBilledWoodpecker", + "Kudu", + "Jackal", + "Kentrosaurus", + "Jaguarundi", + "Kitty", + "Kusimanse", + "KodiakBear", + "AfricanWildcat", + "KomodoDragon", + "LabradorRetriever", + "Duiker", + "Lemur", + "Kiwi", + "Hatchetfish", + "AmericanBlackVulture", + "AsiaticWildAss", + "Bats", + "Beagle", + "Beauceron", + "Binturong", + "Cats", + "Chuckwalla", + "DavidsTiger", + "DevilTasmanian", + "DoctorFish", + "Dodobird", + "Dolphin", + "DouglasFirBarkBeetle", + "DungenessCrab", + "EastRussianCoursingHounds", + "IndianRockPython", + "Junebug", + "IrishSetter", + "Kestrel", + "Liger", + "Ibisbill", + "Barb", + "BedBug", + "BillyGoat", + "BirdOfParadise", + "BlackFootedFerret", + "BorderCollie", + "Brant", + "BrocketDeer", + "Buck", + "Chick", + "Chrysalis", + "Cirriped", + "Clumber", + "Cobra", + "Cricket", + "CrocodileSkink", + "Curassow", + "Gadwall", + "GalapagosAlbatross", + "GardenSnake", + "Gecko", + "GermanWirehairedPointer", + "Gnu", + "Gosling", + "GossamerWingedButterfly", + "GrizzlyBear", + "Grouse", + "Hairstreak", + "Halibut", + "FallowDeer", + "HornedToad", + "HorseMouse", + "Hound", + "Husky", + "Hydra", + "Hyena", + "Hyrax", + "IaerisMetalmark", + "IberianChiffchaff", + "Imago", + "IndianElephant", + "IndianRingneckParakeet", + "AlpineRoadguideTigerBeetle", + "Falcon", + "Elver", + "IndianSkimmer", + "BigHorn", + "AmazonTreeBoa", + "IndochinaHogDeer", + "Frogmouth", + "DikDik", + "FrenchBulldog", + "Koi", + "AmericanCrow", + "HammerheadShark", + "HarborSeal", + "IntermediateEgret", + "IranianGroundJay", + "HarpSeal", + "HarpyEagle", + "Harrier", + "Hen", + "Hoki", + "Homalocephale", + "HoneyBadger", + "IrishWaterSpaniel", + "Leopard", + "Leonberger", + "Leech", + "ApisDorsataLaboriosa", + "Fairyfly", + "ArmedNylonShrimp", + "DairyCow", + "Dotterel", + "IndusRiverDolphin", + "GilaMonster", + "Cur", + "Baboon", + "Ant", + "Cattle", + "Kingfisher", + "FireAnt", + "FieldMouse", + "ArgentineHornedFrog", + "AttwatersPrairieChicken", + "Harvestmen", + "AfricanClawedFrog", + "Krill", + "BarnOwl", + "Goitered", + "HydatidTapeworm", + "BettaFish", + "Kittiwake", + "Cooter", + "Cowbird", + "Ladybug", + "Gar", + "AustrianPinscher", + "Flatfish", + "AsianLion", + "AfricanPiedKingfisher", + "Basilisk", + "Conure", + "Dachshund", + "DaddyLonglegs", + "DogwoodTwigBorer", + "Drongo", + "Ermine", + "Fugu", + "Gallinule", + "ArgentineRuddyDuck", + "Galago", + "GarterSnake", + "Geese", + "GermanSpitz", + "GrassSpider", + "GreatArgus", + "GuernseyCow", + "HookerSeaLion", + "Hornbill", + "IberianNase", + "Illadopsis", + "IndianGlassfish", + "IndianJackal", + "BlueJay", + "IndochineseTiger", + "IvoryGull", + "Jay", + "Jerboa", + "AmurMinnow", + "DwarfMongoose", + "Hare", + "Badger", + "BlackFly", + "Boto", + "Adouri", + "Ankole", + "AustralianCattleDog", + "Barasingha", + "BedlingtonTerrier", + "Blackbird", + "Blowfish", + "Bluegill", + "BrownBear", + "Catbird", + "Hippopotamus", + "Chicken", + "Clam", + "CockerSpaniel", + "BoilWeevil", + "AtlanticSpadefish", + "GermanSpaniel", + "Gibbon", + "Earthworm", + "GordonSetter", + "Hellbender", + "Equestrian", + "Eyra", + "Aardwolf", + "HammerheadBird", + "AegeanCat", + "Guillemot", + "GalapagosHawk", + "Hoatzin", + "Hylaeosaurus", + "Halicore", + "Bee", + "Addax", + "FinWhale", + "Burro", + "Boubou", + "Collie", + "AfricanCivet", + "Centipede", + "GlassFrog", + "GermanPinscher", + "BigMouthBass", + "Bat", + "Alligator", + "Elkhound", + "Albatross", + "AmericanCrocodile", + "AmericanToad", + "Armyworm", + "AustralianShelduck", + "BerneseMountainDog", + "Dorado", + "Bobcat", + "Borzoi", + "Cavy", + "Chrysomelid", + "Bubblefish", + "Cowrie", + "EastSiberianLaika", + "Donkey", + "Dorking", + "Cougar", + "Dormouse", + "Hamster", + "Duckling", + "ArcticFox", + "Gorilla", + "Ass", + "DwarfRabbit", + "Gander", + "AmericanIndianHorse", + "Dragon", + "Coypu", + "AsianPiedStarling", + "FishingCat", + "Flea", + "Fulmar", + "Dunnart", + "Bobolink", + "Coyote", + "FlyingFox", + "Chevrotain", + "Galah", + "Gelding", + "Erne", + "FruitBat", + "IslandCanary", + "Chanticleer", + "Curlew", + "CarpenterAnt", + "GallowayCow", + "Blackfish", + "AcornWeevil", + "AfricanWildDog", + "Bluefish", + "Acaciarat", + "AlaskanKleeKai", + "AmericanCreamDraft", + "Arthropods", + "BlackAndTanCoonhound", + "BlueTongueLizard", + "Caiman", + "FurSeal", + "FrillNeckedLizard", + "FritillaryButterfly", + "AfricanGoldenCat", + "DarklingBeetle", + "Adder", + "Comet", + "Dore", + "Chamois", + "Archaeocete", + "ArmedCrab", + "Cuckoo", + "BushBaby", + "Beaver", + "Hapuka", + "Grub", + "Ammonite", + "BluefinTuna", + "Gannet", + "Angwantibo", + "AzureWingedMagpie", + "Blesbok", + "CapeGhostFrog", + "Bellfrog", + "AbyssinianCat", + "Hyracotherium", + "AndeanCondor", + "BighornSheep", + "Ekaltadeta", + "Flamingo", + "Cock", + "Kinglet", + "AmericanKestrel", + "Arrowana", + "Glowworm", + "Hamadryad", + "IsabellineWheatear", + "BangelTiger", + "Canary", + "BergerPicard", + "Anglerfish", + "Dowitcher", + "Brontosaurus", + "Bumblebee", + "Carp", + "Degus", + "Eft", + "Foxhound", + "Gavial", + "Dove", + "Degu", + "Drever", + "Junco", + "Dinosaur", + "EastEuropeanShepherd", + "JohnDory", + "GangesDolphin", + "AmbushBug", + "Anaconda", + "BlueBreastedKookaburra", + "Babirusa", + "Cockroach", + "DutchSmoushond", + "Aracari", + "Equine", + "FlyingFish", + "Crayfish", + "Gazelle", + "Grebe", + "HornShark", + "Lamprey", + "GrayFox", + "CollardLizard", + "Dragonfly", + "Huia", + "Caudata", + "FrigateBird", + "HowlerMonkey", + "FireBelliedToad", + "HorseFly", + "Bustard", + "Boar", + "AfricanBushViper", + "Chipmunk", + "Graywolf", + "AmericanBulldog", + "AfricanHornbill", + "Chickadee", + "Aurochs", + "ElephantBeetle", + "EnglishPointer", + "AstrangiaCoral", + "AmethystGemClam", + "Armadillo", + "BengalTiger", + "Astarte", + "Buzzard", + "Bronco", + "HorseshoeBat", + "Duck", + "IcelandicHorse", + "Frog", + "BarnSwallow", + "FruitFly", + "Anchovy", + "Grackle", + "BallPython", + "AndalusianHorse", + "FiddlerCrab", + "Archerfish", + "Bison", + "BrownButterfly", + "Garpike", + "AffenPinscher", + "Agama", + "AlaskaJingle", + "DeerMouse", + "AnemoneShrimp", + "AfricanHarrierHawk", + "Dalmatian", + "Hapuku", + "ElephantSeal", + "Herald", + "Grison", + "GroundBeetle", + "BrahmanCow", + "Gonolek", + "Dipper", + "HarlequinBug", + "AmazonParrot", + "AmericanPaintHorse", + "Bunting", + "DassieRat", + "IberianEmeraldLizard", + "AmericanBadger", + "IndianHare", + "AlligatorSnappingTurtle", + "Bufflehead", + "AzureVase", + "AssassinBug", + "AmberPenshell", + "Esok", + "GentooPenguin", + "Hog", + "AfghanHound", + "HumpbackWhale", + "AngelWingMussel", + "JumpingBean", + "Conch", + "BlueMorphoButterfly", + "Hackee", + "AyeAye", + "AfricanParadiseFlycatcher", + "Bellsnake", + "Anteater", + "Bass", + "BlackMamba", + "Gull", + "GoldenMantledGroundSquirrel", + "AsianConstableButterfly", + "Chupacabra", + "BluebottleJellyfish", + "Dog", + "GalapagosPenguin", + "Fox", + "GrayReefShark", + "FlyingLemur", + "GreenDarnerDragonfly", + "Kouprey", + "Honeycreeper", + "InvisibleRail", + "Eeve", + "Firefly", + "Eagle", + "Cicada", + "Cheetah", + "Bilby", + "Crow", + "GreatDane", + "AmurRatSnake", + "IrrawaddyDolphin", + "Barasinga", + "Hypacrosaurus", + "IsabellineShrike", + "EasternGlassLizard", + "Hoiho", + "HairstreakButterfly", + "Crab", + "Hammerkop", + "Acouchi", + "Grouper", + "Ibis", + "Gourami", + "Fantail", + "AnkoleWatusi", + "Anhinga", + "IrukandjiJellyfish", + "Bagworm", + "HerculesBeetle", + "BlueShark", + "Katydid", + "Auk", + "EmeraldTreeSkink", + "GoldenRetriever", + "Blackbuck", + "AquaticLeech", + "Heron", + "AtlasMoth", + "ArcticDuck", + "Egret", + "AzureVaseSponge", + "BaleenWhale", + "Fly", + "Honeyeater", + "Dodo", + "AndeanCockOfTheRock", + "Bullmastiff", + "Gnatcatcher", + "AtlanticRidleyTurtle", + "AdamsStagHornedBeetle", + "Backswimmer", + "ArkShell", + "Chinchilla", + "Eland", + "GiantSchnauzer", + "AdeliePenguin", + "Canvasback", + "JapaneseBeetle", + "AlleyCat", + "BuckeyeButterfly", + "Bream", + "Bug", + "Coney", + "Joey", + "Kingsnake", + "Barnacle", + "Colt", + "EmperorPenguin", + "AmazonDolphin", + "Copepod", + "IndianPangolin", + "BushSqueaker", + "Gemsbok", + "Cockatiel", + "IrishTerrier", + "HochstettersFrog", + "Koodoo", + "Kawala", + "Cuscus", + "Eyas", + "Hake", + "Kookaburra", + "Allosaurus", + "Booby", + "HarrierHawk", + "Chital", + "AcornBarnacle", + "Catfish", + "IridescentShark", + "Kid", + "AnnasHummingbird", + "BorderTerrier", + "AmericanAvocet", + "AmericanRobin", + "BlackLemur", + "Cob", + "Dugong", + "Gerenuk", + "Dikkops", + "AustralianFurSeal", + "Apatosaur", + "FreshwaterEel", + "Goosefish", + "Dogfish", + "DogwoodClubGall", + "DuckbillCat", + "Blackbear", + "Gopher", + "Grayling", + "Kagu", + "AustralianSilkyTerrier", + "IrishWolfhound", + "Fowl", + "Diplodocus", + "FunnelWeaverSpider", + "Iguana", + "GreyhoundDog", + "Hamadryas", + "Groundhog", + "Guanaco", + "AlabamaMapTurtle", + "AntipodesGreenParakeet", + "Coati", + "Condor", + "Annelid", + "Fossa", + "Bobwhite", + "AmericanMarten", + "DarwinsFox", + "Dromaeosaur", + "AsianPorcupine", + "HoneyBee", + "Laughingthrush", + "AmericanSaddlebred", + "AmericanRatSnake", + "Echidna", + "EnglishSetter", + "GalapagosSeaLion", + "Abalone", + "GhostShrimp", + "BrahmanBull", + "Cutworm", + "BelugaWhale", + "Buffalo", + "IriomoteCat", + "JackRabbit", + "DesertPupfish", + "AmericanLobster", + "Icefish", + "Dingo", + "Banteng", + "GreatWhiteShark", + "JuliaButterfly", + "Doe", + "Chafer", + "AfricanAugurBuzzard", + "Damselfly", + "Angelfish", + "Anole", + "Basenji", + "Aoudad", + "Bufeo", + "BichonFrise", + "Boutu", + "Dromedary", + "AllensBigEaredBat", + "Bongo", + "IndianRhinoceros", + "Bittern", + "DutchShepherdDog", + "CanadaGoose", + "Anemone", + "DobermanPinscher", + "AmericanShorthair", + "Aphid", + "ArcticHare", + "AlbacoreTuna", + "Erin", + "BeardedCollie", + "Alpaca", + "Aruanas", + "Annelida", + "HornedViper", + "IberianLynx", + "Housefly", + "Gnat", + "GermanShorthairedPointer", + "BlackRhino", + "Hoopoe", + "Lacewing", + "Caribou", + "ArrowCrab", + "BassetHound", + "Bovine", + "AnemoneCrab", + "ChineseCrocodileLizard", + "AntarcticFurSeal", + "Flounder", + "Flies" +] \ No newline at end of file diff --git a/package.json b/package.json new file mode 100644 index 0000000..f5ba8f9 --- /dev/null +++ b/package.json @@ -0,0 +1,60 @@ +{ + "name": "gfynonce", + "version": "1.0.0", + "description": "nonce generator in the 'adjective adjective animal' pattern that that Gfycat (and Twitch) uses", + "main": "dist/gfynonce.js", + "module": "dist/gfynonce.es.js", + "browser": "dist/gfynonce.min.js", + "bin": "bin/index.js", + "author": "Burkes ", + "license": "MIT", + "homepage": "https://github.com/Burkes/gfynonce", + "repository": "github:Burkes/gfynonce", + "bugs": { + "url": "https://github.com/Burkes/gfynonce/issues", + "email": "gfynonce@burkes.pw" + }, + "scripts": { + "lint": "eslint src test bin", + "prebuild": "npm run lint", + "build": "rollup -c", + "pretest": "npm run build", + "test": "mocha", + "prepare": "npm run build" + }, + "keywords": [ + "nonce", + "adjectives", + "animals", + "generator", + "generation", + "random", + "pattern", + "gfycat", + "twitch", + "identifier", + "unique" + ], + "engines": { + "node": ">= 6" + }, + "devDependencies": { + "babel": "^6.23.0", + "babel-eslint": "^8.2.3", + "babel-plugin-external-helpers": "^6.22.0", + "babel-preset-env": "^1.6.1", + "babel-register": "^6.26.0", + "babelrc-rollup": "^3.0.0", + "chai": "^4.1.2", + "eslint": "^4.19.1", + "lodash.uniq": "^4.5.0", + "mocha": "^5.1.1", + "rollup": "^0.58.2", + "rollup-plugin-babel": "^3.0.4", + "rollup-plugin-json": "^2.3.0", + "rollup-plugin-uglify": "^3.0.0" + }, + "dependencies": { + "minimist": "^1.2.0" + } +} \ No newline at end of file diff --git a/rollup.config.js b/rollup.config.js new file mode 100644 index 0000000..9771d21 --- /dev/null +++ b/rollup.config.js @@ -0,0 +1,58 @@ +import babelrc from 'babelrc-rollup'; +import babel from 'rollup-plugin-babel'; +import uglify from 'rollup-plugin-uglify'; +import json from 'rollup-plugin-json'; + +const pkg = require('./package.json'); + +const banner = `/* + * @preserve + * gfynonce v${pkg.version} (${pkg.homepage}) + * ${pkg.description} + * MIT License + * + */`; + +const plugins = [ + json(), + babel(babelrc()), +]; + +const regularConfig = { + plugins, + input: 'src/index.js', + output: [ + { + file: pkg.main, + format: 'umd', + name: pkg.name, + banner, + }, + { + file: pkg.module, + format: 'es', + }, + ], +}; + +const minifiedConfig = Object.assign({}, regularConfig, { + plugins: [ + json(), + babel(babelrc()), + uglify({ + output: { + comments: /@preserve/, + }, + }) + ], + output: [ + { + file: pkg.browser, + format: 'umd', + name: pkg.name, + banner, + }, + ], +}); + +export default [regularConfig, minifiedConfig]; \ No newline at end of file diff --git a/src/index.js b/src/index.js new file mode 100644 index 0000000..5e2022a --- /dev/null +++ b/src/index.js @@ -0,0 +1,41 @@ +import ANIMALS from '../data/animals.json'; +import ADJECTIVES from '../data/adjectives.json'; + +function shuffleArray(arr) { + let array = [...arr]; + + for (let i = array.length - 1; i > 0; i--) { + let j = Math.floor(Math.random() * (i + 1)); + [array[i], array[j]] = [array[j], array[i]]; + } + + return array; +} + +const randomIndex = array => Math.floor(Math.random() * array.length); +const getRandomArraySliceStart = (array, size) => Math.max(0, randomIndex(array) - size); +const getRandomArraySlice = (array, size, start = getRandomArraySliceStart(array, size)) => shuffleArray(array).slice(start, start + size); + +const defaultOptions = { + separator: '', + adjectives: 2, +}; + +export default function gfynonce(options = {}) { + options = Object.assign({}, defaultOptions, options); + + // set some ground rules to prevent it from breaking + if (options.adjectives <= 0) { + options.adjectives = 1; + } else if (options.adjectives >= ADJECTIVES.length) { + options.adjectives = ADJECTIVES.length; + } + + const randomAdjectives = getRandomArraySlice(ADJECTIVES, options.adjectives); + // TO-DO: More complicated tests are required to allow more than one animal + const randomAnimals = getRandomArraySlice(ANIMALS, 1); + + const pieces = [...randomAdjectives, ...randomAnimals]; + + return pieces.join(options.separator); +} \ No newline at end of file diff --git a/test/index.js b/test/index.js new file mode 100644 index 0000000..c9afe76 --- /dev/null +++ b/test/index.js @@ -0,0 +1,147 @@ +// eslint-disable-next-line prefer-destructuring +import { expect } from 'chai'; +import uniq from 'lodash.uniq'; +import gfynonce from '../'; + +import ADJECTIVES from '../data/adjectives.json'; + +const nonceRegexBuilder = (adjCount = 2, separator = '') => new RegExp(`^([A-Z][a-z]+${separator}){${adjCount}}([A-z]+)$`); +// ugly way of extracting each capitalized word from a nonce.. +const getAdjectivesArrayFromNonce = (nonce) => + nonce.split('') + .map((l, i) => + l + nonce.substr(i + 1, nonce.substr(i + 1).search(/[A-Z]/) !== -1 ? nonce.substr(i + 1).search(/[A-Z]/) : nonce.length)) + .filter(word => word.charAt(0).match(/[A-Z]/) && word.length > 1); + +describe('gfynonce', () => { + describe('default nonce generation', () => { + it('should generate a nonce with the default 2 adjectives and no separator', () => { + expect(gfynonce()) + .to.match(nonceRegexBuilder()); + }); + + describe('fallback to the minimum', () => { + it('when requesting to generate a nonce with insufficient adjective count', () => { + const adjectives = 0; + + expect(gfynonce({ adjectives })) + .to.satisfy((result) => { + const pieces = getAdjectivesArrayFromNonce(result).slice(0, 1); + + if (!Array.isArray(pieces) || !pieces.length) return false; + + if (pieces.length === 1) return true; + + return false; + }); + }); + + it('when requesting to generate a nonce with insufficient adjective count and "." as a separator', () => { + const adjectives = 0; + const separator = '.'; + + expect(gfynonce({ adjectives, separator })) + .to.satisfy((result) => { + const pieces = result.split(separator).slice(0, 1); + + if (!Array.isArray(pieces) || !pieces.length) return false; + + if (pieces.length === 1) return true; + + return false; + }); + }); + }); + + describe('fallback to the maximum available', () => { + it('when requesting to generate a nonce with exceeding adjective count', () => { + const adjectives = ADJECTIVES.length + 100; + + expect(gfynonce({ adjectives })) + .to.satisfy((result) => { + const pieces = getAdjectivesArrayFromNonce(result).slice(0, ADJECTIVES.length); + + if (!Array.isArray(pieces) || !pieces.length) return false; + + if (pieces.length === ADJECTIVES.length) return true; + + return false; + }); + }); + + it('when requesting to generate a nonce with exceeding adjective count and "." as a separator', () => { + const adjectives = ADJECTIVES.length + 100; + const separator = '.'; + + expect(gfynonce({ adjectives, separator })) + .to.satisfy((result) => { + const pieces = result.split(separator).slice(0, ADJECTIVES.length); + + if (!Array.isArray(pieces) || !pieces.length) return false; + + if (pieces.length === ADJECTIVES.length) return true; + + return false; + }); + }); + }); + }); + + describe('custom nonce generation', () => { + it('should generate a nonce with 4 adjectives and no separator (default)', () => { + const adjectives = 4; + + expect(gfynonce({ adjectives })) + .to.match(nonceRegexBuilder(adjectives)); + }); + + it('should generate a nonce with 2 (default) adjectives and "." as separator', () => { + const adjectives = 2; + const separator = '.'; + + expect(gfynonce({ separator })) + .to.match(nonceRegexBuilder(adjectives, separator)); + }); + + it('should generate a nonce with 6 adjectives and "-" as separator', () => { + const adjectives = 6; + const separator = '-'; + + expect(gfynonce({ separator, adjectives })) + .to.match(nonceRegexBuilder(adjectives, separator)); + }); + + describe('adjective uniqueness', () => { + it('should generate a nonce with the most adjectives available without repeating any', () => { + const adjectives = ADJECTIVES.length; + + expect(gfynonce({ adjectives })) + .to.satisfy((result) => { + const pieces = getAdjectivesArrayFromNonce(result).slice(0, adjectives); + + if (!Array.isArray(pieces) || !pieces.length) return false; + + if (uniq(pieces).length === adjectives) return true; + + return false; + }); + }); + + it('should generate a nonce with the most adjectives available without repeating any and "." as a separator', () => { + const adjectives = ADJECTIVES.length; + const separator = '.'; + + expect(gfynonce({ adjectives, separator })) + .to.satisfy((result) => { + const pieces = result.split(separator).slice(0, adjectives); + + if (!Array.isArray(pieces) || !pieces.length) return false; + + if (uniq(pieces).length === adjectives) return true; + + return false; + }); + }); + }); + }); +}); \ No newline at end of file diff --git a/test/mocha.opts b/test/mocha.opts new file mode 100644 index 0000000..7903b88 --- /dev/null +++ b/test/mocha.opts @@ -0,0 +1 @@ +--require babel-register \ No newline at end of file