本文整理汇总了TypeScript中gensequence.genSequence函数的典型用法代码示例。如果您正苦于以下问题:TypeScript genSequence函数的具体用法?TypeScript genSequence怎么用?TypeScript genSequence使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了genSequence函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: seqAffWords
seqAffWords(tapPreApplyRules?: (w: string) => any) {
const seq = genSequence(this.src.dic);
const dicWords = tapPreApplyRules ? seq.map(a => (tapPreApplyRules(a), a)) : seq;
return dicWords
.filter(a => !!a.trim())
.concatMap(dicWord => this.aff.applyRulesToDicEntry(dicWord));
}
开发者ID:Jason-Rev,项目名称:hunspell-reader,代码行数:7,代码来源:IterableHunspellReader.ts
示例2: it
it('reads words', async () => {
const reader = await pReader;
const values = genSequence(reader)
.skip(10000)
.take(10)
.toArray();
expect(values.length).to.be.equal(10);
});
开发者ID:Jason-Rev,项目名称:hunspell-reader,代码行数:8,代码来源:IterableHunspellReader.test.ts
示例3: dicWordsSeq
/**
* @internal
*/
dicWordsSeq(): Sequence<WordInfo> {
return genSequence(this.src.dic)
.map(line => {
const [word, rules] = line.split('/', 2);
return { word, rules, prefixes: [], suffixes: [] };
})
;
}
开发者ID:Jason-Rev,项目名称:hunspell-reader,代码行数:11,代码来源:IterableHunspellReader.ts
示例4: Promise
return new Promise((resolve, reject) => {
let resolved = false;
const out = outFile ? fs.createWriteStream(outFile) : process.stdout;
const bufferedSeq = genSequence(batch(seq, 500)).map(batch => batch.join(''));
const dataStream = iterableToStream(bufferedSeq);
const fileStream = dataStream.pipe(out);
const endEvents = ['finish', 'close', 'end'];
function resolvePromise() {
if (!resolved) {
resolved = true;
resolve();
}
}
const endHandler = () => {
cleanupStreams();
setTimeout(resolvePromise, 10);
};
const errorHandler = (e: Error) => {
cleanupStreams();
reject(e);
};
listenToStreams();
function listenToStreams() {
endEvents.forEach(event => fileStream.addListener(event, endHandler));
fileStream.addListener('error', errorHandler);
dataStream.addListener('end', endHandler);
}
function cleanupStreams() {
endEvents.forEach(event => fileStream.removeListener(event, endHandler));
fileStream.removeListener('error', errorHandler);
dataStream.removeListener('end', endHandler);
}
});
开发者ID:Jason-Rev,项目名称:hunspell-reader,代码行数:37,代码来源:app.ts
示例5: processRules
export function processRules(affInfo: AffInfo): Map<string, Rule> {
const sfxRules: Sequence<Rule> = gs(affInfo.SFX || []).map(([, sfx]) => sfx).map(sfx => ({ id: sfx.id, type: 'sfx', sfx }));
const pfxRules: Sequence<Rule> = gs(affInfo.PFX || []).map(([, pfx]) => pfx).map(pfx => ({ id: pfx.id, type: 'pfx', pfx }));
const flagRules: Sequence<Rule> = GS.sequenceFromObject(affInfo as AffTransformFlags)
.filter(([key, value]) => !!affFlag[key] && !!value)
.map(([key, value]) => ({ id: value!, type: 'flag', flags: affFlag[key]}));
const rules = sfxRules.concat(pfxRules).concat(flagRules)
.reduce<Map<string, Rule>>((acc, rule) => { acc[rule.id] = rule; return acc; }, new Map<string, Rule>());
return rules;
}
开发者ID:Jason-Rev,项目名称:hunspell-reader,代码行数:11,代码来源:aff.ts
注:本文中的gensequence.genSequence函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论