本文整理汇总了TypeScript中ramda.contains函数的典型用法代码示例。如果您正苦于以下问题:TypeScript contains函数的具体用法?TypeScript contains怎么用?TypeScript contains使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了contains函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1:
R.filter(role => {
// 判断返回的是否是 ids
if (user.roles && _.isObjectLike(user.roles[0])) {
return R.contains(role.id)(R.values(R.pluck('id', user.roles)));
}
return R.contains(role.id)(user.roles);
}),
示例2: compose
getIdOrNullFor = type => compose(
ifElse(isNil, always(null), compose(
ifElse(
contains(type),
compose<string, string[], string, number, Record<string, number>>(
objOf(`${type}_id`), Number, last, split('-'),
),
always(null),
),
)),
);
示例3: newId
export const craftMinion = (props: CraftMinionProps): Minion => ({
abilities: [],
attacksPerformed: 0,
// TODO: refactor
exhausted: !!props.abilities && props.abilities.length > 0
? !R.contains(Ability.Charge, props.abilities)
: true,
destroyed: false,
health: props.maxHealth,
...props,
id: newId(),
type: CardType.Minion,
});
示例4: function
route.query = function(context) {
// console.log(context);
context.query = queryParser(context.query || {});
context.method = route.method;
if (route.method === 'get') {
context.query.limit = context.query.limit || options.defaultLimit;
if (context.query.limit > options.maxItems) {
context.query.limit = options.maxItems;
}
}
let query = queryGenerator(context);
let base;
if (context.query.scope) {
base = sequelize.models[state.model].scope(context.query.scope);
}
else {
base = sequelize.models[state.model];
}
let f = base[methodMap[state.type][route.method]];
let fParams = [query];
if (R.contains(route.method, ['put', 'post', 'update'])) {
fParams.unshift(context.payload);
}
return f.apply(base, fParams).then((response) => {
if (route.method === 'put') {
let updated = response[1];
if (state.type === 'row') {
return updated.length === 0 ? null : updated[0];
}
else {
return updated;
}
}
if (route.method === 'delete') {
return {id: context.identifiers[state.identifier]};
}
else {
return response;
}
});
};
示例5: getExplanationVideos
private getExplanationVideos(letter: string) {
if (contains(letter, ['a', 'e', 'n'])) {
return [
this.createExercise(ExerciseTypes.InfoScreen, {
type: 'TutorialVideo',
video: `explanation_find_letter_${letter}_w_letter`
}),
this.createExercise(ExerciseTypes.InfoScreen, {
type: 'TutorialVideo',
video: `explanation_find_letter_${letter}_wo_letter`
})
];
}
return [];
}
示例6: getExplanationVideos
private getExplanationVideos(letter: string) {
if (contains(letter, ['h', 'i', 'r'])) {
return [
this.createExercise(ExerciseTypes.InfoScreen, {
type: 'TutorialVideo',
video: `explanation_has_phoneme_${letter}_w_phoneme`
}),
this.createExercise(ExerciseTypes.InfoScreen, {
type: 'TutorialVideo',
video: `explanation_has_phoneme_${letter}_wo_phoneme`
})
];
}
return [];
}
示例7: createOptionsForSyllable
private createOptionsForSyllable(syllable: string) {
// find correct replacements (doubled vowels, diphtongs or knownVowels)
const replacementSet = this.createCorrectReplacementSet(syllable);
if (!replacementSet) {
return undefined;
}
// create a syllable option for each element in the replacement set
const result = map(
replacement =>
syllable.replace(
new RegExp(`(${join('|', replacementSet)})`, 'g'),
replacement
),
replacementSet
);
return contains(syllable, result) ? result : [...result, syllable];
}
示例8:
(ability: Ability, entity: Card): boolean =>
R.contains(ability, entity.abilities)
示例9: isItemCompleted
function isItemCompleted(item: ITodoItem): boolean {
return R.contains("completed", item.states);
}
示例10: curryN
const containsText = curryN(2, (textToSearch, list) => contains(list, textToSearch))