• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript ramda.without函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中ramda.without函数的典型用法代码示例。如果您正苦于以下问题:TypeScript without函数的具体用法?TypeScript without怎么用?TypeScript without使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了without函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。

示例1: generateExercises

  protected generateExercises() {
    const numberOfOldWords: number = 6;
    const oldWords = sample(
      without(this.newVocabulary, this.vocabulary),
      numberOfOldWords
    );
    const words = sample(
      [...oldWords, ...this.newVocabulary],
      this.newVocabulary.length + numberOfOldWords
    );

    const version = sample(['a', 'b'], 1);

    return [
      this.createExercise(ExerciseTypes.InfoScreenWithSounds, {
        type: 'ExplanationText',
        text: 'Hören Sie den Laut?',
        sound: `exercises_hoeren_sie_den_laut_${version}`
      }),
      ...map(word => {
        const [phoneme] = sample(this.props.letters, 1);
        return this.createExercise(ExerciseTypes.HasPhoneme, {
          type: 'HasPhoneme',
          word,
          phoneme
        });
      }, words)
    ];
  }
开发者ID:serlo-org,项目名称:serlo-abc,代码行数:29,代码来源:has-phoneme-revision.ts


示例2: sample

 ...map(word => {
   const otherWords = sample(without([word], this.vocabulary), 3);
   const wordsProp = sample([...otherWords, word], 4);
   return this.createExercise(ExerciseTypes.MatchImage, {
     type: 'MatchImage',
     words: wordsProp,
     correctIndex: indexOf(word, wordsProp)
   });
 }, words)
开发者ID:serlo-org,项目名称:serlo-abc,代码行数:9,代码来源:match-image.ts


示例3: map

 const options = map(missingLetterIndex => {
   const opt = sample(
     [
       ...sample(
         without(
           [wordLetters[missingLetterIndex].toLowerCase()],
           this.letters
         ),
         numberOfOptions - 1
       ),
       wordLetters[missingLetterIndex]
     ],
     numberOfOptions
   );
   return wordLetters[missingLetterIndex] ===
     wordLetters[missingLetterIndex].toLowerCase()
     ? map(s => s.toLowerCase(), opt)
     : map(capitalizeFirstLetter, opt);
 }, missing);
开发者ID:serlo-org,项目名称:serlo-abc,代码行数:19,代码来源:missing-letter.ts


示例4: update

  },
  // update :: Number → a → [a] → [a]
  update(index, val, list) {
    return R.update(index, val, list)
  },
  // adjust :: (a → a) → Number → [a] → [a]
  adjust(index, fn, list) {
    return R.adjust(fn, index, list)
  },
  // remove :: Number → Number → [a] → [a] (drop / dropLast)
  remove(fromIndex, number, list) {
    return R.remove(fromIndex, number, list)
  },
  // without {a∣a∉xs ∩ a∈ys} :: [a] → [a] → [a]
  without(listA, listB) {
    return R.without(listA, listB)
  },

  // sum :: [Number] → Number
  sum(filed, list) {
    return R.compose(R.sum, R.pluck(filed))(list)
  },
  // pluck :: Functor f => k → f {k: v} → f v
  pluck(filed, list) {
    return R.pluck(filed)(list)
  },
  // filter :: Filterable f => (a → Boolean) → f a → f a
  filter(fn, list) {
    return R.filter(fn, list)
  },
  // findIndex :: (a → Boolean) → [a] → Number
开发者ID:stefaniepei,项目名称:react-redux-scaffold,代码行数:31,代码来源:ramda.ts


示例5: castModelName

export const enumDecorator = ({
  modelName,
  fields,
}: {
  modelName: string;
  fields: (Fields & WithHidden) | PositionsField | EnumField;
}): { modelName; fields: (Fields & WithHidden) | PositionsField | EnumField } => {
  const TAG = '[enumDecorator]';
  logger.log(TAG, { fields });

  const enumFilterFields = R.filter(R.propEq('type', DynamicFormTypes.EnumFilter))(fields);
  if (R.not(R.isEmpty(enumFilterFields))) {
    const [, enumFilterField] = R.toPairs(enumFilterFields)[0];
    logger.debug(TAG, { enumFilterField });

    const enums = _.map(
      _.keys(idx(enumFilterField as EnumField, _ => _.options.enumData)),
      castModelName,
    );
    const current = castModelName(R.pathOr('', ['value'])(enumFilterField));
    logger.debug(TAG, { enums, current });

    // check if positions has value already
    // save positions value if no value exists, update models' sequence for else
    const positionsFieldPair = R.compose(
      R.toPairs,
      R.map(field => {
        // raw is the original value, if exists, means it's update request
        if (field.value && !field.raw) {
          const value = R.is(String, field.value) ? JSON.parse(field.value) : field.value;
          return { ...field, value, raw: field.value };
        }
        return { ...field, value: R.path([current, 'value'])(fields), raw: field.value };
      }),
      R.filter(R.pathEq(['options', 'type'], 'SortPosition')),
    )(fields);

    const filteredNames = R.without(current)(enums);
    const filteredFields = R.omit(filteredNames)(fields);
    const wrappedFields = current
      ? R.mergeDeepRight(filteredFields, {
          [current]: {
            isFilterField: true,
            options: { filterType: R.path(['options', 'filterType'])(enumFilterField) },
            value: R.isEmpty(positionsFieldPair)
              ? R.path([current, 'value'])(filteredFields)
              : R.path([0, 1, 'value'])(positionsFieldPair),
          },
          ...R.fromPairs(positionsFieldPair),
        })
      : filteredFields;

    logger.debug(TAG, 'wrappedFields', {
      current,
      filteredNames,
      filteredFields,
      wrappedFields,
      positionsFieldPair,
    });

    return { modelName, fields: wrappedFields };
  }

  return { modelName, fields };
};
开发者ID:danielwii,项目名称:asuna-admin,代码行数:65,代码来源:index.ts


