Skip to content

Instantly share code, notes, and snippets.

@brudil
Last active August 1, 2017 08:44
Show Gist options
  • Save brudil/47aedccfef84816e13ad6e38bbb8d6d2 to your computer and use it in GitHub Desktop.
Save brudil/47aedccfef84816e13ad6e38bbb8d6d2 to your computer and use it in GitHub Desktop.
import { createGeneration, gs, needsArticle, useArticle } from 'generation-game';
const names = [
'Dave',
'Chris',
'Sally',
'Lucy',
];
const places = [
'London',
needsArticle('Moon'),
'Brighton',
needsArticle('small shop left of Halfords'),
];
const templates = [
gs`I went to ${useArticle('the', places)} and it was wonderful`, // "I went to the Moon and it was wonderful"
gs`Beyond ${useArticle(places)} is a fella named ${names}`,
];
const generator = createGeneration(templates);
console.log(generator.totalCombinations) // 32
console.log(generator.generate()) // "Beyond a small shop left of Halfords is a fella named Dave"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment