lib/annotation.helper.js
function getAnnotationInfo(name, fn, isArray) {

    if (!fn) { return null; }

    var str = fn.toString();
    var rgx = new RegExp('(?:@' + name + '\\()(.*)(?:\\))');

    var matches = rgx.exec(str);

    if (!matches || matches.length < 2) {
        return null;
    }

    var annotation = matches[1];
    if (isArray) {
        annotation = '{ "data": ' + annotation + '}';
    }

    // we want all double quotes in our string
    annotation = annotation.replace(/'/g, '"');

    // parse out the object from the string
    var obj = null;
    try {
        obj = JSON.parse(annotation);
    }
    catch (ex) {
        /* eslint no-console:0 */
        console.log('Annotation parse error with ' + annotation);
        throw ex;
    }

    if (isArray) {
        obj = obj.data;
    }

    return obj;
}
function getAnnotationInfo(name, fn, isArray) {

    if (!fn) { return null; }

    var str = fn.toString();
    var rgx = new RegExp('(?:@' + name + '\\()(.*)(?:\\))');

    var matches = rgx.exec(str);

    if (!matches || matches.length < 2) {
        return null;
    }

    var annotation = matches[1];
    if (isArray) {
        annotation = '{ "data": ' + annotation + '}';
    }

    // we want all double quotes in our string
    annotation = annotation.replace(/'/g, '"');

    // parse out the object from the string
    var obj = null;
    try {
        obj = JSON.parse(annotation);
    }
    catch (ex) {
        /* eslint no-console:0 */
        console.log('Annotation parse error with ' + annotation);
        throw ex;
    }

    if (isArray) {
        obj = obj.data;
    }

    return obj;
}
function getAnnotationInfo ( name , fn , isArray ) { if ( ! fn ) { return null ; } var str = fn . toString ( ) ; var rgx = new RegExp ( '(?:@' + name + '\\()(.*)(?:\\))' ) ; var matches = rgx . exec ( str ) ; if ( ! matches || matches . length < 2 ) { return null ; } var annotation = matches [ 1 ] ; if ( isArray ) { annotation = '{ "data": ' + annotation + '}' ; } // we want all double quotes in our string annotation = annotation . replace ( / ' / g , '"' ) ; // parse out the object from the string var obj = null ; try { obj = JSON . parse ( annotation ) ; } catch ( ex ) { /* eslint no-console:0 */ console . log ( 'Annotation parse error with ' + annotation ) ; throw ex ; } if ( isArray ) { obj = obj . data ; } return obj ; }
Get any annotation that follows the same format
@param name
@param fn
@param isArray
@returns {*}
Get any annotation that follows the same format