示例6: generateExercises

  protected generateExercises() {
    const numberOfOldWords: number = 6;
    const oldWords = sample(
      without(this.newVocabulary, this.vocabulary),
      numberOfOldWords
    );
    const words = sample(
      [...oldWords, ...this.newVocabulary],
      this.newVocabulary.length + numberOfOldWords
    );

    const version = sample(['a', 'b'], 1);
    const text: string =
      this.props.difficulty < 0.2
        ? 'Ergänzen Sie den fehlenden Buchstaben.'
        : 'Ergänzen Sie die fehlenden Buchstaben.';

    const sound: string =
      this.props.difficulty < 0.2
        ? `exercises_ergaenzen_sie_den_fehlenden_buchstaben_${version}`
        : `exercises_ergaenzen_sie_die_fehlenden_buchstaben_${version}`;

    {
      /*const wordObj creates String
      const wordLetters array of splitted substrings of the wordObj
      const numberOfOptions
      const numberMissing number of missing letters
      const knownLettersInWord list containing
      const missing
      const options
      */
    }
    return [
      this.createExercise(ExerciseTypes.InfoScreenWithSounds, {
        type: 'ExplanationText',
        text,
        sound
      }),
      this.createExercise(ExerciseTypes.InfoScreen, {
        type: 'TutorialVideo',
        video: 'explanation_missing_letter_esel'
      }),
      ...map(word => {
        const wordObj = this.createWord(word);
        const wordLetters = (wordObj ? wordObj.toString() : word).split('');
        const numberOfOptions: number = 3;
        const numberMissing: number =
          this.props.difficulty < 0.2
            ? 1
            : this.props.difficulty < 0.4
            ? 2
            : this.props.difficulty < 0.6
            ? 3
            : this.props.difficulty < 0.8
            ? 4
            : wordLetters.length;
        const knownLettersInWord = filter(
          i => indexOf(wordLetters[i].toLowerCase(), this.letters) !== -1,
          times(identity, wordLetters.length)
        );
        const missing = sample(knownLettersInWord, numberMissing);
        const options = map(missingLetterIndex => {
          const opt = sample(
            [
              ...sample(
                without(
                  [wordLetters[missingLetterIndex].toLowerCase()],
                  this.letters
                ),
                numberOfOptions - 1
              ),
              wordLetters[missingLetterIndex]
            ],
            numberOfOptions
          );
          return wordLetters[missingLetterIndex] ===
            wordLetters[missingLetterIndex].toLowerCase()
            ? map(s => s.toLowerCase(), opt)
            : map(capitalizeFirstLetter, opt);
        }, missing);
        return this.createExercise(ExerciseTypes.MissingText, {
          type: 'MissingText',
          word,
          text: wordLetters,
          missing,
          options
        });
      }, words)
    ];
  }
开发者ID:serlo-org,项目名称:serlo-abc,代码行数:90,代码来源:missing-letter.ts


示例7: generateExercises

  protected generateExercises() {
    const numberOfOldWords: number = 6;
    const oldWords = sample(
      without(this.newVocabulary, this.vocabulary),
      numberOfOldWords
    );
    const words = sample(
      [...oldWords, ...this.newVocabulary],
      this.newVocabulary.length + numberOfOldWords
    );

    const version = sample(['a', 'b'], 1);

    return [
      this.createExercise(ExerciseTypes.InfoScreenWithSounds, {
        type: 'ExplanationText',
        text: 'Verbinden Sie die Silben.',
        sound: `exercises_verbinden_sie_die_silben_${version}`
      }),
      this.createExercise(ExerciseTypes.InfoScreen, {
        type: 'TutorialVideo',
        video: 'explanation_connect_syllables'
      }),
      ...(filter(
        exercise => !!exercise,
        map(word => {
          const wordObj = this.createWord(word);
          if (!wordObj) {
            return undefined;
          }
          const syllablesRawString = wordObj.getRawSingular();
          if (!syllablesRawString || syllablesRawString.indexOf('|') === -1) {
            return undefined;
          }
          const syllables = syllablesRawString.replace(/['-]/g, '').split('|');

          const missingSyllableIndices = sample(
            times(identity, syllables.length),
            1
          );
          try {
            const options = map(missingSyllableIndex => {
              const syllableOptions = this.createOptionsForSyllable(
                syllables[missingSyllableIndex]
              );
              if (!syllableOptions) {
                throw new Error(
                  `ConnectSyllables: Options empty at word ${syllablesRawString}, syllable ${missingSyllableIndex}`
                );
              }
              return syllableOptions;
            }, missingSyllableIndices);

            return this.createExercise(ExerciseTypes.MissingText, {
              type: 'MissingText',
              word,
              text: syllables,
              missing: missingSyllableIndices,
              options
            });
          } catch (err) {
            Sentry.captureException(err);
            return undefined;
          }
        }, words)
        /* tslint:disable-next-line:no-any */
      ) as Array<AbstractExercise<any, any, any>>)
    ];
  }
开发者ID:serlo-org,项目名称:serlo-abc,代码行数:69,代码来源:connect-syllables.ts



注:本文中的ramda.without函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript pluck.default函数代码示例发布时间:2022-05-25
下一篇:
TypeScript ramda.when函数代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap