@refabric/text
TypeScript icon, indicating that this package has built-in type declarations

1.1.4 • Public • Published

Refabric Text

Wrapper around tracery-grammar to generate text based on custom grammar files.

Get Started

Install text.

npm install @refabric/text

Example

// index.js
import { TextGenerator } from '@refabric/text';

// Grab a list of files here...

const grammars = files.map((file) => {
  if (file.endsWith('.grammar')) {
    return fs.readFileSync(path.resolve(__dirname, file), 'utf-8');
  }
});
const generator = new TextGenerator(grammars.filter(Boolean));
console.log(generator.think('Example'));

some-file-name.grammar

Example

This is ->

the example.
an example.
some example.

Readme

Keywords

none

Package Sidebar

Install

npm i @refabric/text

Weekly Downloads

1

Version

1.1.4

License

ISC

Unpacked Size

11.8 kB

Total Files

12

Last publish

Collaborators

  • popon