本文整理匯總了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))