1.1.0 • Published 7 years ago

tracery-es8 v1.1.0

Weekly downloads
3
License
ISC
Repository
github
Last release
7 years ago

Tracery

Build Status npm npm

Tracery: A story-grammar generation library for javascript

This package uses what is known as Syntactic Sugar: ES6's classes. They improve code readability and additionally, this package is designed for V8 5.9+ (which uses the new Compiler Pipeline, with TurboFan and Ignition). This is also a NPM library designed for Node.js, and requires minimum Node.js 8.x.

Installation

This is hosted at npm, so it can be installed like so:

$ npm install tracery-es8 --production
npm installation...

Example usage

const tracery = require('tracery-es8');

const grammar = tracery.createGrammar({
    animal: ['panda', 'fox', 'capybara', 'iguana'],
    emotion: ['sad', 'happy', 'angry', 'jealous'],
    origin: ['I am #emotion.a# #animal#.']
});

grammar.addModifiers(tracery.baseEngModifiers);

console.log(grammar.flatten('#origin#'));

Sample output:

I am a happy iguana.
I am an angry fox.
I am a sad capybara.