当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript ramda.map函数代码示例

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


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

示例1: createCorrectReplacementSet

  private createCorrectReplacementSet(syllable: string) {
    const vowels = ['a', 'e', 'i', 'o', 'u'];
    const knownVowels = intersection(vowels, this.letters);
    const longVowels = map(vowel => vowel + vowel, vowels);
    const knownLongVowels = map(vowel => vowel + vowel, knownVowels);
    const diphtongs = ['ie', 'ei', 'au', 'eu', 'äu'];
    const umlauts = ['ä', 'ö', 'ü'];

    // start with the sets containing strings of length two!
    const possibleReplacementSetsLowercase = [
      knownLongVowels,
      diphtongs,
      longVowels,
      umlauts,
      knownVowels,
      vowels
    ];
    const possibleReplacementSetsCapitalized = map(
      set => map(capitalizeFirstLetter, set),
      possibleReplacementSetsLowercase
    );
    return find(
      set => set.length > 0 && new RegExp(join('|', set), 'g').test(syllable),
      [
        ...possibleReplacementSetsCapitalized,
        ...possibleReplacementSetsLowercase
      ]
    );
  }
开发者ID:serlo-org,项目名称:serlo-abc,代码行数:29,代码来源:connect-syllables.ts

示例2: extractDefinition

const composeSenseData = (senseMarkup: string): SenseData => {
    const definition = extractDefinition(senseMarkup)
    const situation = extractSituation(senseMarkup)
    const geography = extractGeography(senseMarkup)
    const synonym = extractSynonym(senseMarkup)
    const antonym = extractAntonym(senseMarkup)
    const examples = extractExamples(senseMarkup)
    const exampleGroups = R.pipe(
        splitBySelector({
            selector: '.ColloExa, .GramExa',
            onlyChildren: true
        }),
        R.map(composeExampleGroupData)
    )(senseMarkup)
    const subsenses = R.pipe(
        splitBySelector({ selector: '.Subsense' }),
        R.map(composeSenseData)
    )(senseMarkup)

    const senseData = {
        definition,
        situation,
        geography,
        synonym,
        antonym,
        examples,
        exampleGroups,
        subsenses
    }

    return senseData
}
开发者ID:yakhinvadim,项目名称:longman-to-anki,代码行数:32,代码来源:composeSenseData.ts

示例3: sendSubscriptions

    /**
     * Sends all subscribed values to the Reactotron app.
     *
     * @param node The tree to grab the state data from
     */
    function sendSubscriptions(state: any) {
      // this is unreadable
      const changes = pipe(
        map(when(isNil, always(""))) as any,
        filter(endsWith(".*")),
        map((key: string) => {
          const keyMinusWildcard = slice(0, -2, key)
          const value = dotPath(keyMinusWildcard, state)
          if (is(Object, value) && !isNilOrEmpty(value)) {
            return pipe(keys, map(key => `${keyMinusWildcard}.${key}`))(value)
          }
          return []
        }) as any,
        concat(map(when(isNil, always("")), subscriptions)),
        flatten,
        reject(endsWith(".*")) as any,
        uniq as any,
        sortBy(identity) as any,
        map((key: string) => ({
          path: key,
          value: isNilOrEmpty(key) ? state : dotPath(key, state),
        })),
      )(subscriptions)

      reactotron.stateValuesChange(changes)
    }
开发者ID:nick121212,项目名称:reactotron,代码行数:31,代码来源:reactotron-mst.ts

示例4: generateExercises

  protected generateExercises() {
    const letterSymbols: Figure[] = this.newLetter
      ? [
          { name: this.newLetter.toLowerCase(), isIcon: false },
          ...(this.newLetter === 'ß'
            ? []
            : [{ name: capitalizeFirstLetter(this.newLetter), isIcon: false }])
        ]
      : [];
    const allTextSymbols: Figure[] = map(
      symbol => ({ name: symbol, isIcon: false }),
      // prettier-ignore
      [
        '0','1','2','3', '4', '5', '6', '7', '8', '9',
        '=', '!', '"', '§', '$', '%', '&', '/', '(', ')',
        '?', '<', '>', ',', ';', '.', ':', '*', '+', '#', "'", '.', '_', '-'
      ]
    );
    const allIconSymbols: Figure[] = map(
      icon => ({ name: icon, isIcon: true }),
      // prettier-ignore
      [
        'autorenew', 'block', 'bluetooth', 'border-all', 'camera', 'crop-free',
        'directions-subway', 'done', 'event-seat', 'extension', 'favorite-border',
        'fingerprint', 'flight', 'headset', 'healing', 'highlight', 'lightbulb-outline',
        'local-bar', 'local-phone', 'mic', 'nature', 'notifications', 'remove-red-eye',
        'security', 'star-border', 'usb', 'watch', 'whatshot'
      ]
    );
    const version = sample(['a', 'b'], 1);

    return [
      this.createExercise(ExerciseTypes.InfoScreenWithSounds, {
        type: 'ExplanationText',
        text: `Finden Sie den Buchstaben`,
        sound: `exercises_finden_sie_den_buchstaben_${version}`
      }),
      this.createExercise(ExerciseTypes.InfoScreen, {
        type: 'TutorialVideo',
        video: 'explanation_differ_from_symbol'
      }),
      ...map(letter => {
        const selectedSymbols: Figure[] = sample(
          concat(allTextSymbols, allIconSymbols),
          4
        );
        const symbols = sample(
          [...selectedSymbols, letter],
          selectedSymbols.length + 1
        );
        return this.createExercise(ExerciseTypes.DifferFromSymbol, {
          type: 'DifferFromSymbol',
          symbols,
          correctIndex: symbols.indexOf(letter)
        });
      }, letterSymbols)
    ];
  }
