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


TypeScript gensequence.genSequence函數代碼示例

本文整理匯總了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;未經允許,請勿轉載。