• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript sync.default函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中csv-parse/lib/sync.default函数的典型用法代码示例。如果您正苦于以下问题:TypeScript default函数的具体用法?TypeScript default怎么用?TypeScript default使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了default函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。

示例1: parseRegions

function parseRegions(fileContent: string): RegionMap {
  const questionRows: Row[] = parse(fileContent);
  const regions = questionRows.slice(1).map(row => ({
    id: row[0],
    name: row[1]
  }));
  return R.indexBy(r => r.id, regions) as RegionMap;
}
开发者ID:shybyte,项目名称:wahlomat,代码行数:8,代码来源:convert.ts


示例2: it

 it('parse', () => {
     const lines = parse("Nom,Entreprise,Commentaire,Interet\n" +
         "Karim Sanglan ,Orange,Tu dois le faire,5\n", {columns:true})
     expect(lines).eql([{ Nom: 'Karim Sanglan ',
         Entreprise: 'Orange',
         Commentaire: 'Tu dois le faire',
         Interet: '5' }])
 });
开发者ID:martinsson,项目名称:martinsson.github.io,代码行数:8,代码来源:to-html.spec.ts


示例3: parseQuestions

function parseQuestions(fileContent: string): Question[] {
  const questionRows: Row[] = parse(fileContent);
  return questionRows.slice(1).map(row => ({
    id: row[0],
    initiative: (row[3] || 'anonym').replace('annonym', 'anonym'),
    initiativeAnswer: ANSWER.yes,
    initiativeReason: row[2],
    text: row[1],
  }));
}
开发者ID:shybyte,项目名称:wahlomat,代码行数:10,代码来源:convert.ts


示例4: toHtml

export async function toHtml(csvContent: string) {
    const lins = parse(csvContent, {columns:true})
    return lins.map((line: any) => {
        const phrase = line.Commentaire.replace("\n", '<br>' )
        const name = line.Nom.trim()
        const company = line.Entreprise
        return "<blockquote>\n" +
            `${phrase}\n<span>${name} - ${company}</span>\n` +
            "</blockquote>"
    }).join('\n')

}
开发者ID:martinsson,项目名称:martinsson.github.io,代码行数:12,代码来源:to-html.ts


示例5: parseCandidateAnswers

function parseCandidateAnswers(fileContent: string): Candidate[] {
  const rows: string[][] = parse(fileContent);
  const rowsByCandidate = R.groupBy(row => row[AnswerFileCols.NAME], rows.slice(1));
  const candidateRowPairs: [string, Row[]][] = R.toPairs(rowsByCandidate) as any;
  return candidateRowPairs.map((candidateAndAnswerRows: [string, Row[]]) => {
    const candidateName = candidateAndAnswerRows[0];
    const answerRows = candidateAndAnswerRows[1];
    const oneRow = answerRows[0];
    return {
      answers: getAnswerMapFromRows(answerRows),
      id: candidateName,
      name: candidateName,
      party: oneRow[AnswerFileCols.PARTY],
      reasons: getReasonsMapFromRows(answerRows),
      regions: oneRow[AnswerFileCols.REGION].split(/,\s+/)
    };
  });
}
开发者ID:shybyte,项目名称:wahlomat,代码行数:18,代码来源:convert.ts


示例6: jsonParse

export const csvParse = (csvContent, options) => {
  const { hasCategory } = options

  const mergeRows = (acc, { question, answer, answer2, category, action }) => {
    const [prevRow] = acc.slice(-1)
    const isSameAnswer = prevRow && (prevRow.answer === answer && (!answer2 || answer2 === prevRow.answer2))
    if (isSameAnswer) {
      return [...acc.slice(0, acc.length - 1), { ...prevRow, questions: [...prevRow.questions, question] }]
    }
    const categoryWrapper = hasCategory ? { category } : {}
    return [...acc, { answer, answer2, action, ...categoryWrapper, questions: [question] }]
  }
  const categoryWrapper = hasCategory ? ['category'] : []
  const rows = parseCsvToJson(csvContent, {
    columns: ['question', 'action', 'answer', 'answer2', ...categoryWrapper]
  }).reduce(mergeRows, [])

  // We trim the header if detected in the first row
  if (get(rows, '0.action') === 'action') {
    rows.splice(0, 1)
  }

  return jsonParse(rows, options)
}
开发者ID:alexsandrocruz,项目名称:botpress,代码行数:24,代码来源:parsers.ts


示例7: require

};
*/
declare var process: any;
declare var require: any;
declare var __dirname: any;
declare var exports: any;
declare var self: any;
if (typeof process === 'object')
{
	var parse = require("csv-parse/lib/sync");
	var iconv = require("iconv-lite");
	var fs = require('fs');
	var assert = require('assert');

	//读取任务模板
	var task_lib_records = parse(iconv.decode(fs.readFileSync(__dirname + '/WeeklyTaskLib.csv'), 'gbk'));
	TASK_LIB = [];
	TASK_LIB.push(null);
	for (let i = 1; i < task_lib_records.length; ++i)
	{
		var line = task_lib_records[i];
		var type = line[0];
		var count = parseInt(line[1]);
		var failCount = parseInt(line[2]);
		var desc = line[3];
		assert(TASK_LIST1.some(x => x.type === type), `任务类型type一定要有效的,type=${type}`);
		assert(count >= 0, 'count must be number >= 0');
		assert(failCount >= 0 && failCount <= 5, 'failCount must be a number >= 0 && <= 5');
		assert(typeof desc === 'string', 'desc must be a string');
		TASK_LIB.push({ type: type, maxCount: count, failCount: failCount, desc: desc });
	}
开发者ID:hUangDDD,项目名称:bally,代码行数:31,代码来源:WeeklyTaskDefine.ts


示例8: require

	14,
	13,
]*/

declare var process: any;
declare var require: any;
declare var __dirname: any;
declare var exports: any;
declare var self:any;
if (typeof process === 'object')
{
	var parse = require("csv-parse/lib/sync");
	var iconv = require("iconv-lite");
	var fs = require('fs');
	var assert = require('assert');
	var records = parse(iconv.decode(fs.readFileSync(__dirname + '/PetRules.csv'), 'gbk'));
	assert(records.length === MAX_PET_COUNT + 1);
	PET_NAMES = [];
	PET_REAL_COLORS = [];
	PET_BASE_SCORE = [];
	PET_UP_SCORE = [];
	PET_SKILL = [];
	for (let i = 0; i < MAX_PET_COUNT; ++i)
	{
		let line = records[i + 1];
		PET_NAMES.push(line[0]);
		PET_REAL_COLORS.push(line[1]);
		let skill = parseInt(line[2]);
		let baseScore = parseInt(line[3]);
		let upScore = parseInt(line[4]);
		assert(typeof skill === 'number');
开发者ID:hUangDDD,项目名称:bally,代码行数:31,代码来源:PetRules.ts



注:本文中的csv-parse/lib/sync.default函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript csvtojson.Converter类代码示例发布时间:2022-05-24
下一篇:
TypeScript csv-parse.default函数代码示例发布时间:2022-05-24
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap