lundi 17 août 2015

expose properties from node module

I've NodeJs App with specific module which is parsing some document. In different module I need different properties from the following parser...for example in module A I need the prop and module B I need the config etc.

My question is how is recommended to expose the properties after the parse...as a global properties in the module?Any other way ? And when its recommended to do the parse? when the first method invoked

Here I expose all the properties in the parse which im not sure if it the right way...

parse = function (key, data) {
    var ymlObj = ymlParser.parse(data);
    return {
        key: ymlObj.def.key,
        config: ymlObj.config,
        prop :ymlObj.prop

    }

};

module.exports = {
    parse: parse
};

So which is responsible to call to the parser since this done only One time... The first method call to this module?

Aucun commentaire:

Enregistrer un commentaire