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


TypeScript lodash.fromPairs函数代码示例

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


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

示例1: getAllOutcomesProfitLoss

export async function getAllOutcomesProfitLoss(db: Knex, params: GetProfitLossParamsType): Promise<AllOutcomesProfitLoss> {
  const { profits, outcomeValues, buckets, lastTradePriceMinusMinPrice24hAgoByOutcomeByMarketId, oldestTradePriceMinusMinPriceUserPaidForOpenPositionInLast24hByOutcomeByMarketId } = await getProfitLossData(db, params);

  const bucketedProfits = _.mapValues(profits, (pls, marketId) => {
    return bucketAtTimestamps<ProfitLossTimeseries>(pls, buckets, Object.assign(getDefaultPLTimeseries(), { marketId }));
  });

  const bucketedOutcomeValues = _.mapValues(outcomeValues, (marketOutcomeValues) => {
    return bucketAtTimestamps<OutcomeValueTimeseries>(marketOutcomeValues, buckets, getDefaultOVTimeseries());
  });

  const profit = _.mapValues(bucketedProfits, (pls, marketId) => {
    return getProfitResultsForMarket(pls, bucketedOutcomeValues[marketId], buckets, lastTradePriceMinusMinPrice24hAgoByOutcomeByMarketId, oldestTradePriceMinusMinPriceUserPaidForOpenPositionInLast24hByOutcomeByMarketId);
  });

  const marketOutcomes = _.fromPairs(_.values(_.mapValues(profits, (pls) => {
    const first = _.first(_.first(_.values(pls)))!;
    return [first.marketId, first.numOutcomes];
  })));

  return {
    profit,
    marketOutcomes,
    buckets,
  };
}
开发者ID:AugurProject,项目名称:augur_node,代码行数:26,代码来源:get-profit-loss.ts

示例2: map

export function makeLookup<T>(
  items: Array<T>,
  key: string
): { [key: string]: T } {
  // Yep, we can't index into item without knowing what it is. True. But we want to.
  // @ts-ignore
  const pairs = map(items, item => [item[key], item]);

  return fromPairs(pairs);
}
开发者ID:WhisperSystems,项目名称:Signal-Desktop,代码行数:10,代码来源:makeLookup.ts

示例3: map

  map(byRule, (list, ruleName) => {
    const byCategory = groupBy(list, 'reasonCategory');

    return [
      ruleName,
      fromPairs(
        map(byCategory, (innerList, categoryName) => {
          return [categoryName, innerList.length];
        })
      ),
    ];
  })
开发者ID:WhisperSystems,项目名称:Signal-Desktop,代码行数:12,代码来源:analyze_exceptions.ts

示例4: if

      return _.reduce(groupedRows, (result: T | undefined, row: T): T => {
        if (typeof result === "undefined") return row;

        const mapped = _.map(row, (value: BigNumber | number | null, key: string): Array<any> => {
          const previousValue = result[key];
          if (sumFields.indexOf(key) === -1 || typeof previousValue === "undefined" || value === null || typeof value === "undefined") {
            return [key, value];
          } else if (BigNumber.isBigNumber(value)) {
            return [key, (value as BigNumber).plus(result[key] as BigNumber)];
          } else {
            return [key, value + previousValue];
          }
        }) as Array<any>;

        return _.fromPairs(mapped) as T;
      }) as T;
开发者ID:AugurProject,项目名称:augur_node,代码行数:16,代码来源:database.ts

示例5: Map

export function filterCommandLineOptions<O extends CommandMetadataOption>(options: readonly O[], parsedArgs: CommandLineOptions, predicate: OptionPredicate<O> = () => true): CommandLineOptions {
  const initial: CommandLineOptions = { _: parsedArgs._ };

  if (parsedArgs['--']) {
    initial['--'] = parsedArgs['--'];
  }

  const mapped = new Map([
    ...options.map((o): [string, O] => [o.name, o]),
    ...lodash.flatten(options.map(opt => opt.aliases ? opt.aliases.map((a): [string, O] => [a, opt]) : [])),
  ]);

  const pairs = Object.keys(parsedArgs)
    .map((k): [string, O | undefined, ParsedArg | undefined] => [k, mapped.get(k), parsedArgs[k]])
    .filter(([ k, opt, value ]) => opt && predicate(opt, value))
    .map(([ k, opt, value ]) => [opt ? opt.name : k, value]);

  return { ...initial, ...lodash.fromPairs(pairs) };
}
开发者ID:driftyco,项目名称:ionic-cli,代码行数:19,代码来源:options.ts

示例6: loadImageData

function loadImageData(state, action) {

    if (action.error) {
        return Object.assign({}, state, {
            isLoading: false,
            errorMessage: action.payload.message
        })
    }

    let dataSet = _.fromPairs(action.payload.map(img => [img.id, img]))
    return Object.assign({}, state, {
        isLoading: false,
        dataSet,
        displayedItems: getDisplayedItems({
            dataSet,
            sortBy: state.sortBy,
            isAscending: state.isAscending,
            excludedTags: state.excludedTags
        })
    })
}
开发者ID:ng-cookbook,项目名称:angular2-redux-complex-ui,代码行数:21,代码来源:image-list.ts

示例7: fromPairs

 (part: [string, string, string, PredicateRaw, string]) =>
   fromPairs(
     zip(["axis", "namespace", "name", "predicates", "attribute"], part)
   ) as Record<string, any>
开发者ID:ariutta,项目名称:cxml,代码行数:4,代码来源:xpath.ts

示例8: cb

 (err, res) => {
   return cb(err, _.fromPairs(res.filter(Boolean) as any[]));
 }
开发者ID:bitpay,项目名称:bitcore,代码行数:3,代码来源:pushnotificationsservice.ts

示例9:

        ]).spread(function(alertEmitters, uiDescriptor) {
            context.object = _.fromPairs<AlertEmitter>((_.map(alertEmitters, (alertEmitter: AlertEmitter) => [alertEmitter.name, alertEmitter]) as Array<any>));
            context.userInterfaceDescriptor = uiDescriptor;

            return self.updateStackWithContext(stack, context);
        });
开发者ID:mactanxin,项目名称:gui,代码行数:6,代码来源:system.ts


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