1.2.1 • Published 3 years ago

randomgen-parser v1.2.1

Weekly downloads
341
License
MIT
Repository
github
Last release
3 years ago

randomgen-parser

Parses RandomGen

Installation

npm install randomgen-parser

API

Importing

const RandomGenParser = require('randomgen-parser');

Using

The randomgen-parser module exports a class. The constructor accepts two arguments. The first one is the string to parse. The second one is optional and is the string to parse. The results of the parsing will be stored at the parsed property of the object. Here are some more functions:

const RandomGenParser = require('randomgen-parser');

new RandomGenParser('').parsed;
// -> [ { type: "newline", raw: "", stringValue: "", interpretedValue: "", pos: { line: 1, column: 0 }, afterLinebreak: null } ]

let parser = new RandomGenParser('$hello world\na\nb\nc\n');

parser.setString('$hello world\na\nb\nc\nd\n');
parser.reparse();

Here is the format of the config:

{
  linebreaks: String
}

For more information on the functions given and the types, look at the types.

Extending

The randomgen-parser module allows to extend and create plugins for it. An example plugin that would use # instead of // for line comments is:

module.exports = {
  lineCommentStart: '#',
  lineCommentValueReg: /^[\s\uFEFF\xA0]*#(.*)$/
};

The exported object must contain properties that are intended to be edited of the class.

Development

Run the following to convert typescript to javascript:

npm run build
1.2.1

3 years ago

1.2.0

3 years ago

1.1.0

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.2

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago