當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。