wiseService/wiseSource.js
/**
   * Util function to parse tagger formatted data
   * @param {string} body - the raw CSV data
   * @param {function} setCb - the function to call for each row found
   * @param {function} endCB - all done parsing
   */
Util function to parse tagger formatted data
@param {string} body - the raw CSV data
@param {function} setCb - the function to call for each row found
@param {function} endCB - all done parsing
Util function to parse tagger formatted data @param { string } body - the raw CSV data @param { function } setCb - the function to call for each row found @param { function } endCB - all done parsing
parseTagger (body, setCb, endCb) {
    const lines = body.toString().split(/\r?\n/);
    this.view = '';
    for (let l = 0, llen = lines.length; l < llen; l++) {
      if (lines[l][0] === '#') {
        this.parseFieldDef(lines[l]);
        continue;
      }
      if (lines[l].match(/^\s*$/)) {
        continue;
      }
      const args = [];
      const parts = lines[l].split(';');
      for (let p = 1; p < parts.length; p++) {
        const kv = splitRemain(parts[p], '=', 1);
        if (kv.length !== 2) {
          console.log('WARNING -', this.section, "- ignored extra piece '" + parts[p] + "' from line '" + lines[l] + "'");
          continue;
        }
        if (this.shortcuts[kv[0]] !== undefined) {
          args.push(this.shortcuts[kv[0]].pos);
        } else if (WISESource.field2Pos[kv[0]]) {
          args.push(WISESource.field2Pos[kv[0]]);
        } else {
          args.push(this.api.addField('field:' + kv[0]));
        }
        args.push(kv[1]);
      }
      setCb(parts[0], WISESource.encodeResult.apply(null, args));
    }
    if (this.view !== '') {
      this.api.addView(this.section, this.view);
    }
    endCb(null);
  }
parseTagger ( body , setCb , endCb ) { const lines = body . toString ( ) . split ( / \r?\n / ) ; this . view = '' ; for ( let l = 0 , llen = lines . length ; l < llen ; l ++ ) { if ( lines [ l ] [ 0 ] === '#' ) { this . parseFieldDef ( lines [ l ] ) ; continue ; } if ( lines [ l ] . match ( / ^\s*$ / ) ) { continue ; } const args = [ ] ; const parts = lines [ l ] . split ( ';' ) ; for ( let p = 1 ; p < parts . length ; p ++ ) { const kv = splitRemain ( parts [ p ] , '=' , 1 ) ; if ( kv . length !== 2 ) { console . log ( 'WARNING -' , this . section , "- ignored extra piece '" + parts [ p ] + "' from line '" + lines [ l ] + "'" ) ; continue ; } if ( this . shortcuts [ kv [ 0 ] ] !== undefined ) { args . push ( this . shortcuts [ kv [ 0 ] ] . pos ) ; } else if ( WISESource . field2Pos [ kv [ 0 ] ] ) { args . push ( WISESource . field2Pos [ kv [ 0 ] ] ) ; } else { args . push ( this . api . addField ( 'field:' + kv [ 0 ] ) ) ; } args . push ( kv [ 1 ] ) ; } setCb ( parts [ 0 ] , WISESource . encodeResult . apply ( null , args ) ) ; } if ( this . view !== '' ) { this . api . addView ( this . section , this . view ) ; } endCb ( null ) ; }
Util function to parse tagger formatted data
 @param {string} body - the raw CSV data
 @param {function} setCb - the function to call for each row found
 @param {function} endCB - all done parsing
Util function to parse tagger formatted data @param { string } body - the raw CSV data @param { function } setCb - the function to call for each row found @param { function } endCB - all done parsing