-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
26 lines (20 loc) · 947 Bytes
/
Copy pathindex.js
File metadata and controls
26 lines (20 loc) · 947 Bytes
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
const data = require('./data.json');
const { random, sampleSize: sample } = require('lodash');
const subjects = ['cats', 'birds', 'fish', 'ocean waves', 'trees', 'poppies'];
const getRandomValue = (key, opts) => (key in opts ? opts[key] : sample(data[key]));
const promptmaker = (opts = {}) => {
const medium = getRandomValue('mediums', opts);
const subject = getRandomValue('subjects', opts);
const movement = getRandomValue('movements', opts);
const artist = getRandomValue('artists', opts);
const flavors = getRandomValue('flavors', opts) || sample(data.flavors, random(1, 3));
let prompt = `${medium} of ${subject} ${movement} by ${artist}`;
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;