-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.js
30 lines (23 loc) · 1.02 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
const data = require('./data.json')
const { random, sampleSize: sample } = require('lodash')
const subjects = ['cats', 'birds', 'fish', 'ocean waves', 'trees', 'poppies']
const promptmaker = (opts = {}) => {
const medium = 'medium' in opts ? opts.medium : sample(data.mediums)
const subject = 'subject' in opts ? opts.subject : sample(subjects)
const movement = 'movement' in opts ? opts.movement : sample(data.movements)
const artist = 'artist' in opts ? opts.artist : sample(data.artists)
const flavors =
'flavors' in opts ? opts.flavors : sample(data.flavors, random(1, 3))
let prompt = `${medium} of ${subject} ${movement}`
// artist can be disabled by setting a falsy value
if (artist) prompt += ` by ${artist}`
// allow custom flavors
if (flavors) prompt += `, ${flavors.join(', ')}`
return prompt
}
promptmaker.mediums = data.mediums
promptmaker.subjects = subjects
promptmaker.artists = data.artists
promptmaker.movements = data.movements
promptmaker.flavors = data.flavors
module.exports = promptmaker