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


TypeScript ramda.fromPairs函数代码示例

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


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

示例1: getReasonsMapFromRows

function getReasonsMapFromRows(answerRows: Row[]): ReasonMap {
  const pairs = answerRows.map((answerRow: string[]) =>
    [answerRow[AnswerFileCols.QUESTION_NUMBER], answerRow[AnswerFileCols.REASON]] as [string, string]
  );
  return R.fromPairs(pairs);
}
开发者ID:shybyte,项目名称:wahlomat,代码行数:6,代码来源:convert.ts

示例2: getAnswerMapFromRows

function getAnswerMapFromRows(answerRows: string[][]): AnswerMap {
  const pairs = answerRows.map((answerRow: string[]) =>
    [answerRow[AnswerFileCols.QUESTION_NUMBER], toAnswer(answerRow[AnswerFileCols.ANSWER])] as [string, Answer]
  );
  return R.fromPairs(pairs);
}
开发者ID:shybyte,项目名称:wahlomat,代码行数:6,代码来源:convert.ts

示例3: 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

示例4:

/**
 * This file ties together the library's EntityGenerator class with the game's entity templates.
 * It must be imported once to complete this process.
 * After it has been imported once, the generator can be referenced by importing either this file
 * or the original file.
 */
'use strict';
import templates from './data/entities/index';
import EntityGenerator from 'shattered-lib/generators/EntityGenerator';
import R from 'ramda';

let _templates = R.fromPairs(R.map(template=>[template.name, template], R.flatten(R.values(templates))));
EntityGenerator._templates = _templates;

export default EntityGenerator;
开发者ID:nathantreid,项目名称:shattered-planes,代码行数:15,代码来源:EntityGenerator.ts

示例5: getSimilarities

export function getSimilarities(answerMap: AnswerMap, weights: WeightMap, candidates: Candidate[]): NumberMap {
  const pairs = candidates.map(candidate => [candidate.id, getSimilarity(answerMap, weights, candidate)] as [string, number]);
  return R.fromPairs(pairs);
}
开发者ID:shybyte,项目名称:wahlomat,代码行数:4,代码来源:model.ts


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