當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript papaparse.unparse函數代碼示例

本文整理匯總了TypeScript中papaparse.unparse函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript unparse函數的具體用法?TypeScript unparse怎麽用?TypeScript unparse使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了unparse函數的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: dumpToCSV

 public dumpToCSV(resultFile: string) {
   const newResult = _.mapKeys(this.result as _.Dictionary<any>, (v, k) => {
     if (k !== 'repoName') {
       return `${requestTypeMapping.get(this.requestType)}_${k}`;
     } else {
       return 'repoName';
     }
   });
   if (!fs.existsSync(resultFile)) {
     console.log(papa.unparse([newResult]));
     fs.writeFileSync(resultFile, papa.unparse([newResult]));
   } else {
     const file = fs.createReadStream(resultFile);
     papa.parse(file, {
       header: true,
       complete: parsedResult => {
         const originResults = parsedResult.data;
         const index = originResults.findIndex(originResult => {
           return originResult.repoName === newResult.repoName;
         });
         if (index === -1) {
           originResults.push(newResult);
         } else {
           originResults[index] = { ...originResults[index], ...newResult };
         }
         fs.writeFileSync(resultFile, papa.unparse(originResults));
       },
     });
   }
 }
開發者ID:elastic,項目名稱:kibana,代碼行數:30,代碼來源:lsp_test_runner.ts

示例2: numeral

        .then(jobs => {
          json.data = jobs
            .map(job => {
              //http://stackoverflow.com/a/10073761
              const formattedNumber: string = numeral(job.number).value() < 99999 ? `0000${job.number}`.slice(-5) : job.number.toString(),
                prefix = job.job_type === JobType.SERVICE_CALL ? 'S' : 'P',
                startMoment = moment(job.startDate),
                endMoment = moment(job.endDate),
                start = job.startDate && startMoment.isValid() ? startMoment.format('YYYY-MM-DD') : '',
                end = job.endDate && endMoment.isValid() ? endMoment.format('YYYY-MM-DD') : '';
              return [
                `${prefix}-${formattedNumber}`,
                job.name,
                job.customer.name,
                job.status,
                job.foreman,
                job.description,
                job.notes,
                start,
                end
              ];
            });

          const csv = PapaParse.unparse(json);
          resolve(csv);
        })
開發者ID:Resounding,項目名稱:Jobs-Web,代碼行數:26,代碼來源:csv-export.ts

示例3:

 complete: parsedResult => {
   const originResults = parsedResult.data;
   const index = originResults.findIndex(originResult => {
     return originResult.repoName === newResult.repoName;
   });
   if (index === -1) {
     originResults.push(newResult);
   } else {
     originResults[index] = { ...originResults[index], ...newResult };
   }
   fs.writeFileSync(resultFile, papa.unparse(originResults));
 },
開發者ID:elastic,項目名稱:kibana,代碼行數:12,代碼來源:lsp_test_runner.ts

示例4: downloadCSV

  public downloadCSV() {
    let csv = papa.unparse({
      fields: this.csvHeader,
      data: this.csvContent
    });

    var blob = new Blob([csv]);
    var a = window.document.createElement("a");
    a.href = window.URL.createObjectURL(blob);
    a.download = this.csvFilename;
    document.body.appendChild(a);
    a.click();
    document.body.removeChild(a);
  }
開發者ID:bitjson,項目名稱:copay,代碼行數:14,代碼來源:wallet-transaction-history.ts

示例5: downloadGhost

function downloadGhost(items: DimItem[], nameMap: { [key: string]: string }) {
  // We need to always emit enough columns for all perks
  const maxPerks = getMaxPerks(items);

  const data = items.map((item) => {
    const row: any = {
      Name: item.name,
      Hash: item.hash,
      Id: `"${item.id}"`,
      Tag: item.dimInfo.tag,
      Tier: item.tier,
      Owner: nameMap[item.owner],
      Locked: item.locked,
      Equipped: item.equipped,
      Notes: item.dimInfo.notes
    };

    addPerks(row, item, maxPerks);

    return row;
  });

  downloadCsv('destinyGhosts', Papa.unparse(data));
}
開發者ID:w1cked,項目名稱:DIM,代碼行數:24,代碼來源:dimCsvService.factory.ts

示例6: toCSV

export function toCSV(records: Record[]): string {
    return unparse(recordsToTable(records));
}
開發者ID:MaKleSoft,項目名稱:padlock,代碼行數:3,代碼來源:export.ts

示例7: downloadWeapons


//.........這裏部分代碼省略.........
    row.Owner = nameMap[item.owner];
    if (item.isDestiny1()) {
      row['% Leveled'] = (item.percentComplete * 100).toFixed(0);
    }
    row.Locked = item.locked;
    row.Equipped = item.equipped;
    if (item.isDestiny1()) {
      row.Year = item.year;
    } else if (item.isDestiny2()) {
      row.Year = D2SeasonInfo[item.season].year;
    }
    if (item.isDestiny2()) {
      row.Season = item.season;
      row.Event = item.event ? events[item.event] : events[0];
    }
    if (item.dtrRating && item.dtrRating.overallScore) {
      row['DTR Rating'] = item.dtrRating.overallScore;
      row['# of Reviews'] = item.dtrRating.ratingCount;
    } else {
      row['DTR Rating'] = 'N/A';
      row['# of Reviews'] = 'N/A';
    }

    const stats = {
      aa: 0,
      impact: 0,
      range: 0,
      stability: 0,
      rof: 0,
      reload: 0,
      magazine: 0,
      equipSpeed: 0,
      drawtime: 0,
      chargetime: 0,
      accuracy: 0
    };

    if (item.stats) {
      item.stats.forEach((stat) => {
        if (stat.value) {
          switch (stat.statHash) {
            case 1345609583: // Aim Assist
              stats.aa = stat.value;
              break;
            case 4043523819: // Impact
              stats.impact = stat.value;
              break;
            case 1240592695: // Range
              stats.range = stat.value;
              break;
            case 155624089: // Stability
              stats.stability = stat.value;
              break;
            case 4284893193: // Rate of fire
              stats.rof = stat.value;
              break;
            case 4188031367: // Reload
              stats.reload = stat.value;
              break;
            case 3871231066: // Magazine
            case 925767036: // Energy
              stats.magazine = stat.value;
              break;
            case 943549884: // Equip Speed
              stats.equipSpeed = stat.value;
              break;
            case 447667954: // Draw Time
              stats.drawtime = stat.value;
              break;
            case 2961396640: // Charge Time
              stats.chargetime = stat.value;
              break;
            case 1591432999: // accuracy
              stats.accuracy = stat.value;
              break;
          }
        }
      });
    }

    row.AA = stats.aa;
    row.Impact = stats.impact;
    row.Range = stats.range;
    row.Stability = stats.stability;
    row.ROF = stats.rof;
    row.Reload = stats.reload;
    row.Mag = stats.magazine;
    row.Equip = stats.equipSpeed;
    row.DrawTime = stats.drawtime;
    row.ChargeTime = stats.chargetime;
    row.Accuracy = stats.accuracy;

    row.Notes = item.dimInfo.notes;

    addPerks(row, item, maxPerks);

    return row;
  });
  downloadCsv('destinyWeapons', Papa.unparse(data));
}
開發者ID:w1cked,項目名稱:DIM,代碼行數:101,代碼來源:dimCsvService.factory.ts

示例8: downloadArmor

function downloadArmor(items: DimItem[], nameMap: { [key: string]: string }) {
  // We need to always emit enough columns for all perks
  const maxPerks = getMaxPerks(items);

  const data = items.map((item) => {
    const row: any = {
      Name: item.name,
      Hash: item.hash,
      Id: `"${item.id}"`,
      Tag: item.dimInfo.tag,
      Tier: item.tier,
      Type: item.typeName,
      Equippable: equippable(item),
      [item.isDestiny1() ? 'Light' : 'Power']: item.primStat && item.primStat.value
    };
    if (item.isDestiny2() && item.masterworkInfo) {
      row['Masterwork Type'] = item.masterworkInfo.statName;
      row['Masterwork Tier'] = item.masterworkInfo.statValue
        ? item.masterworkInfo.statValue <= 10
          ? item.masterworkInfo.statValue
          : 10
        : undefined;
    }
    row.Owner = nameMap[item.owner];
    if (item.isDestiny1()) {
      row['% Leveled'] = (item.percentComplete * 100).toFixed(0);
    }
    row.Locked = item.locked;
    row.Equipped = item.equipped;
    if (item.isDestiny1()) {
      row.Year = item.year;
    } else if (item.isDestiny2()) {
      row.Year = D2SeasonInfo[item.season].year;
    }
    if (item.isDestiny2()) {
      row.Season = item.season;
      row.Event = item.event ? events[item.event] : events[0];
    }
    if (item.dtrRating && item.dtrRating.overallScore) {
      row['DTR Rating'] = item.dtrRating.overallScore;
      row['# of Reviews'] = item.dtrRating.ratingCount;
    } else {
      row['DTR Rating'] = 'N/A';
      row['# of Reviews'] = 'N/A';
    }
    if (item.isDestiny1()) {
      row['% Quality'] = item.quality ? item.quality.min : 0;
    }
    const stats: { [name: string]: { value: number; pct: number } } = {};
    if (item.isDestiny1() && item.stats) {
      item.stats.forEach((stat) => {
        let pct = 0;
        if (stat.scaled && stat.scaled.min) {
          pct = Math.round((100 * stat.scaled.min) / (stat.split || 1));
        }
        stats[stat.name] = {
          value: stat.value || 0,
          pct
        };
      });
    } else if (item.isDestiny2() && item.stats) {
      item.stats.forEach((stat) => {
        stats[stat.name] = {
          value: stat.value || 0,
          pct: 0
        };
      });
    }
    if (item.isDestiny1()) {
      row['% IntQ'] = stats.Intellect ? stats.Intellect.pct : 0;
      row['% DiscQ'] = stats.Discipline ? stats.Discipline.pct : 0;
      row['% StrQ'] = stats.Strength ? stats.Strength.pct : 0;
      row.Int = stats.Intellect ? stats.Intellect.value : 0;
      row.Disc = stats.Discipline ? stats.Discipline.value : 0;
      row.Str = stats.Strength ? stats.Strength.value : 0;
    } else {
      row.Mobility = stats.Intellect ? stats.Intellect.value : 0;
      row.Recovery = stats.Recovery ? stats.Recovery.value : 0;
      row.Resilience = stats.Resilience ? stats.Resilience.value : 0;
    }

    row.Notes = item.dimInfo.notes;

    addPerks(row, item, maxPerks);

    return row;
  });
  downloadCsv('destinyArmor', Papa.unparse(data));
}
開發者ID:w1cked,項目名稱:DIM,代碼行數:89,代碼來源:dimCsvService.factory.ts


注:本文中的papaparse.unparse函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。