@johnallentech/generator

1.0.2 • Public • Published

Generators

The vast majority of the packages in Chance are generators. Generators use pseudo-random number generator to generate a specified data type. The abstract classes and interfaces for generators are maintained in this package.

Creating a generator

From the package root, run the following command and follow the prompts:

$ yarn run generator:create

This should generate a new package in the /packages directory with all of the necessary files to start with.

Next, you write your generator function body and tests. Once, your code is merged in, your generator will be published as a separate npm package in the @johnallentech namespace.

Adding generator methods to the Chance class

You can also add your generator to the Chance class as a method.

Once you write your generator code and tests, you can install the package locally:

$ yarn workspace @johnallentech/chance add @johnallentech/YOUR_GENERATOR@1.0.0

Then you can generate the boilerplate code to add the generator as a method:

$ yarn method:add

Now you can use your generator as a method on the Chance class.

Readme

Keywords

none

Package Sidebar

Install

npm i @johnallentech/generator

Weekly Downloads

1

Version

1.0.2

License

MIT

Unpacked Size

28 kB

Total Files

74

Last publish

Collaborators

  • john-allen-tech