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


TypeScript diacritics.remove函數代碼示例

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


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

示例1: async

router.post('/save', async (req: any, res) => {
  if (!req.user.admin) {
    res.status(403);
    return;
  }

  const ideogram = ideogramsConverter.convertIdeogramsToUtf16(
    await ideogramsConverter.traditionalToSimplified(req.body.ideograms),
  );

  const pronunciation = req.body.pinyin.toLowerCase();

  let response = await knex('cjk')
    .where({
      ideogram,
      pronunciation,
    })
    .select('id');

  if (!response.length) {
    response = await knex('cjk')
      .where({
        ideogram,
        main: 1,
      })
      .select('id');
  }

  if (response.length) {
    const id = response[0].id;
    await CjkRepository.save({
      id,
      definition_pt: JSON.stringify(req.body.dictionary),
    });
  } else {
    const pronunciationUnaccented = removeDiacritics(pronunciation);
    await CjkRepository.save({
      ideogram,
      ideogram_raw: req.body.ideograms,
      main: 1,
      pronunciation,
      pronunciation_unaccented: pronunciationUnaccented,
      language_id: 1,
      simplified: 1,
      hsk: 999,
      type: 'W',
      usage: 0,
      created_at: new Date(),
      definition_pt: JSON.stringify(req.body.dictionary),
    });

    const cacheKey = `PINYIN_${ideogram}`;

    await ArrayCache.forget(cacheKey);
    await RedisCache.forget(cacheKey);
  }

  res.setHeader('Content-Type', 'application/json');
  res.send(JSON.stringify({}));
});
開發者ID:pierophp,項目名稱:pinyin,代碼行數:60,代碼來源:unihan.controller.ts

示例2:

 sels.forEach(selection => {
     let text = d.getText(new vscode.Range(selection.start, selection.end));
     let newText = DiacriticsRemover.remove(text);
     e.edit(edit => {
         edit.replace(selection, newText);
     });
 });
開發者ID:zemacik,項目名稱:vscode-diakritika-sk-extension,代碼行數:7,代碼來源:extension.ts

示例3: extractPinyinTone

      pinyin.forEach(syllable => {
        let tone = extractPinyinTone(syllable);
        if (tone === 0) {
          tone = 5;
        }

        syllable = syllable.replace(/[ǖǘǚǜü]/, 'v');
        pinyinTones += `${removeDiacritics(syllable)}${tone}`;
      });
開發者ID:pierophp,項目名稱:pinyin,代碼行數:9,代碼來源:pleco.export.ts

示例4: prepareAnswer

 private prepareAnswer(answer: string): string {
     return (diacritics.remove(answer) as string)
         .toLowerCase()
         .trim()
         .replace(/\W/g, ' ');
 }
開發者ID:QuentinFchx,項目名稱:quizz,代碼行數:6,代碼來源:Question.ts

示例5:

import * as diacritics from "diacritics";

const replacementListItem = diacritics.replacementList[1];

// tslint:disable-next-line:no-unused-expression
replacementListItem.base === "0";
replacementListItem.chars === "\u07C0";

const mapItem = diacritics.diacriticsMap["A"];

// tslint:disable-next-line:no-unused-expression
diacritics.remove("foo") === "bar";
開發者ID:AbraaoAlves,項目名稱:DefinitelyTyped,代碼行數:12,代碼來源:diacritics-tests.ts


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