本文整理匯總了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({}));
});
示例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);
});
});
示例3: extractPinyinTone
pinyin.forEach(syllable => {
let tone = extractPinyinTone(syllable);
if (tone === 0) {
tone = 5;
}
syllable = syllable.replace(/[ǖǘǚǜü]/, 'v');
pinyinTones += `${removeDiacritics(syllable)}${tone}`;
});
示例4: prepareAnswer
private prepareAnswer(answer: string): string {
return (diacritics.remove(answer) as string)
.toLowerCase()
.trim()
.replace(/\W/g, ' ');
}
示例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";