lib/processors/Formatter.class.js
/**
     * Add a placeholder to a set of patterns that's available for the formatter. Patterns are processed either in
     * order of their pattern length (longer > shorter) or using the priority parameter, if set.
     * @param {string} pattern              The pattern to match (without the "%" prefix)
     * @param {processorFunction} processor The function that will process the message
     * @param {number} [priority=1]         An optional priority for a processor. If none is set, patterns will be
     *                                      matched from longest to shortest.
     */
Add a placeholder to a set of patterns that's available for the formatter. Patterns are processed either in
order of their pattern length (longer > shorter) or using the priority parameter, if set.
@param {string} pattern              The pattern to match (without the "%" prefix)
@param {processorFunction} processor The function that will process the message
@param {number} [priority=1]         An optional priority for a processor. If none is set, patterns will be
matched from longest to shortest.
Add a placeholder to a set of patterns that ' s available for the formatter . Patterns are processed either in order of their pattern length ( longer > shorter ) or using the priority parameter if set . @param { string } pattern The pattern to match ( without the " % " prefix ) @param { processorFunction } processor The function that will process the message @param { number } [ priority = 1 ] An optional priority for a processor . If none is set patterns will be matched from longest to shortest .
static addPattern(pattern, processor, priority) {
        let patternList = pattern.split(/[ ,|;]/);
        for (let i of patternList) {
            if (i.length) {
                patterns.push({
                    matcher: "%" + i,
                    processor,
                    priority: _.isNumber(priority) ? priority : 1
                });
            }
        }
        patterns.sort((a,b) => {
            let diff = b.priority - a.priority;
            if (diff != 0) {
                return diff;
            }
            return b.matcher.length - a.matcher.length;
        });
    }
static addPattern ( pattern , processor , priority ) { let patternList = pattern . split ( / [ ,|;] / ) ; for ( let i of patternList ) { if ( i . length ) { patterns . push ( { matcher : "%" + i , processor , priority : _ . isNumber ( priority ) ? priority : 1 } ) ; } } patterns . sort ( ( a , b ) => { let diff = b . priority - a . priority ; if ( diff != 0 ) { return diff ; } return b . matcher . length - a . matcher . length ; } ) ; }
Add a placeholder to a set of patterns that's available for the formatter.
Add a placeholder to a set of patterns that ' s available for the formatter .