lacona-addon-simple

0.2.0 • Public • Published

lacona-addon-simple

Build Status Coverage Status

Removal Notice

This module is no longer used. On modern versions of Lacona, its functionality can be reproduced with:

var Writable = require('stream').Writable;
 
function toArray(done) {
  var stream = new Writable({ objectMode: true });
  var list = [];
  stream.write = function(obj) {
    list.push(obj);
  };
 
  stream.end = function() {
    done(list);
  };
 
  return stream;
}
 
parser.parse(input).pipe(toArray(function (data) {
  console.log(data);
});

Historical Information

By default, the lacona parser behaves like a stream outputting parse results in the order that they are computed. However, sometimes for simple applications you do not need this complex behavior. lacona-addon-simple simplifies the results of the parser to return all parse results in a callback.

var lacona = require('lacona');
var Simple = require('lacona-addon-simple');
var laconaParser = new lacona.Parser();
 
var simpleParser = new Simple(laconaParser);
 
assert(simpleParser.parser === laconaParser);
 
simpleParser.parse('input', function (err, data) {
  data.forEach(console.log);
});

Installation

npm install lacona-addon-simple

Use

lacona-addon-simple exports a single constructor. The constructor must be invoked using new. It accepts a single argument, a lacona.Parser instance.

The returned object has one property and one method:

  • property parser - the instance of lacona.Parser passed to the constructor. Can be modified at will.
  • method parse - a function that takes an input string and a callback. It will parse the input string using parser and return an array of all results to the callback, or an error.

Package Sidebar

Install

npm i lacona-addon-simple

Weekly Downloads

2

Version

0.2.0

License

MIT

Last publish

Collaborators

  • brandonhorst