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


TypeScript ramda.contains函數代碼示例

本文整理匯總了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);
 }),
開發者ID:danielwii,項目名稱:asuna-admin,代碼行數:7,代碼來源:menu.redux.ts

示例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),
    ),
  )),
);
開發者ID:displague,項目名稱:manager,代碼行數:11,代碼來源:createDevicesFromStrings.ts

示例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,
});
開發者ID:zernie,項目名稱:typescript-redux-card-game,代碼行數:13,代碼來源:Minion.ts

示例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;
        }
      });
    };
開發者ID:repositive,項目名稱:hapi-path-generator,代碼行數:49,代碼來源:sequelizePaths.ts

示例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 [];
  }
開發者ID:serlo-org,項目名稱:serlo-abc,代碼行數:16,代碼來源:find-letter.ts

示例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 [];
  }
開發者ID:serlo-org,項目名稱:serlo-abc,代碼行數:16,代碼來源:has-phoneme.ts

示例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];
  }
開發者ID:serlo-org,項目名稱:serlo-abc,代碼行數:19,代碼來源:connect-syllables.ts

示例8:

 (ability: Ability, entity: Card): boolean =>
   R.contains(ability, entity.abilities)
開發者ID:zernie,項目名稱:typescript-redux-card-game,代碼行數:2,代碼來源:Card.ts

示例9: isItemCompleted

 function isItemCompleted(item: ITodoItem): boolean {
     return R.contains("completed", item.states);
 }
開發者ID:ababup1192,項目名稱:react-bacon-todomvc-typescript,代碼行數:3,代碼來源:todos.ts

示例10: curryN

const containsText = curryN(2, (textToSearch, list) => contains(list, textToSearch))
開發者ID:skellock,項目名稱:apisauce,代碼行數:1,代碼來源:apisauce.ts


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