0.0.2 • Published 7 years ago

es2node v0.0.2

Weekly downloads
2
License
MIT
Repository
github
Last release
7 years ago

es2node stable

npm install es2node

EcmaScript to NodeJS class converter.

Example

Input class (ES7+ format):

import jfObject from 'jf-object';

/**
 * Clase de ejemplo.
 *
 *
 * @namespace jf
 * @class     jf.Example
 * @extends   jf.Object
 */
export default class jfExample extends jfObject
{
    /**
     * Nombre de ejemplo.
     *
     * @property name
     * @type     {String}
     */
    name = '';

    /**
     * Valor del ejemplo.
     *
     * @property value
     * @type     {String}
     */
    value = '';

    /**
     * Constructor de la clase.
     *
     * @param {Object|null} config Configuración a aplicar a la instancia.
     */
    constructor(config)
    {
        super();
        if (config)
        {
            this.setProperties(config);
        }
    }

    /**
     * Método de ejemplo.
     *
     * @return {String} Resultado del ejemplo.
     */
    build()
    {
        return `Nombre: ${this.name}\nValor : ${this.value}`;
    }
}

Output class (CommonJS):

const jfObject = require('jf-object');

/**
 * Clase de ejemplo.
 *
 *
 * @namespace jf
 * @class     jf.Example
 * @extends   jf.Object
 */
class jfExample extends jfObject
{
    /**
     * Constructor de la clase.
     *
     * @param {Object|null} config Configuración a aplicar a la instancia.
     */
    constructor(config)
    {
        super();
        //-----------------------------------------------------------------------------
        // Propiedades de la clase.
        //-----------------------------------------------------------------------------
        /**
         * Nombre de ejemplo.
         *
         * @property name
         * @type     {String}
         */
        this.name = '';
        /**
         * Valor del ejemplo.
         *
         * @property value
         * @type     {String}
         */
        this.value = '';    
        //-----------------------------------------------------------------------------
        if (config)
        {
            this.setProperties(config);
        }
    }

    /**
     * Método de ejemplo.
     *
     * @return {String} Resultado del ejemplo.
     */
    build()
    {
        return `Nombre: ${this.name}\nValor : ${this.value}`;
    }
}

module.exports = jfExample;