开发者ID:serlo-org,项目名称:serlo-abc,代码行数:58,代码来源:differ-from-symbol.ts

示例5: async

 async (data: IOMessage[]) => {
   const to = data[0].to // Should be consistent across batches
   const indexedData = toPairs(data) as Array<[string, IOMessage]>
   const sortedIndexedData = sortByContent(indexedData)
   const originalIndexes = pluck(0, sortedIndexedData) as string[]
   const sortedData = pluck(1, sortedIndexedData) as IOMessage[]
   const strLength = map(obj => JSON.stringify(obj).length, sortedData)
   const batches = batchData(strLength, sortedData)
   const promises = map((batch: IOMessage[]) => !!to ? messagesAPI.translate(to, batch) : Promise.resolve(pluck('content', batch)), batches)
   const translations = await Promise.all(promises).then(res => flatten<string>(res))
   const indexedTranslations = zip(originalIndexes, translations) as Array<[string, string]>
   const translationsInOriginalOrder = sortByOriginalIndex(indexedTranslations)
   return pluck(1, translationsInOriginalOrder)
 }
开发者ID:vtex,项目名称:apps-client-node,代码行数:14,代码来源:messagesLoader.ts

示例6: Promise

        R.map(file => {
          const source = path.join(imagesPath, file);

          // Create three output files
          const targets = R.map(
            suffix =>
              path.join(
                outputPath,
                `${getFilename(file)}${suffix}${getExtname(file)}`
              ),
            suffixes
          );

          return Promise.all(
            R.zipWith(
              (target, size) =>
                new Promise((resolve, reject) => {
                  gm(source)
                    .resize(size, size, '!')
                    .quality(0.8)
                    .write(target, err => {
                      if (err) {
                        reject(err);
                        return;
                      }

                      resolve();
                    });
                }),
              targets,
              sizes
            )
          );
        }, files)
开发者ID:serlo-org,项目名称:serlo-abc,代码行数:34,代码来源:generate-words-images.ts

示例7: findChildImages

export function findChildImages(parentName: string, imagesConfigMap: ImagesConfigMap): string[] {
  const confPairs = toPairs(imagesConfigMap) as [string, ImageConfig][];
  return pipe(
    filter<[string, ImageConfig]>(pathEq(['1', 'baseimage'], parentName)),
    map((arr: [string, ImageConfig]) => arr[0])
  )(confPairs);
}
开发者ID:d6u,项目名称:docker-build-layers,代码行数:7,代码来源:Util.ts

示例8: castModelKey

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

  let wrappedFields = R.omit([castModelKey('createdAt'), castModelKey('updatedAt')])(fields);
  if (R.has('id', wrappedFields)) {
    const hidden = R.isNil(wrappedFields.id.value);
    wrappedFields = R.mergeDeepRight(wrappedFields, { id: { options: { hidden } } });
  }

  const positions = R.filter(R.pathEq(['options', 'type'], 'SortPosition'))(wrappedFields);
  if (!R.isEmpty(positions)) {
    const hiddenPositions = R.map(position => ({
      ...position,
      options: { hidden: true },
    }))(positions);

    wrappedFields = R.mergeDeepRight(wrappedFields, { ...hiddenPositions });
  }
  logger.log(TAG, 'wrappedFields', { wrappedFields }, diff(fields, wrappedFields));
  return { modelName, fields: wrappedFields };
};
开发者ID:danielwii,项目名称:asuna-admin,代码行数:28,代码来源:index.ts

示例9: wrapForeignOpt

export const associationDecorator = ({ modelName, fields }: { modelName: string; fields }) => {
  const TAG = '[associationDecorator]';
  logger.log(TAG, { fields });

  // prettier-ignore
  const associationFields = R.filter(R.compose(R.not, R.isNil, R.prop('associations')))(fields);
  logger.log(TAG, { associationFields }, R.not(R.isEmpty(associationFields)));
  if (R.not(R.isEmpty(associationFields))) {
    const wrapForeignOpt = R.map(opt => ({
      ...opt,
      association: AppContext.adapters.models.getAssociationConfigs(opt.modelName),
    }));
    const withAssociations = R.mapObjIndexed(field => ({
      ...field,
      foreignOpts: wrapForeignOpt(field.foreignOpts),
    }))(associationFields);
    logger.debug(TAG, { withAssociations, wrapForeignOpt });

    const wrappedFields = R.mergeDeepRight(fields, withAssociations);
    logger.debug(TAG, { wrappedFields });

    return { modelName, fields: wrappedFields };
  }

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

示例10: initializeNavigation

  private initializeNavigation(models: NavModel[]): void {
    const mapName: any = R.map((model: NavModel) => {
      return [model.config.route, model];
    });

    this.navigation = R.pipe(mapName, R.fromPairs)(models) as { [k: string]: NavModel };
  }
开发者ID:devkat,项目名称:calendar,代码行数:7,代码来源:navigation.ts


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