当前位置: 首页>>代码示例>>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;未经允许,请勿转载。