lib/index.js
function parse(messageType, args) {
        const options = getOptions(messageType);
        /** Interpreter */
        if (typeof options.interpreter === "function") {
            for (const index in args) {
                /** Let string be without additional ' ' */
                if (typeof args[index] === "string") {
                    continue;
                }
                args[index] = options.interpreter(args[index]);
            }
        }
        /** Label */
        if (options.labels) {
            args.unshift(`[${messageType.toUpperCase()}]`);
        }
        /** Timestamp */
        if (options.timestamp) {
            switch (typeof options.timestamp) {
                case "boolean":
                    args.unshift(`[${new Date().toLocaleString()}]`);
                    break;
                case "string":
                    args.unshift(`[${moment().format(options.timestamp)}]`);
                    break;
                default:
                    throw new Error(`Invalid timestamp type (${typeof options.timestamp}). Should be (boolean | string)`);
            }
        }
        return args.join(" ");
    }
function parse(messageType, args) {
        const options = getOptions(messageType);
        /** Interpreter */
        if (typeof options.interpreter === "function") {
            for (const index in args) {
                /** Let string be without additional ' ' */
                if (typeof args[index] === "string") {
                    continue;
                }
                args[index] = options.interpreter(args[index]);
            }
        }
        /** Label */
        if (options.labels) {
            args.unshift(`[${messageType.toUpperCase()}]`);
        }
        /** Timestamp */
        if (options.timestamp) {
            switch (typeof options.timestamp) {
                case "boolean":
                    args.unshift(`[${new Date().toLocaleString()}]`);
                    break;
                case "string":
                    args.unshift(`[${moment().format(options.timestamp)}]`);
                    break;
                default:
                    throw new Error(`Invalid timestamp type (${typeof options.timestamp}). Should be (boolean | string)`);
            }
        }
        return args.join(" ");
    }
function parse ( messageType , args ) { const options = getOptions ( messageType ) ; /** Interpreter */ if ( typeof options . interpreter === "function" ) { for ( const index in args ) { /** Let string be without additional ' ' */ if ( typeof args [ index ] === "string" ) { continue ; } args [ index ] = options . interpreter ( args [ index ] ) ; } } /** Label */ if ( options . labels ) { args . unshift ( ` ${ messageType . toUpperCase ( ) } ` ) ; } /** Timestamp */ if ( options . timestamp ) { switch ( typeof options . timestamp ) { case "boolean" : args . unshift ( ` ${ new Date ( ) . toLocaleString ( ) } ` ) ; break ; case "string" : args . unshift ( ` ${ moment ( ) . format ( options . timestamp ) } ` ) ; break ; default : throw new Error ( ` ${ typeof options . timestamp } ` ) ; } } return args . join ( " " ) ; }
Prepare message and return as string
@param {string} messageType
@param args
@returns {string}
Prepare message and return as string