Skip to content

Commit

Permalink
refactor: move randomAdjective() in separate file
Browse files Browse the repository at this point in the history
  • Loading branch information
gr2m committed Oct 4, 2017
1 parent 2a6d3ec commit a9d4d07
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
7 changes: 2 additions & 5 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
module.exports = generateRandomString

const adjectives = require('adjectives')
const animals = require('animals')
const randomNumber = require('random-number-in-range')

const randomAdjective = require('./lib/random-adjective')

function generateRandomString (num) {
if (typeof num === 'number') {
return Array(num).fill().map(generateRandomString)
}

return [randomAdjective(), animals(), randomNumber(10, 99)].join('-')
}

function randomAdjective () {
return adjectives[randomNumber(0, adjectives.length - 1)]
}
6 changes: 6 additions & 0 deletions lib/random-adjective.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
const adjectives = require('adjectives')
const randomNumber = require('random-number-in-range')

module.exports = function randomAdjective () {
return adjectives[randomNumber(0, adjectives.length - 1)]
}

0 comments on commit a9d4d07

Please sign in to comment.