tracery-es8

    1.1.0 • Public • Published

    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.

    Keywords

    Install

    npm i tracery-es8

    DownloadsWeekly Downloads

    1

    Version

    1.1.0

    License

    ISC

    Last publish

    Collaborators

    • kyranet