本文整理汇总了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";