Giter Club home page Giter Club logo

biojs-io-parser's Introduction

biojs-io-parser

Build Status NPM version NPM downloads

A small, generic parser module.

It expects that you provide at least a method parse (see below for more details).

Provided methods

read(url)

Parses an url an calls your parse method with the returned body.

parser.read("http://your-url", function(err, model) {
	// model is the parsed url
});

If callback is undefined, read returns a promise.

var p = parser.read("http://your-url");
//...
p.then(function(model) {
	// model is the parsed url
}, function(err){
	console.error("err happened during downloading", err);
});

(more to come)

Expected methods

Your parser should have the following methods:

  • parse: Takes in an entire file as string and returns the JSON representation

Optional:

  • write: Takes the JSON representation of a file and writes it in the custom format

If the file is line-by-line, one should create a new instance of the parser:

  • parseLine: parses another line
  • result: returns the current, resulting object of the parsing process.

How to extend

With functions

var parser = function(){
  this.parse = function(data){
      return data;
  };
  Parser.mixin(this);
};

With objects

var throughParserAlt = {
  parse: function(data) {
    return data;
  }
};
Parser.mixin(throughParserAlt);

License

Apache 2

biojs-io-parser's People

Contributors

wilzbach avatar

Stargazers

Matúš Kalaš avatar Ricardo H. Ramírez-Gonzalez avatar  avatar

Watchers

Ian Mulvany avatar Tim Ruffles avatar  avatar Miguel Pignatelli avatar James Cloos avatar Matúš Kalaš avatar Rafael C Jimenez avatar Gustavo Salazar avatar Michiel Helvensteijn avatar  avatar  avatar José Villaveces avatar Carlos avatar  avatar

biojs-io-parser's Issues

Expected behaviour for multiline formats

In case that a "unit" of information is contained in more than one line, what should be done in the readline method? Intuitively, I would say read the whole unit.
R.

support streams

The generic BioJS parser should allow components to be Duplexstreams.

Problem (atm): adding the browserified stream package will add about 120 to 180kB of unminified source code.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.